blob: d9556cc552d266f774dc7a4d06d529afeddce1db [file] [log] [blame]
Mikhail Glushenkov35576b02008-05-30 06:10:19 +00001//===--- StringSet.h - The LLVM Compiler Driver -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open
6// Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// StringSet - A set-like wrapper for the StringMap.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TOOLS_LLVMC2_STRINGSET_H
15#define LLVM_TOOLS_LLVMC2_STRINGSET_H
16
17#include "llvm/ADT/StringMap.h"
18
19#include <cassert>
20
21namespace llvmc {
22
23 /// StringSet - A wrapper for StringMap that provides set-like
24 /// functionality. Only insert() and count() methods are used by my
25 /// code.
26 template <class AllocatorTy = llvm::MallocAllocator>
27 class StringSet : public llvm::StringMap<char, AllocatorTy> {
28 typedef llvm::StringMap<char, AllocatorTy> base;
29 public:
30 void insert (const std::string& InLang) {
31 assert(!InLang.empty());
32 const char* KeyStart = &InLang[0];
33 const char* KeyEnd = KeyStart + InLang.size();
34 base::insert(llvm::StringMapEntry<char>::
35 Create(KeyStart, KeyEnd, base::getAllocator(), '+'));
36 }
37 };
38}
39
40#endif //LLVM_TOOLS_LLVMC2_STRINGSET_H