本文整理汇总了C++中Twine::toNullTerminatedStringRef方法的典型用法代码示例。如果您正苦于以下问题:C++ Twine::toNullTerminatedStringRef方法的具体用法?C++ Twine::toNullTerminatedStringRef怎么用?C++ Twine::toNullTerminatedStringRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twine
的用法示例。
在下文中一共展示了Twine::toNullTerminatedStringRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileManager
bool
runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code,
const std::vector<std::string> &Args,
const Twine &FileName,
const std::vector<std::pair<std::string, std::string>> &
VirtualMappedFiles) {
SmallString<16> FileNameStorage;
StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions()));
ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef),
ToolAction, Files.get());
SmallString<1024> CodeStorage;
Invocation.mapVirtualFile(FileNameRef,
Code.toNullTerminatedStringRef(CodeStorage));
for (auto &FilenameWithContent : VirtualMappedFiles) {
Invocation.mapVirtualFile(FilenameWithContent.first,
FilenameWithContent.second);
}
return Invocation.run();
}
示例2: pair
void cFontLoader::
ExportDFFToFile(tDistanceFontHandle font, const Twine& in_path /*= ""*/)
{
auto& dff = DistanceFont(font);
size_t face_size = cSerialization::SerializedSize(dff.Face());
cDFFFile pair(dff, face_size);
AlignedBuffer<16> buffer;
cSerialization::SerializeLZMA(pair,buffer);
cStringRef file_data(buffer.ptr<char>(), buffer.size());
try{
if (sys::path::has_filename(in_path))
{
WriteFileToDisk(file_data, in_path);
}
else
{
cSmallVector<char, 256> path_buf;
cStringRef temp_path = in_path.toNullTerminatedStringRef(path_buf);
sys::path::append(path_buf, in_path, dff.FontName() + ".dff");
cStringRef full_path(path_buf.data(), path_buf.size());
WriteFileToDisk(file_data, full_path);
}
}
catch (const Exception& e)
{
Log::Warn("Swallowed exception while trying to write dff file: %s",
e.what());
}
}
示例3: runToolOnCode
bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
const Twine &FileName) {
SmallString<16> FileNameStorage;
StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
const char *const CommandLine[] = {
"clang-tool", "-fsyntax-only", FileNameRef.data()
};
FileManager Files((FileSystemOptions()));
ToolInvocation Invocation(
std::vector<std::string>(
CommandLine,
CommandLine + llvm::array_lengthof(CommandLine)),
ToolAction, &Files);
SmallString<1024> CodeStorage;
Invocation.mapVirtualFile(FileNameRef,
Code.toNullTerminatedStringRef(CodeStorage));
return Invocation.run();
}
示例4: getFile
error_code MemoryBuffer::getFile(Twine Filename,
std::unique_ptr<MemoryBuffer> &Result,
int64_t FileSize,
bool RequiresNullTerminator) {
// Ensure the path is null terminated.
SmallString<256> PathBuf;
StringRef NullTerminatedName = Filename.toNullTerminatedStringRef(PathBuf);
return getFileAux(NullTerminatedName.data(), Result, FileSize,
RequiresNullTerminator);
}