当前位置: 首页>>代码示例>>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;未经允许,请勿转载。