本文整理汇总了C++中CGUIString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIString::c_str方法的具体用法?C++ CGUIString::c_str怎么用?C++ CGUIString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIString
的用法示例。
在下文中一共展示了CGUIString::c_str方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strtol
int32 StringToValue<int16>( const CGUIString& rString, int16& rValue)
{
long value = strtol(rString.c_str(), 0, 10);
if( value > (long)(std::numeric_limits<int16>::max()))
{
GUI_THROW( GUI_FORMAT(
"[StringToValue[int16]]: Value <%s> exceeds range of destination type",
rString.c_str()));
return -1;
}
rValue = static_cast<int16>(value);
return 0;
}
示例2: strtoul
int32 StringToValue<uint8>( const CGUIString& rString, uint8& rValue)
{
unsigned long value = strtoul(rString.c_str(), 0, 10);
if( value > std::numeric_limits<uint8>::max() )
{
GUI_THROW( GUI_FORMAT(
"[StringToValue[uint8]]: Value <%s> exceeds range of destination type",
rString.c_str()));
return -1;
}
rValue = static_cast<uint8>(value);
return 0;
}
示例3: if
int32 StringToValue<EImageOrientation>( const CGUIString& rString, EImageOrientation& rValue)
{
if( rString == "eImageOrientation_Normal" )
{
rValue = eImageOrientation_Normal;
}
else if( rString == "eImageOrientation_90CW" )
{
rValue = eImageOrientation_90CW;
}
else if( rString == "eImageOrientation_90CCW" )
{
rValue = eImageOrientation_90CCW;
}
else if( rString == "eImageOrientation_FlipHorizon" )
{
rValue = eImageOrientation_FlipHorizon;
}
else if( rString == "eImageOrientation_FlipVertical" )
{
rValue = eImageOrientation_FlipVertical;
}
else
{
GUI_THROW( GUI_FORMAT(
"[StringToValue[EImageOrientation]]: string value format is wrong! <%s>",
rString.c_str()));
return -1;
}
return 0;
}
示例4:
//------------------------------------------------------------------------------
void CGUIWgtParticle2D::SetParticle2D( const CGUIString& rParticle2DName )
{
GUI_TRACE( GUI_FORMAT( "[CGUIWgtParticle2D::SetParticle2D]: play particle %s", rParticle2DName.c_str()));
if( rParticle2DName.empty() )
{
//clear
SetParticle2D( NULL );
}
else
{
CGUIParticle2DSystem* pParticle2D = CGUIParticle2DManager::Instance()->AllocateResource( rParticle2DName );
SetParticle2D( pParticle2D );
pParticle2D->RefRelease();
}
}
示例5: StringToVector
int32 StringToValue<CGUIVector2>( const CGUIString& rString, CGUIVector2& rValue)
{
//string should have format as "x,y"
std::vector<CGUIString> aListString= StringToVector(rString);
if( aListString.size() != 2 )
{
GUI_THROW( GUI_FORMAT(
"[StringToValue[StringToValue]]: string value format is wrong! <%s>",
rString.c_str()));
return -1;
}
StringToValue(aListString[0], rValue.x);
StringToValue(aListString[1], rValue.y);
return 0;
}
示例6: ParseTMXFile
//------------------------------------------------------------------------------
int32 CGUITiledMap::ParseTMXFile( const CGUIString& rFileName )
{
Reset();
m_pMapInfo = new CGUITiledMapInfo;
if( 0 != m_pMapInfo->InitWithTMXFile( rFileName ) )
{
GUI_THROW( GUI_FORMAT("[CGUITiledMap::ParseTMXFile]: failed parse tmx file %s", rFileName.c_str() ));
return -1;
}
for( uint32 i=0; i<m_pMapInfo->GetLayerInfos().size(); ++i )
{
CGUITiledMapLayer* pLayer = new CGUITiledMapLayer( this, i );
m_arrayLayer.push_back( pLayer );
}
return 0;
}
示例7: BuildShader
//------------------------------------------------------------------------------
uint32 CGUIShader_opengl_base::BuildShader(const CGUIString& rSource, uint32 shaderType)
{
#if defined(GUIEX_RENDER_OPENGL) || defined(GUIEX_RENDER_OPENGL_ES2)
///read file
IGUIInterfaceFileSys* pFileSys = CGUIInterfaceManager::Instance()->GetInterfaceFileSys();
CGUIDataChunk aShaderDataChunk;
if( 0 != pFileSys->ReadFile( rSource, aShaderDataChunk, IGUIInterfaceFileSys::eOpenMode_String ))
{
//failed
GUI_THROW( GUI_FORMAT("[CGUIShader_opengl_base::BuildShader]: failed to read file <%s>!", rSource.c_str()));
return -1;
}
GLuint shaderHandle = glCreateShader(shaderType);
const char* data = (const char*)aShaderDataChunk.GetDataPtr();
glShaderSource(shaderHandle, 1, &data, 0);
glCompileShader(shaderHandle);
GLint compileSuccess;
glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess);
if (compileSuccess == GL_FALSE)
{
char messages[256];
glGetShaderInfoLog(shaderHandle, sizeof(messages), 0, &messages[0]);
GUI_THROW( GUI_FORMAT( "[CGUIShader_opengl_base::BuildShader]: %s", messages ));
return 0;
}
return shaderHandle;
#else ////#if defined(GUIEX_RENDER_OPENGL) || defined(GUIEX_RENDER_OPENGL_ES2)
return 0;
#endif //#if defined(GUIEX_RENDER_OPENGL) || defined(GUIEX_RENDER_OPENGL_ES2)
}
示例8: UpdateGridProperty
//------------------------------------------------------------------------------
void UpdateGridProperty( wxPropertyGridManager* pSheetMgr, CGUIWidget* pWidget, const CGUIString& rPropertyName, const CGUIString& rPropertyType )
{
const CGUIProperty& rSet = CPropertyConfigMgr::Instance()->GetPropertySet(pWidget->GetType());
const CGUIProperty* pDefaultProp = rSet.GetProperty(rPropertyName, rPropertyType);
if( !pDefaultProp )
{
throw CGUIException( "[UpdateGridProperty]: failed to get default property by name <%s>", rPropertyName.c_str() );
}
pWidget->DumpToProperty();
const CGUIProperty* pProp = pWidget->GetProperty().GetProperty(rPropertyName, rPropertyType);
if( !pProp )
{
throw CGUIException( "[UpdateGridProperty]: failed to get property by name <%s> from widget <%s>", rPropertyName.c_str(), pWidget->GetName().c_str() );
}
CGUIProperty aProp = *pProp;
aProp.SetData( pDefaultProp->GetData() );
CPropertyConvertorMgr::Instance()->GuiProperty2GridProperty( pSheetMgr, NULL, aProp );
}
示例9: CGUIException
//------------------------------------------------------------------------------
int IGUIStringConv_iconv::Utf8ToWChar( const CGUIString& rSrc, CGUIStringW& rDst )
{
if( rSrc.empty())
{
rDst.clear();
return 0;
}
//open iconv
iconv_t cd = iconv_open ("UTF-16LE", "UTF-8");
if( cd == (iconv_t)-1 )
{
throw CGUIException(
"[MultiByteToWideChar]: failed to open iconv, errno is %d",
errno);
return -1;
}
//convert
size_t buf_size = rSrc.size()+1;
size_t inbytesleft = rSrc.size();
size_t outbytesleft = buf_size;
char* dst = (char*)(new wchar[buf_size]);
char* pOutBuf = NULL;
char* pInBuf = (char*)(rSrc.c_str());
bool bError = false;
while(inbytesleft > 0)
{
pOutBuf = dst;
outbytesleft = buf_size*sizeof(wchar);
size_t retbytes = iconv(cd, &pInBuf, &inbytesleft, &pOutBuf, &outbytesleft);
if (dst != pOutBuf)
{
// wchar is 4byte in mac, but iconv return a "utf-16" buff which is 2byte per code
if (sizeof(wchar) == 4)
{
for (int iChar = 0; iChar < (pOutBuf-dst)/2; iChar++)
{
unsigned short* pU16Char = (unsigned short*)&dst[2*iChar];
rDst.push_back((wchar)*pU16Char);
}
}
else if (sizeof(wchar) == 2)
{
rDst.append((wchar*)dst, (pOutBuf-dst)/sizeof(wchar));
}
}
//check ret
if( retbytes == size_t(-1) )
{
if( errno == E2BIG )
{
continue;
}
else
{
bError = true;
break;
}
}
else
{
//success
break;
}
}
delete[] dst;
if( bError)
{
switch(errno)
{
case EILSEQ:
throw CGUIException(
"[MultiByteToWideChar]: failed to iconv, errno is EILSEQ");
return -1;
case EINVAL:
throw CGUIException(
"[MultiByteToWideChar]: failed to iconv, errno is EINVAL");
return -1;
default:
throw CGUIException(
"[MultiByteToWideChar]: failed to iconv, errno is %d",
errno);
return -1;
}
}
//close iconv
int ret = iconv_close(cd);
if( ret == -1 )
{
throw CGUIException(
"[MultiByteToWideChar]: failed to close iconv, errno is %d",
//.........这里部分代码省略.........
示例10: LoadOggFile
//------------------------------------------------------------------------------
bool CGUIMusicData_openal::LoadOggFile( const CGUIString& rFilename ) const
{
//open file
FILE *pFile = fopen( rFilename.c_str(), "rb" );
if( !pFile)
{
return false;
}
ov_callbacks sCallbacks;
sCallbacks.read_func = ov_read_func;
sCallbacks.seek_func = ov_seek_func;
sCallbacks.close_func = ov_close_func;
sCallbacks.tell_func = ov_tell_func;
if (ov_open_callbacks(pFile, &m_aVorbisFile, NULL, 0, sCallbacks) != 0)
{
fclose( pFile );
return false;
}
// Get some information about the file (Channels, Format, and Frequency)
if( false == GetOggVorbisInfo( &m_aVorbisFile, &m_nFrequency, &m_nFormat, &m_nFormat, &m_nBufferSize ) )
{
ov_clear(&m_aVorbisFile);
return false;
}
// Allocate a buffer to be used to store decoded data for all Buffers
m_pDecodeBuffer = (char*)malloc(m_nBufferSize);
if ( !m_pDecodeBuffer )
{
ov_clear(&m_aVorbisFile);
return false;
}
// Generate a Source to playback the Buffers
alGenSources(1, &m_nSourceId);
if (alGetError() != AL_NO_ERROR)
{
return false;
}
// Generate some AL Buffers for streaming
alGenBuffers( GUI_MUSIC_NUMBUFFERS, m_nBuffers );
if (alGetError() != AL_NO_ERROR)
{
return false;
}
// Fill all the Buffers with decoded audio data from the OggVorbis file
for (int iLoop = 0; iLoop < GUI_MUSIC_NUMBUFFERS; iLoop++)
{
unsigned long ulBytesWritten = DecodeOggVorbis(&m_aVorbisFile, m_pDecodeBuffer, m_nBufferSize, m_nChannels);
if (ulBytesWritten)
{
alBufferData(m_nBuffers[iLoop], m_nFormat, m_pDecodeBuffer, ulBytesWritten, m_nFrequency);
alSourceQueueBuffers(m_nSourceId, 1, &m_nBuffers[iLoop]);
}
}
return true;
}
示例11: DoLoad
//------------------------------------------------------------------------------
int32 CGUIMusicData_openal::DoLoad()
{
// identify file type by extension
CGUIString strExt;
size_t pos = m_strPath.find_last_of(".");
if( pos != CGUIString::npos )
{
strExt = m_strPath.substr(pos);
}
for ( uint32 i=0; i<strExt.size(); ++i)
{
strExt[i] = tolower(strExt[i]);
}
CGUIString strScenePath = CGUISceneManager::Instance()->GetScenePath( m_strSceneName ) + m_strPath;
CGUIString strFullPath;
GSystem->GenerateFullPath( strScenePath, strFullPath );
if (strExt == ".ogg")
{
//load ogg file
if( LoadOggFile( strFullPath ) != true)
{
GUI_THROW( GUI_FORMAT("[CGUISoundData_openal::DoLoad]: failed to load ogg file <%s>!", m_strPath.c_str()));
return -1;
}
}
else
{
GUI_THROW( GUI_FORMAT("[CGUISoundData_openal::DoLoad]: doesn't support the sound type <%s>!", strExt.c_str()));
return -1;
}
//assign the buffer to this source
//alSourcei( m_nSourceId, AL_BUFFER, m_nBufferId);
//set source position
alSource3f( m_nSourceId,AL_POSITION, 0, 0, 0);
//set source velocity
alSource3f( m_nSourceId,AL_VELOCITY, 0, 0, 0);
return 0;
}
示例12:
int32 StringToValue<real>( const CGUIString& rString, real& rValue)
{
rValue = static_cast<real>(strtod(rString.c_str(), 0));
return 0;
}
示例13: LoadResourceConfigFile
/**
* @brief read config file and load data
*/
int32 CGUIConfigFileLoader::LoadResourceConfigFile( const CGUIString& rPath, const CGUIString& rSceneName)
{
//get interface of config file
IGUIInterfaceConfigFile* pConfigFile = CGUIInterfaceManager::Instance()->GetInterfaceConfigFile();
if( !pConfigFile )
{
GUI_THROW( "[LoadResourceConfigFile]: failed to get interface <IGUIConfigFile>!");
}
//get property set
CGUIProperty aPropertySet;
if( 0 != pConfigFile->LoadConfigFile(rPath, aPropertySet) )
{
GUI_THROW( GUI_FORMAT(
"[LoadResourceConfigFile]: failed to load config file <%s : %s>!",
rSceneName.c_str(),
rPath.c_str()));
}
//parse it
uint32 nSize = aPropertySet.GetPropertyCount();
for( uint32 i=0; i<nSize; ++i )
{
const CGUIProperty* pProperty = aPropertySet.GetProperty(i);
CGUIResourceManagerBase* pResourceManager = NULL;
switch( pProperty->GetType() )
{
case ePropertyType_Set:
if( 0 != DoLoadConfig_Set( pProperty, rSceneName ))
{
return -1;
}
break;
case ePropertyType_ImageDefine:
pResourceManager = CGUIImageManager::Instance();
break;
case ePropertyType_AnimationDefine:
pResourceManager = CGUIAnimationManager::Instance();
break;
case ePropertyType_FontDefine:
pResourceManager = CGUIFontManager::Instance();
break;
case ePropertyType_SoundDefine:
pResourceManager = CGUISoundManager::Instance();
break;
case ePropertyType_MusicDefine:
pResourceManager = CGUIMusicManager::Instance();
break;
case ePropertyType_AsDefine:
pResourceManager = CGUIAsManager::Instance();
break;
case ePropertyType_ShaderDefine:
pResourceManager = CGUIShaderManager::Instance();
break;
case ePropertyType_Particle2DDefine:
pResourceManager = CGUIParticle2DManager::Instance();
break;
case ePropertyType_TiledMapDefine:
pResourceManager = CGUITiledMapManager::Instance();
break;
default:
{
GUI_THROW( GUI_FORMAT(
"[LoadResourceConfigFile], unknown property type <%s:%s:%s>",
pProperty->GetName().c_str(),
pProperty->GetTypeAsString().c_str(),
pProperty->GetValue().c_str()));
}
return -1;
}
if( pResourceManager )
{
if( 0 != pResourceManager->RegisterResource( rSceneName, *pProperty ) )
{
GUI_THROW( GUI_FORMAT(
"[CGUIConfigFileLoader::LoadResourceConfigFile], failed to register resource with name <%s:%s:%s>!",
pProperty->GetName().c_str(),
pProperty->GetTypeAsString().c_str(),
pProperty->GetValue().c_str()));
return -1;
}
}
}
return 0;
}