summaryrefslogtreecommitdiff
path: root/clang/tools/libclang/CXString.h
blob: c354bd2334e03bc358d3adecd93a9e5e42e4ec27 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===- CXString.h - Routines for manipulating CXStrings -------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines routines for manipulating CXStrings.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_CXSTRING_H
#define LLVM_CLANG_CXSTRING_H

#include "clang-c/Index.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"

namespace clang {
namespace cxstring {
  
struct CXStringBuf {
  SmallString<128> Data;
  CXTranslationUnit TU;
  CXStringBuf(CXTranslationUnit tu) : TU(tu) {}
};

/// \brief Create a CXString object from a C string.
CXString createCXString(const char *String, bool DupString = false);

/// \brief Create a CXString object from a StringRef.
CXString createCXString(StringRef String, bool DupString = true);

/// \brief Create a CXString object that is backed by a string buffer.
CXString createCXString(CXStringBuf *buf);

/// \brief Create an opaque string pool used for fast geneneration of strings.
void *createCXStringPool();

/// \brief Dispose of a string pool.
void disposeCXStringPool(void *pool);
  
CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
 
void disposeCXStringBuf(CXStringBuf *buf);

/// \brief Returns true if the CXString data is managed by a pool.
bool isManagedByPool(CXString str);

}
}

#endif