• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- CXString.h - Routines for manipulating CXStrings -------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines routines for manipulating CXStrings.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_CXSTRING_H
15 #define LLVM_CLANG_CXSTRING_H
16 
17 #include "clang-c/Index.h"
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/SmallString.h"
21 
22 namespace clang {
23 namespace cxstring {
24 
25 struct CXStringBuf {
26   SmallString<128> Data;
27   CXTranslationUnit TU;
CXStringBufCXStringBuf28   CXStringBuf(CXTranslationUnit tu) : TU(tu) {}
29 };
30 
31 /// \brief Create a CXString object from a C string.
32 CXString createCXString(const char *String, bool DupString = false);
33 
34 /// \brief Create a CXString object from a StringRef.
35 CXString createCXString(StringRef String, bool DupString = true);
36 
37 /// \brief Create a CXString object that is backed by a string buffer.
38 CXString createCXString(CXStringBuf *buf);
39 
40 /// \brief Create an opaque string pool used for fast geneneration of strings.
41 void *createCXStringPool();
42 
43 /// \brief Dispose of a string pool.
44 void disposeCXStringPool(void *pool);
45 
46 CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
47 
48 void disposeCXStringBuf(CXStringBuf *buf);
49 
50 /// \brief Returns true if the CXString data is managed by a pool.
51 bool isManagedByPool(CXString str);
52 
53 }
54 }
55 
56 #endif
57 
58