LLVM API Documentation

StringSet.h

Go to the documentation of this file.
00001 //===--- StringSet.h - The LLVM Compiler Driver -----------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open
00006 // Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  StringSet - A set-like wrapper for the StringMap.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_ADT_STRINGSET_H
00015 #define LLVM_ADT_STRINGSET_H
00016 
00017 #include "llvm/ADT/StringMap.h"
00018 #include <cassert>
00019 
00020 namespace llvm {
00021 
00022   /// StringSet - A wrapper for StringMap that provides set-like
00023   /// functionality.  Only insert() and count() methods are used by my
00024   /// code.
00025   template <class AllocatorTy = llvm::MallocAllocator>
00026   class StringSet : public llvm::StringMap<char, AllocatorTy> {
00027     typedef llvm::StringMap<char, AllocatorTy> base;
00028   public:
00029     bool insert(const std::string& InLang) {
00030       assert(!InLang.empty());
00031       const char* KeyStart = &InLang[0];
00032       const char* KeyEnd = KeyStart + InLang.size();
00033       return base::insert(llvm::StringMapEntry<char>::
00034                           Create(KeyStart, KeyEnd, base::getAllocator(), '+'));
00035     }
00036   };
00037 }
00038 
00039 #endif // LLVM_ADT_STRINGSET_H