2010-11-16 10:03:55 +08:00
|
|
|
//===- 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"
|
2011-07-20 14:58:45 +08:00
|
|
|
#include "clang/Basic/LLVM.h"
|
2010-11-16 16:15:36 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2012-12-04 17:25:21 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2013-01-27 06:44:19 +08:00
|
|
|
#include <vector>
|
2010-11-16 10:03:55 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace cxstring {
|
2013-01-27 06:44:19 +08:00
|
|
|
|
|
|
|
struct CXStringBuf;
|
2010-11-16 10:03:55 +08:00
|
|
|
|
2013-02-01 22:21:22 +08:00
|
|
|
/// \brief Create a CXString object for an empty "" string.
|
|
|
|
CXString createEmpty();
|
|
|
|
|
2013-02-01 22:13:32 +08:00
|
|
|
/// \brief Create a CXString object for an NULL string.
|
2013-02-02 00:38:41 +08:00
|
|
|
///
|
|
|
|
/// A NULL string should be used as an "invalid" value in case of errors.
|
2013-02-01 22:13:32 +08:00
|
|
|
CXString createNull();
|
|
|
|
|
2010-11-16 10:03:55 +08:00
|
|
|
/// \brief Create a CXString object from a C string.
|
|
|
|
CXString createCXString(const char *String, bool DupString = false);
|
|
|
|
|
2010-11-16 16:15:36 +08:00
|
|
|
/// \brief Create a CXString object from a StringRef.
|
2011-07-20 14:58:45 +08:00
|
|
|
CXString createCXString(StringRef String, bool DupString = true);
|
2010-11-16 16:15:36 +08:00
|
|
|
|
|
|
|
/// \brief Create a CXString object that is backed by a string buffer.
|
|
|
|
CXString createCXString(CXStringBuf *buf);
|
|
|
|
|
2013-01-27 06:44:19 +08:00
|
|
|
/// \brief A string pool used for fast allocation/deallocation of strings.
|
|
|
|
class CXStringPool {
|
|
|
|
public:
|
|
|
|
~CXStringPool();
|
|
|
|
|
|
|
|
CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<CXStringBuf *> Pool;
|
|
|
|
|
|
|
|
friend struct CXStringBuf;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CXStringBuf {
|
|
|
|
SmallString<128> Data;
|
|
|
|
CXTranslationUnit TU;
|
|
|
|
|
|
|
|
CXStringBuf(CXTranslationUnit TU) : TU(TU) {}
|
|
|
|
|
|
|
|
/// \brief Return this buffer to the pool.
|
|
|
|
void dispose();
|
|
|
|
};
|
2010-11-16 16:15:36 +08:00
|
|
|
|
|
|
|
CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
|
2010-11-16 10:03:55 +08:00
|
|
|
|
2011-08-18 06:19:53 +08:00
|
|
|
/// \brief Returns true if the CXString data is managed by a pool.
|
|
|
|
bool isManagedByPool(CXString str);
|
|
|
|
|
2010-11-16 10:03:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|