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


C++ string_view::data方法代码示例

本文整理汇总了C++中std::string_view::data方法的典型用法代码示例。如果您正苦于以下问题:C++ string_view::data方法的具体用法?C++ string_view::data怎么用?C++ string_view::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::string_view的用法示例。


在下文中一共展示了string_view::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

std::string operator+(std::string_view a, std::string_view b)
{
    std::string result;
    result.reserve(a.size() + b.size());
    result.append(a.data(), a.size());
    result.append(b.data(), b.size());
    return result;
}
开发者ID:emlai,项目名称:zenith,代码行数:8,代码来源:utility.cpp

示例2: operator

  bool operator()(std::string_view lhs, std::string_view rhs) const {
#if _WIN32
    if (_stricmp(lhs.data(), rhs.data()) < 0)
#else
    if (strcasecmp(lhs.data(), rhs.data()) < 0)
#endif
      return true;
    return false;
  }
开发者ID:AxioDL,项目名称:amuse,代码行数:9,代码来源:DirectoryEnumerator.hpp

示例3: writeString

/*!
  */
void SettingNodeBase::writeString(const std::string_view& text,
                                  std::ostream* data_stream) const noexcept
{
  const uint32 text_length = zisc::cast<uint32>(text.size());
  zisc::write(&text_length, data_stream);
  zisc::write(text.data(), data_stream, text_length);
}
开发者ID:byzin,项目名称:Nanairo,代码行数:9,代码来源:setting_node_base.cpp

示例4: easy

   std::vector<unsigned int> fetch_unread_uids(std::string_view folder)
   {
      std::stringstream str;

      try
      {
         curl::curl_ios<std::stringstream> writer(str);

         curl::curl_easy easy(writer);
         easy.add<CURLOPT_URL>((url.data() + std::string("/") + folder.data() + std::string("/")).c_str());
         easy.add<CURLOPT_CUSTOMREQUEST>("SEARCH UNSEEN");
         setup_easy(easy);

         easy.perform();
      }
      catch (curl::curl_easy_exception const & error)
      {
         auto errors = error.get_traceback();
         error.print_traceback();
      }

      std::vector<unsigned int> uids;
      str.seekg(8, std::ios::beg);
      unsigned int uid;
      while (str >> uid)
         uids.push_back(uid);

      return uids;
   }
开发者ID:keitee,项目名称:kb,代码行数:29,代码来源:main.cpp

示例5: sendToBlender

void DCLN::sendToBlender(hecl::blender::Connection& conn, std::string_view entryName) {
  /* Open Py Stream and read sections */
  hecl::blender::PyOutStream os = conn.beginPythonOut(true);
  os.format(
      "import bpy\n"
      "import bmesh\n"
      "from mathutils import Vector, Matrix\n"
      "\n"
      "bpy.context.scene.name = '%s'\n"
      "# Clear Scene\n"
      "for ob in bpy.data.objects:\n"
      "    if ob.type != 'CAMERA':\n"
      "        bpy.context.scene.objects.unlink(ob)\n"
      "        bpy.data.objects.remove(ob)\n",
      entryName.data());

  DeafBabe::BlenderInit(os);
  atInt32 idx = 0;
  for (const Collision& col : collision) {
    DeafBabeSendToBlender(os, col, true, idx++);
#if DCLN_DUMP_OBB
    col.root.sendToBlender(os);
#endif
  }
  os.centerView();
  os.close();
}
开发者ID:AxioDL,项目名称:urde,代码行数:27,代码来源:DCLN.cpp

示例6: browseTexture

// -----------------------------------------------------------------------------
// Opens the texture browser for [tex_type] textures, with [init_texture]
// initially selected. Returns the selected texture
// -----------------------------------------------------------------------------
std::string MapEditor::browseTexture(
	std::string_view init_texture,
	TextureType      tex_type,
	SLADEMap&        map,
	std::string_view title)
{
	// Unlock cursor if locked
	bool cursor_locked = edit_context->mouseLocked();
	if (cursor_locked)
		edit_context->lockMouse(false);

	// Setup texture browser
	MapTextureBrowser browser(map_window, tex_type, wxString{ init_texture.data(), init_texture.size() }, &map);
	browser.SetTitle(WxUtils::strFromView(title));

	// Get selected texture
	std::string tex;
	if (browser.ShowModal() == wxID_OK)
		tex = browser.selectedItem()->name();

	// Re-lock cursor if needed
	if (cursor_locked)
		edit_context->lockMouse(true);

	return tex;
}
开发者ID:SteelTitanium,项目名称:SLADE,代码行数:30,代码来源:MapEditor.cpp

示例7: resolveIdFromName

ObjectId NameDB::resolveIdFromName(std::string_view str) const {
  auto search = m_stringToId.find(std::string(str));
  if (search == m_stringToId.cend()) {
    Log.report(logvisor::Error, "Unable to resolve name %s", str.data());
    return {};
  }
  return search->second;
}
开发者ID:AxioDL,项目名称:amuse,代码行数:8,代码来源:Common.cpp

示例8: ItemNameToType

CPlayerState::EItemType CPlayerState::ItemNameToType(std::string_view name) {
  std::string lowName = name.data();
  athena::utility::tolower(lowName);
  if (g_TypeNameMap.find(lowName) == g_TypeNameMap.end())
    return EItemType::Invalid;

  return g_TypeNameMap.find(lowName)->second;
}
开发者ID:AxioDL,项目名称:urde,代码行数:8,代码来源:CPlayerState.cpp

示例9: outputString

void outputString( std::string_view string ) {
#ifdef _WIN32
    OutputDebugStringA( string.data() );
    OutputDebugStringA( "\n" );
#endif
    std::setlocale( LC_ALL, "en_US.utf-8" );
    std::cout << string << std::endl;
}
开发者ID:vanderlokken,项目名称:storm,代码行数:8,代码来源:user_input.cpp

示例10: loadFile

	bool loadFile(const std::string_view file, Document& doc)
	{
		if (file.empty() == true)
		{
			return false;
		}
		return loadJson(FileUtils::readText(file.data()), doc);
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:8,代码来源:JsonUtils.cpp

示例11: create_stmt

SQLiteDb::SQLiteStmt SQLiteDb::create_stmt(std::string_view const Stmt) const
{
	sqlite::sqlite3_stmt* pStmt;

	// https://www.sqlite.org/c3ref/prepare.html
	// If the caller knows that the supplied string is nul-terminated,
	// then there is a small performance advantage to passing an nByte parameter
	// that is the number of bytes in the input string *including* the nul-terminator.

	// We use data() instead of operator[] here to bypass any bounds checks in debug mode
	const auto IsNullTerminated = !Stmt.data()[Stmt.size()];

	const auto Result = sqlite::sqlite3_prepare_v3(m_Db.get(), Stmt.data(), static_cast<int>(Stmt.size() + (IsNullTerminated? 1 : 0)), SQLITE_PREPARE_PERSISTENT, &pStmt, nullptr);
	if (Result != SQLITE_OK)
		throw MAKE_FAR_EXCEPTION(format(L"SQLiteDb::create_stmt error {0} - {1}", Result, GetErrorString(Result)));

	return SQLiteStmt(pStmt);
}
开发者ID:johnd0e,项目名称:farmanager,代码行数:18,代码来源:sqlitedb.cpp

示例12: loadJson

	bool loadJson(const std::string_view json, Document& doc)
	{
		if (json.empty() == true)
		{
			return false;
		}
		// Default template parameter uses UTF8 and MemoryPoolAllocator.
		return (doc.Parse(json.data(), json.size()).HasParseError() == false);
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:9,代码来源:JsonUtils.cpp

示例13: translate_text

   std::wstring translate_text(
      std::wstring_view wtext, 
      std::string_view to,
      std::string_view from = "en")
   {
      try
      {
         using namespace std::string_literals;

         std::stringstream str;
         std::string text = utf16_to_utf8(wtext);

         curl::curl_ios<std::stringstream> writer(str);
         curl::curl_easy easy(writer);

         curl::curl_header header;
         header.add("Ocp-Apim-Subscription-Key:" + app_key);

         easy.escape(text);
         auto url = endpoint + "/Translate";
         url += "?from="s + from.data();
         url += "&to="s + to.data();
         url += "&text="s + text;

         easy.add<CURLOPT_URL>(url.c_str());
         easy.add<CURLOPT_HTTPHEADER>(header.get());

         easy.perform();

         auto result = deserialize_result(str.str());
         return utf8_to_utf16(result);
      }
      catch (curl::curl_easy_exception const & error)
      {
         auto errors = error.get_traceback();
         error.print_traceback();
      }
      catch (std::exception const & ex)
      {
         std::cout << ex.what() << std::endl;
      }

      return {};
   }
开发者ID:keitee,项目名称:kb,代码行数:44,代码来源:main.cpp

示例14: saveText

	bool saveText(const std::string_view filePath, const std::string_view str) noexcept
	{
		try
		{
			std::filesystem::path path(filePath);
			if (path.has_parent_path() == true)
			{
				createDir(path.parent_path().u8string().c_str());
			}
			auto file = PHYSFS_openWrite(filePath.data());
			if (file != nullptr)
			{
				PHYSFS_writeBytes(file, str.data(), str.size());
				return PHYSFS_close(file) != 0;
			}
		}
		catch (std::exception&) {}
		return false;
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:19,代码来源:FileUtils.cpp

示例15: serialize

void serialize(movie_list const & movies, std::string_view filepath)
{
   json jdata{ { "movies", movies } };

   std::ofstream ofile(filepath.data());
   if (ofile.is_open())
   {
      ofile << std::setw(2) << jdata << std::endl;
   }
}
开发者ID:keitee,项目名称:kb,代码行数:10,代码来源:main.cpp


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