Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 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" |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 18 | #include "clang/Basic/LLVM.h" |
Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringRef.h" |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/SmallString.h" |
Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 21 | |
| 22 | namespace clang { |
| 23 | namespace cxstring { |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 24 | |
| 25 | struct CXStringBuf { |
| 26 | llvm::SmallString<128> Data; |
| 27 | CXTranslationUnit TU; |
| 28 | CXStringBuf(CXTranslationUnit tu) : TU(tu) {} |
| 29 | }; |
Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 30 | |
| 31 | /// \brief Create a CXString object from a C string. |
| 32 | CXString createCXString(const char *String, bool DupString = false); |
| 33 | |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 34 | /// \brief Create a CXString object from a StringRef. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 35 | CXString createCXString(StringRef String, bool DupString = true); |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 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); |
Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 49 | |
Ted Kremenek | baf82b0 | 2011-08-17 22:19:53 +0000 | [diff] [blame] | 50 | /// \brief Returns true if the CXString data is managed by a pool. |
| 51 | bool isManagedByPool(CXString str); |
| 52 | |
Ted Kremenek | ea834df | 2010-11-16 02:03:55 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | #endif |
| 57 | |