當前位置: 首頁>>代碼示例>>C++>>正文


C++ string_t::c_str方法代碼示例

本文整理匯總了C++中string_t::c_str方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::c_str方法的具體用法?C++ string_t::c_str怎麽用?C++ string_t::c_str使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在string_t的用法示例。


在下文中一共展示了string_t::c_str方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: readdir

void pal::readdir(const string_t& path, const string_t& pattern, std::vector<pal::string_t>* list)
{
    assert(list != nullptr);

    std::vector<string_t>& files = *list;

    string_t search_string(path);
    append_path(&search_string, pattern.c_str());

    WIN32_FIND_DATAW data = { 0 };
    auto handle = ::FindFirstFileExW(search_string.c_str(), FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
    if (handle == INVALID_HANDLE_VALUE)
    {
        return;
    }
    do
    {
        string_t filepath(data.cFileName);
        files.push_back(filepath);
    } while (::FindNextFileW(handle, &data));
    ::FindClose(handle);
}
開發者ID:928PJY,項目名稱:edge,代碼行數:22,代碼來源:pal.windows.cpp

示例2: init

void
logger_t::_log(
    char const *        file,
    int                 line,
    level_t             level,
    string_t const &    message
) {
    init();
    string_t thread = ( _thread == NULL ? "master" : _thread->name() );
    string_t prefix = _prefix;
    if ( prefix.substr( 0, thread.size() + 2 ) == thread + ": " ) {
        prefix.erase( 0, thread.size() + 2 );
    };
    syslog(
        levels[ level ].id,
        "%s %s(%s) %s%s",
        levels[ level ].name,
        location( file, line ).c_str(),
        thread.c_str(),
        prefix.c_str(),
        message.c_str()
    );
}; // _log
開發者ID:rucoder,項目名稱:ritex,代碼行數:23,代碼來源:logger.cpp

示例3: SaveToFile

bool SaveToFile(LPCVOID data, DWORD length, const string_t& path,
                bool take_backup) {
  // Make sure the path is available
  CreateFolder(GetPathOnly(path));

  // Take a backup if needed
  if (take_backup) {
    std::wstring new_path = path + L".bak";
    MoveFileEx(path.c_str(), new_path.c_str(),
               MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
  }

  // Save the data
  BOOL result = FALSE;
  HANDLE file_handle = OpenFileForGenericWrite(path);
  if (file_handle != INVALID_HANDLE_VALUE) {
    DWORD bytes_written = 0;
    result = ::WriteFile(file_handle, data, length, &bytes_written, nullptr);
    ::CloseHandle(file_handle);
  }

  return result != FALSE;
}
開發者ID:Hydro8182,項目名稱:taiga,代碼行數:23,代碼來源:file.cpp

示例4: selectMatch

	int selectMatch(const string_t& name)
	{
		LV_FINDINFO findInfo = { sizeof(LV_FINDINFO) }; 
		findInfo.flags = LVFI_STRING;
				
		findInfo.psz = name.c_str();
		
		int itemPos = list_.FindItem(&findInfo, -1);	
					
		if (itemPos == -1)
			return itemPos;
			
		UINT flags = list_.GetItemState(itemPos, LVIS_SELECTED);
		
		//if (!flags && LVIS_SELECTED)
		{
			LVITEM lvi = { LVIF_STATE };
			lvi.state = LVIS_SELECTED;
			lvi.stateMask = LVIS_SELECTED;
			list_.SetItemState(itemPos, &lvi);
		}
	
		return itemPos;
	}
開發者ID:SteffenL,項目名稱:Van-Helsing-game-research,代碼行數:24,代碼來源:SelectionManager.hpp

示例5: save

        bool save(const string_t& path, const trainer_states_t& states)
        {
                std::ofstream ofs(path.c_str(), std::ofstream::out);
                if (!ofs.is_open())
                {
                        return false;
                }
                
                const string_t delim = "\t";
                const size_t colsize = 24;
                
                // header
                ofs 
                << text::resize("train-loss", colsize) << delim
                << text::resize("train-error-average", colsize) << delim
                << text::resize("train-error-variance", colsize) << delim
                << text::resize("valid-loss", colsize) << delim
                << text::resize("valid-error-average", colsize) << delim
                << text::resize("valid-error-variance", colsize) << delim
                << std::endl;

                // optimization states
                for (const trainer_state_t& state : states)
                {
                        ofs 
                        << text::resize(text::to_string(state.m_tvalue), colsize) << delim
                        << text::resize(text::to_string(state.m_terror_avg), colsize) << delim
                        << text::resize(text::to_string(state.m_terror_var), colsize) << delim
                        << text::resize(text::to_string(state.m_vvalue), colsize) << delim
                        << text::resize(text::to_string(state.m_verror_avg), colsize) << delim
                        << text::resize(text::to_string(state.m_verror_var), colsize) << delim
                        << std::endl;
                }

                return ofs.good();
        }
開發者ID:0x0all,項目名稱:nanocv,代碼行數:36,代碼來源:trainer_state.cpp

示例6: stop

void stop( string_t const & message ) {
    printf( "%s\n", message.c_str() );
    exit( 1 );
}
開發者ID:HackLinux,項目名稱:goblin-core,代碼行數:4,代碼來源:objcopy.cpp

示例7:

D3DTexture::D3DTexture(D3DRenderContext& renderContext, const string_t& path) {
    CGL_CHECK(D3DXCreateTextureFromFileA(renderContext.GetDevice(), path.c_str(), &m_texture) == D3D_OK);
}
開發者ID:fromtherussia,項目名稱:e2d,代碼行數:3,代碼來源:D3DTexture.cpp

示例8: DrawBitmapText

void TextureManager::DrawBitmapText(float sx, float sy, size_t tex, SpriteColor color, const string_t &str, enumAlignText align) const
{
	// grep enum enumAlignText LT CT RT LC CC RC LB CB RB
	static const float dx[] = { 0, 1, 2, 0, 1, 2, 0, 1, 2 };
	static const float dy[] = { 0, 0, 0, 1, 1, 1, 2, 2, 2 };

	std::vector<size_t> lines;
	size_t maxline = 0;
	if( align )
	{
		size_t count = 0;
		for( const string_t::value_type *tmp = str.c_str(); *tmp; )
		{
			++count;
			++tmp;
			if( '\n' == *tmp || '\0' == *tmp )
			{
				if( maxline < count ) 
					maxline = count;
				lines.push_back(count);
				count = 0;
			}
		}
	}


	const LogicalTexture &lt = Get(tex);

	size_t count = 0;
	size_t line  = 0;

	float x0 = sx - floorf(dx[align] * (lt.pxFrameWidth - 1) * (float) maxline / 2);
	float y0 = sy - floorf(dy[align] * lt.pxFrameHeight * (float) lines.size() / 2);

	for( const string_t::value_type *tmp = str.c_str(); *tmp; ++tmp )
	{
		if( '\n' == *tmp )
		{
			++line;
			count = 0;
		}

		if( (unsigned char) *tmp < 32 )
		{
			continue;
		}

		const FRECT &rt = lt.uvFrames[(unsigned char) *tmp - 32];
		float x = x0 + (float) ((count++) * (lt.pxFrameWidth - 1));
		float y = y0 + (float) (line * lt.pxFrameHeight);

		MyVertex *v = g_render->DrawQuad(lt.dev_texture);

		v[0].color = color;
		v[0].u = rt.left;
		v[0].v = rt.top;
		v[0].x = x;
		v[0].y = y ;

		v[1].color = color;
		v[1].u = rt.left + lt.uvFrameWidth;
		v[1].v = rt.top;
		v[1].x = x + lt.pxFrameWidth;
		v[1].y = y;

		v[2].color = color;
		v[2].u = rt.left + lt.uvFrameWidth;
		v[2].v = rt.bottom;
		v[2].x = x + lt.pxFrameWidth;
		v[2].y = y + lt.pxFrameHeight;

		v[3].color = color;
		v[3].u = rt.left;
		v[3].v = rt.bottom;
		v[3].x = x;
		v[3].y = y + lt.pxFrameHeight;
	}
}
開發者ID:ACefalu,項目名稱:tzod,代碼行數:78,代碼來源:TextureManager.cpp

示例9: LoadPackage

int TextureManager::LoadPackage(const string_t &packageName, const SafePtr<FS::MemMap> &file)
{
	TRACE("Loading texture package '%s'", packageName.c_str());

	lua_State *L = lua_open();

	if( 0 != (luaL_loadbuffer(L, file->GetData(), file->GetSize(), packageName.c_str()) || lua_pcall(L, 0, 1, 0)) )
	{
		GetConsole().WriteLine(1, lua_tostring(L, -1));
		lua_close(L);
		return 0;
	}

	if( !lua_istable(L, 1) )
	{
		lua_close(L);
		return 0;
	}

	// loop over files
	for( lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1) )
	{
		// now 'key' is at index -2 and 'value' at index -1

		// check that value is a table
		if( !lua_istable(L, -1) )
		{
			TRACE("WARNING: value is not a table; skipping.");
		}

		while( lua_istable(L, -1) )
		{
			TexDescIterator td;

			// get a file name; load
			lua_getfield(L, -1, "file");
			std::string f = lua_tostring(L, -1);
			lua_pop(L, 1); // pop result of lua_getfield

			try
			{
				LoadTexture(td, f);
			}
			catch( const std::exception &e )
			{
				TRACE("WARNING: could not load texture '%s' - %s", f.c_str(), e.what());
				break;
			}


			// get 'content' field
			lua_getfield(L, -1, "content");
			if( lua_istable(L, -1) )
			{
				// loop over textures in 'content' table
				for( lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1) )
				{
					if( !lua_istable(L, -1) )
					{
						TRACE("WARNING: element of 'content' is not a table; skipping");
						continue;
					}

					lua_pushvalue(L, -2); // create copy of the key
					if( const char *texname = lua_tostring(L, -1) )
					{
						// now 'value' at index -2

						float scale_x = auxgetfloat(L, -2, "xscale", 1);
						float scale_y = auxgetfloat(L, -2, "yscale", 1);

						LogicalTexture tex;
						tex.dev_texture = td->id;

						// texture bounds
						tex.uvLeft   = (float) floorf(auxgetfloat(L, -2, "left", 0)) / (float) td->width;
						tex.uvRight  = (float) floorf(auxgetfloat(L, -2, "right", (float) td->width)) / (float) td->width;
						tex.uvTop    = (float) floorf(auxgetfloat(L, -2, "top", 0)) / (float) td->height;
						tex.uvBottom = (float) floorf(auxgetfloat(L, -2, "bottom", (float) td->height)) / (float) td->height;

						// frames count
						tex.xframes = auxgetint(L, -2, "xframes", 1);
						tex.yframes = auxgetint(L, -2, "yframes", 1);

						// frame size
						tex.uvFrameWidth  = (tex.uvRight - tex.uvLeft) / (float) tex.xframes;
						tex.uvFrameHeight = (tex.uvBottom - tex.uvTop) / (float) tex.yframes;

						// original size
						tex.pxFrameWidth  = (float) td->width  * scale_x * tex.uvFrameWidth;
						tex.pxFrameHeight = (float) td->height * scale_y * tex.uvFrameHeight;

						// pivot position
						tex.uvPivot.x = (float) auxgetfloat(L, -2, "xpivot", (float) td->width * tex.uvFrameWidth / 2) / ((float) td->width * tex.uvFrameWidth);
						tex.uvPivot.y = (float) auxgetfloat(L, -2, "ypivot", (float) td->height * tex.uvFrameHeight / 2) / ((float) td->height * tex.uvFrameHeight);

						// frames
						tex.uvFrames.reserve(tex.xframes * tex.yframes);
						for( int y = 0; y < tex.yframes; ++y )
						{
//.........這裏部分代碼省略.........
開發者ID:ACefalu,項目名稱:tzod,代碼行數:101,代碼來源:TextureManager.cpp

示例10: stringToDouble

double Utils::stringToDouble(string_t string)
{
	return atof(string.c_str());
}
開發者ID:maismail,項目名稱:cuYURI,代碼行數:4,代碼來源:Utils.cpp

示例11: stringToFloat

float Utils::stringToFloat(string_t string)
{
	return atof(string.c_str());
}
開發者ID:maismail,項目名稱:cuYURI,代碼行數:4,代碼來源:Utils.cpp

示例12: value

 void value(const string_t& val)
 {
     node_->value(val.c_str());
 }
開發者ID:CodeBlueDev,項目名稱:Xenos,代碼行數:4,代碼來源:rapidxml_wrap.hpp

示例13: SetOverlayIcon

 void cTaskBar::SetOverlayIcon(HICON hIcon, const string_t& sDescription)
 {
   std::cout<<"cTaskBar::SetOverlayIcon"<<std::endl;
   ASSERT(IsValid());
   taskBarList->SetOverlayIcon(hwndWindow, hIcon, LPCWSTR(sDescription.c_str()));
 }
開發者ID:pilkch,項目名稱:library,代碼行數:6,代碼來源:taskbar.cpp

示例14: are_paths_equal_with_normalized_casing

bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2)
{
    // On Windows, paths are case-insensitive
    return (strcasecmp(path1.c_str(), path2.c_str()) == 0);
}
開發者ID:AustinWise,項目名稱:core-setup,代碼行數:5,代碼來源:pal.windows.cpp

示例15: StringToNum

extern
T Utils::StringToNum(string_t string)
{
    return (T) atoi(string.c_str());
}
開發者ID:maismail,項目名稱:cuYURI,代碼行數:5,代碼來源:TypeConversion.cpp


注:本文中的string_t::c_str方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。