当前位置: 首页>>代码示例>>C++>>正文


C++ Twine::toNullTerminatedStringRef方法代码示例

本文整理汇总了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();
}
开发者ID:parallaxe,项目名称:clang,代码行数:25,代码来源:Tooling.cpp

示例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());
		}
	}
开发者ID:ProframFiles,项目名称:FancyDraw,代码行数:30,代码来源:akjFontLoader.cpp

示例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();
}
开发者ID:socantre,项目名称:Clang,代码行数:19,代码来源:Tooling.cpp

示例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);
}
开发者ID:AmesianX,项目名称:dagger,代码行数:10,代码来源:MemoryBuffer.cpp


注:本文中的Twine::toNullTerminatedStringRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。