blob: 73d94f6bbb2bf8fa2ff3a2b88c533d78573486fa [file] [log] [blame]
Ted Kremenekea834df2010-11-16 02:03:55 +00001//===- 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 Lattner686775d2011-07-20 06:58:45 +000018#include "clang/Basic/LLVM.h"
Ted Kremeneka60ed472010-11-16 08:15:36 +000019#include "llvm/ADT/SmallString.h"
Chandler Carruthf59edb92012-12-04 09:25:21 +000020#include "llvm/ADT/StringRef.h"
Ted Kremenekea834df2010-11-16 02:03:55 +000021
22namespace clang {
23namespace cxstring {
Ted Kremeneka60ed472010-11-16 08:15:36 +000024
25struct CXStringBuf {
Dylan Noblesmith36d59272012-02-13 12:32:26 +000026 SmallString<128> Data;
Ted Kremeneka60ed472010-11-16 08:15:36 +000027 CXTranslationUnit TU;
28 CXStringBuf(CXTranslationUnit tu) : TU(tu) {}
29};
Ted Kremenekea834df2010-11-16 02:03:55 +000030
31/// \brief Create a CXString object from a C string.
32CXString createCXString(const char *String, bool DupString = false);
33
Ted Kremeneka60ed472010-11-16 08:15:36 +000034/// \brief Create a CXString object from a StringRef.
Chris Lattner686775d2011-07-20 06:58:45 +000035CXString createCXString(StringRef String, bool DupString = true);
Ted Kremeneka60ed472010-11-16 08:15:36 +000036
37/// \brief Create a CXString object that is backed by a string buffer.
38CXString createCXString(CXStringBuf *buf);
39
40/// \brief Create an opaque string pool used for fast geneneration of strings.
41void *createCXStringPool();
42
43/// \brief Dispose of a string pool.
44void disposeCXStringPool(void *pool);
45
46CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
47
48void disposeCXStringBuf(CXStringBuf *buf);
Ted Kremenekea834df2010-11-16 02:03:55 +000049
Ted Kremenekbaf82b02011-08-17 22:19:53 +000050/// \brief Returns true if the CXString data is managed by a pool.
51bool isManagedByPool(CXString str);
52
Ted Kremenekea834df2010-11-16 02:03:55 +000053}
54}
55
56#endif
57