1 //===- CXString.h - Routines for manipulating CXStrings -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines routines for manipulating CXStrings.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_CXSTRING_H
15 #define LLVM_CLANG_CXSTRING_H
17 #include "clang-c/Index.h"
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/SmallString.h"
20 #include "llvm/ADT/StringRef.h"
28 /// \brief Create a CXString object for an empty "" string.
29 CXString createEmpty();
31 /// \brief Create a CXString object for an NULL string.
32 CXString createNull();
34 /// \brief Create a CXString object from a C string.
35 CXString createCXString(const char *String, bool DupString = false);
37 /// \brief Create a CXString object from a StringRef.
38 CXString createCXString(StringRef String, bool DupString = true);
40 /// \brief Create a CXString object that is backed by a string buffer.
41 CXString createCXString(CXStringBuf *buf);
43 /// \brief A string pool used for fast allocation/deallocation of strings.
48 CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
51 std::vector<CXStringBuf *> Pool;
53 friend struct CXStringBuf;
57 SmallString<128> Data;
60 CXStringBuf(CXTranslationUnit TU) : TU(TU) {}
62 /// \brief Return this buffer to the pool.
66 CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
68 /// \brief Returns true if the CXString data is managed by a pool.
69 bool isManagedByPool(CXString str);