StringSet.h revision 193323
1//===--- 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_ADT_STRINGSET_H
15#define LLVM_ADT_STRINGSET_H
16
17#include "llvm/ADT/StringMap.h"
18#include <cassert>
19
20namespace llvm {
21
22  /// StringSet - A wrapper for StringMap that provides set-like
23  /// functionality.  Only insert() and count() methods are used by my
24  /// code.
25  template <class AllocatorTy = llvm::MallocAllocator>
26  class StringSet : public llvm::StringMap<char, AllocatorTy> {
27    typedef llvm::StringMap<char, AllocatorTy> base;
28  public:
29    bool insert(const std::string& InLang) {
30      assert(!InLang.empty());
31      const char* KeyStart = &InLang[0];
32      const char* KeyEnd = KeyStart + InLang.size();
33      return base::insert(llvm::StringMapEntry<char>::
34                          Create(KeyStart, KeyEnd, base::getAllocator(), '+'));
35    }
36  };
37}
38
39#endif // LLVM_ADT_STRINGSET_H
40