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


C++ BString::c_str方法代码示例

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


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

示例1: _openDataFile

void Slice::_openDataFile(BString &dataFileName)
{
	if (!_dataFd.open(dataFileName.c_str(), O_CREAT | O_RDWR)) {
		log::Fatal::L("Can't open slice dataFile %s\n", dataFileName.c_str());
		throw SliceError("Can't open slice dataFile");
	}
	TSize curSeek = _dataFd.seek(0, SEEK_END);
	if (curSeek < sizeof(SliceDataHeader)) 	{ // create new file
		_dataFd.seek(0, SEEK_SET);
		SliceDataHeader sh;
		sh.version = SliceDataHeader::CURRENT_VERSION;
		sh.sliceID = _sliceID;
		if (_dataFd.write(&sh, sizeof(sh)) != sizeof(sh)) {
			log::Fatal::L("Can't write slice dataFile header %s\n", dataFileName.c_str());
			throw SliceError("Can't write slice dataFile header");
		}
		_size = sizeof(sh);
	}	else {
		_dataFd.seek(0, SEEK_SET);
		SliceDataHeader sh;
		if (_dataFd.read(&sh, sizeof(sh)) != sizeof(sh)) {
			log::Fatal::L("Can't read slice dataFile header %s\n", dataFileName.c_str());
			throw SliceError("Can't read slice dataFile header");
		}
		if (sh.sliceID != _sliceID) {
			log::Fatal::L("SliceID mismatch in %s, %u != %u\n", dataFileName.c_str(), _sliceID, sh.sliceID);
			throw SliceError("SliceID mismatch");
		}
		_size = _dataFd.seek(0, SEEK_END);
	}
}
开发者ID:AntonOrnatskyi,项目名称:metis,代码行数:31,代码来源:slice.cpp

示例2:

			File::File( const BString& strFileName, const BString& strPassword )
			{
				Init();

				m_pRead = (void*)XZip::OpenZip( strFileName.c_str(), strPassword.c_str() );
				RefreshFiles();
			}
开发者ID:ace13,项目名称:bootil,代码行数:7,代码来源:Compression.cpp

示例3: _openIndexFile

void Slice::_openIndexFile(BString &indexFileName)
{
	if (!_indexFd.open(indexFileName.c_str(), O_CREAT | O_RDWR)) {
		log::Fatal::L("Can't open slice dataFile %s\n", indexFileName.c_str());
		throw SliceError("Can't open slice dataFile");
	}
	TSize curSeek = _indexFd.seek(0, SEEK_END);
	if (curSeek < sizeof(SliceIndexHeader)) {
		_rebuildIndexFromData(indexFileName);
	}	else {
		_indexFd.seek(0, SEEK_SET);
		try
		{
			SliceIndexHeader sh;
			if (_indexFd.read(&sh, sizeof(sh)) != sizeof(sh)) {
				log::Fatal::L("Can't read slice indexFile header %s\n", indexFileName.c_str());
				throw SliceError("Can't read slice indexFile header");
			}
			if (sh.sliceID != _sliceID) {
				log::Fatal::L("SliceID mismatch in %s, %u != %u\n", indexFileName.c_str(), _sliceID, sh.sliceID);
				throw SliceError("SliceID mismatch");
			}
			_indexFd.seek(0, SEEK_END);
		}
		catch (SliceError &er)
		{
			_rebuildIndexFromData(indexFileName);
		}
	}
}
开发者ID:AntonOrnatskyi,项目名称:metis,代码行数:30,代码来源:slice.cpp

示例4: PopupMessage

		BOOTIL_EXPORT void PopupMessage( const char* str, ... )
		{
			BString strBuilt;
			Bootil_FormatString( strBuilt, str );

			Output::Warning( strBuilt.c_str() );
			printf( "%s", strBuilt.c_str() );

			Bootil::Platform::Popup( "Bootil", strBuilt );
		}
开发者ID:ace13,项目名称:bootil,代码行数:10,代码来源:Debug.cpp

示例5: Write

		BOOTIL_EXPORT bool Write( const BString & strFileName, const BString & strOut )
		{
			std::ofstream f( strFileName.c_str(), std::ios_base::out );

			if ( !f.is_open() ) { return false; }

			f.write( strOut.c_str(), strOut.length() );
			f.close();
			return true;
		}
开发者ID:AlVar009,项目名称:bootil,代码行数:10,代码来源:File.cpp

示例6: StartProcess

		BOOTIL_EXPORT void StartProcess( const BString & strProcess, bool AndWait )
		{
			BString strFileName = String::File::GetExtractFilename( strProcess );
			const char* args[32];
			args[0] = strFileName.c_str();
			args[1] = NULL;
			int iFlag = P_NOWAIT;

			if ( AndWait ) { iFlag = P_WAIT; }

			spawnv( P_WAIT, strProcess.c_str(), args );
		}
开发者ID:aleksijuvani,项目名称:bootil,代码行数:12,代码来源:Platform_WINDOWS.cpp

示例7: Warning

		//-----------------------------------------------------------------------------
		//  
		//-----------------------------------------------------------------------------
		BOOTIL_EXPORT void Warning( const char* str, ... )
		{
			BString strBuilt;
			Bootil_FormatString( strBuilt, str );

			Output::Msg( "%s", strBuilt.c_str() );

			for ( Debug::IListener::List::iterator i = Debug::Listeners().begin(); i != Debug::Listeners().end(); i++ )
			{
				(*i)->Warning( strBuilt.c_str() );
			}
		}
开发者ID:ace13,项目名称:bootil,代码行数:15,代码来源:Debug.cpp

示例8: SetupAssociation

		BOOTIL_EXPORT void SetupAssociation( BString ext )
		{
			//Write our file association to the registry -NOTE: must run in administrator mode once to work
			HKEY hKey;
			LPDWORD dwDisp = 0;
			BString strmv = "\"" + FullProgramName() + "\" %1";
			String::File::ToWindowsSlashes( strmv );
			BString keyName = ext + "\\shell\\open\\command";
			LONG lRet  = RegCreateKeyEx( HKEY_CLASSES_ROOT, keyName.c_str(), 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, dwDisp );

			if ( !lRet )
			{ RegSetValueEx( hKey, NULL, 0, REG_SZ, ( BYTE* )strmv.c_str(), strmv.length() + 1 ); }
		}
开发者ID:aleksijuvani,项目名称:bootil,代码行数:13,代码来源:Platform_WINDOWS.cpp

示例9: load

void SFMLImage::load(const BString& path)
{
    BImage::load(path);
    SFMLApplication* app = (SFMLApplication*)BApplication::instance();
    if (!_image.loadFromFile(app->context()->path + path))
    {
        Log::error("Cannot load image %s", path.c_str());
        return ;
    }
    _size.setWidth(_image.getSize().x);
    _size.setHeight(_image.getSize().y);
    glGenTextures(1, &_textureId); 
    glBindTexture(GL_TEXTURE_2D, _textureId); 
    /*glTexParameteri(GL_TEXTURE_2D, 
                    GL_TEXTURE_MAG_FILTER, 
                    GL_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D, 
                    GL_TEXTURE_MIN_FILTER, 
                    GL_LINEAR_MIPMAP_LINEAR);*/
    //GLfloat maxA;
    //glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxA);
    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,maxA);//Anisotropic Filtering Attempt
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _size.width(), _size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, _image.getPixelsPtr());
    _image = sf::Image();
}
开发者ID:pollastri-pierre,项目名称:BeanEngine,代码行数:30,代码来源:SFMLImage.cpp

示例10: createFilesystem

void AndroidApplication::createFilesystem()
{
    DIR *dp;
    struct dirent* entry;
    BString key;
    std::basic_string<char> s;
    s.resize(12, 'a');
    if((dp  = opendir(_storageDirectory.c_str())) == NULL)
        return ;

   // Log::info("Storage Directory = %s", _storageDirectory.c_str());
    while ((entry = readdir(dp)) != NULL)
    {
    	if (entry->d_type == DT_DIR && findEntryInDirMap(entry->d_name, &key))
    	{
    		_dirMap[key].setPath(_storageDirectory);
    	}
    }
    closedir(dp);

    DirMap::iterator it = _dirMap.begin();
    DirMap::iterator ite = _dirMap.end();

    for (; it != ite; ++it)
    {
    	if (!it->second.isValid())
    	{
    		BString path = _storageDirectory + "/" + it->second.dirName();
    		if (mkdir(path.c_str(), 0777))
    			it->second.setPath(_storageDirectory);
    	}
    }

}
开发者ID:pollastri-pierre,项目名称:BeanEngine,代码行数:34,代码来源:AndroidApplication.cpp

示例11: Msg

		//-----------------------------------------------------------------------------
		//  
		//-----------------------------------------------------------------------------
		BOOTIL_EXPORT void Msg( const char* str, ... )
		{
			BString strBuilt;
			Bootil_FormatString( strBuilt, str );

			printf( "%s", strBuilt.c_str() );
			Platform::DebuggerOutput( strBuilt );

			if ( Bootil::IsShuttingDown() )
				return;

			for ( Debug::IListener::List::iterator i = Debug::Listeners().begin(); i != Debug::Listeners().end(); i++ )
			{
				(*i)->Msg( strBuilt.c_str() );
			}
		}
开发者ID:ace13,项目名称:bootil,代码行数:19,代码来源:Debug.cpp

示例12: _rebuildIndexFromData

void Slice::_rebuildIndexFromData(BString &indexFileName)
{
	_indexFd.truncate(0);
	SliceIndexHeader sh;
	sh.version = SliceIndexHeader::CURRENT_VERSION;
	sh.sliceID = _sliceID;
	if (_indexFd.write(&sh, sizeof(sh)) != sizeof(sh)) {
		log::Fatal::L("Can't write slice indexFile header %s\n", indexFileName.c_str());
		throw SliceError("Can't write slice indexFile header");
	}
	if (_size <= sizeof(SliceDataHeader))
		return;
	
	log::Warning::L("Begin rebuild slice index file %s\n", indexFileName.c_str());

	Buffer buf(MAX_BUF_SIZE + sizeof(IndexEntry) * 2);
	_dataFd.seek(sizeof(SliceDataHeader), SEEK_SET);
	TSeek curSeek = sizeof(SliceDataHeader);
	while (curSeek < _size)	{
		IndexEntry &ie = *(IndexEntry*)buf.reserveBuffer(sizeof(IndexEntry));
		if (_dataFd.read(&ie.header, sizeof(ie.header)) != sizeof(ie.header)) {
			log::Fatal::L("Can't read an item header from slice dataFile while rebuilding %s\n", indexFileName.c_str());
			throw SliceError("Can't read an item header from slice dataFile");
		}

		auto resSeek = _dataFd.seek(ie.header.size, SEEK_CUR);
		if (resSeek <= 0) {
			log::Fatal::L("Can't seek slice dataFile while rebuilding %s\n", indexFileName.c_str());
			throw SliceError("Can't seek slice dataFile\n");
		}
		curSeek = resSeek;
		
		if (ie.header.status & ST_ITEM_DELETED) {
			buf.truncate(buf.writtenSize() - sizeof(IndexEntry));
		} else {
			ie.pointer.seek = curSeek;
			ie.pointer.sliceID = _sliceID;
		}
		if ((buf.writtenSize() >= MAX_BUF_SIZE) || (curSeek >= _size)) {
			if (_indexFd.write(buf.begin(), buf.writtenSize()) != (ssize_t)buf.writtenSize()) {
				log::Fatal::L("Can't write data to slice indexFile header %s\n", indexFileName.c_str());
				throw SliceError("Can't write data to slice indexFile header");
			}
			buf.clear();
		}
	}
}
开发者ID:AntonOrnatskyi,项目名称:metis,代码行数:47,代码来源:slice.cpp

示例13: IsFolder

		BOOTIL_EXPORT bool IsFolder( const BString& strFileName )
		{
			struct stat fileStat; 
			int err = stat( strFileName.c_str(), &fileStat ); 
			if ( err != 0 ) return false;

			return (fileStat.st_mode & S_IFMT) == S_IFDIR;
		}
开发者ID:ace13,项目名称:bootil,代码行数:8,代码来源:File.cpp

示例14: add

void Buffer::add(const BString &value)
{
	TSize size = value.size();
	_fit(sizeof(size) + size);
	memcpy(_writePos, &size, sizeof(size));
	_writePos += sizeof(size);
	memcpy(_writePos, value.c_str(), size);
	_writePos += size;	
}
开发者ID:FinalLevel,项目名称:libs,代码行数:9,代码来源:buffer.cpp

示例15: DoAssert

			BOOTIL_EXPORT void DoAssert( const char* strFile, unsigned int iLine, const char* strFunction, const char* strModule, const char* format, ... )
			{
				BString strBuilt;
				Bootil_FormatString( strBuilt, format );

				BString strError = String::Format::Print( "%s\n\nModule:\t%s\nFile:\t%s\nLine:\t%i\nFunction:\t%s\n", strBuilt.c_str(), strModule, strFile, iLine, strFunction );

				Output::Warning( "%s", strError.c_str() );
			}
开发者ID:ace13,项目名称:bootil,代码行数:9,代码来源:Debug.cpp


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