本文整理汇总了C++中LString::find方法的典型用法代码示例。如果您正苦于以下问题:C++ LString::find方法的具体用法?C++ LString::find怎么用?C++ LString::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LString
的用法示例。
在下文中一共展示了LString::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayMessage
void clConsole::DisplayMessage( const LString& Message, const LConsoleMessageType MSGType ) const
{
if ( Env )
{
Env->SendSync( L_EVENT_CONSOLELOG, LEventArgs( &Message ), false );
}
FTimeVisible = MESSAGE_VISIBILITY_TIME;
LVector4 Color;
switch ( MSGType )
{
case CMSG_ENGINEMESSAGE:
Color = LC_LinderdaumConsoleEM;
break;
case CMSG_ERRORMESSAGE:
Color = LC_LinderdaumConsoleERR;
break;
case CMSG_INFOTIP:
Color = LC_LinderdaumConsoleIT;
break;
default:
FATAL_MSG( "Unknown message type" );
}
LString Msg = Message;
LMutex Lock( &FMessagesHistoryMutex );
while ( true )
{
size_t Separation = Msg.find( "\n" );
if ( Separation == LString::npos )
{
break;
}
LString NewMsg = Msg.substr( 0, Separation );
FMessagesHistory.push_back( sConsoleMessage( NewMsg, Color ) );
if ( FMessagesHistory.size() > MAX_HISTORY_SIZE )
{
FMessagesHistory.pop_front();
}
Msg = Msg.substr( Separation + 1, Message.length() - 1 );
}
FMessagesHistory.push_back( sConsoleMessage( Msg, Color ) );
}
示例2: parse
//------------------------------------------------------------------------------
int LArguments::parse(int argc, char* argv[]) {
LString opt;
int find;
int ret;
for(int num = 1; num < argc; num++) {
opt = LString(argv[num]);
if(opt.find("--") == 0) {
if((find = opt.find("=")) != (int)string::npos) {
if((ret = parseInternalOptionWithParamater(opt.substr(0, find), opt.substr(find + 1))) != L_OK) {
return ret;
}
}
else {
if((ret = parseInternalOption(opt)) != L_OK) {
return ret;
}
}
}
else if(opt.find("-") == 0) {
if((find = opt.find("=")) != (int)string::npos) {
if((ret = parseInternalOptionWithParamater(opt.substr(0, find), opt.substr(find + 1))) != L_OK) {
return ret;
}
}
else {
if((ret = parseInternalOption(opt)) != L_OK) {
return ret;
}
}
}
else {
if((ret = parseInternalArgument(opt)) != L_OK) {
return ret;
}
}
}
return L_OK;
}
示例3: SetLocale
void clLocalizer::SetLocale( const LString& LocaleName )
{
guard( "%s", LocaleName.c_str() );
ClearLocalization();
FLocaleName = LocaleName;
const LString FileName( FLocalePath + "/Localizer-" + LocaleName + ".txt" );
if ( Env->FileSystem->FileExists( FileName ) )
{
Env->Logger->LogP( L_NOTICE, "Reading locale from %s", FileName.c_str() );
iIStream* Stream = Env->FileSystem->CreateFileReader( FileName );
while ( !Stream->Eof() )
{
LString Line = Stream->ReadLine();
size_t SepPos = Line.find( "~" );
FATAL( SepPos == Line.npos, "Invalid locale translation file format: missing ~" );
LString Text( Line.substr( 0, SepPos ) );
LString Translation( Line.substr( SepPos + 1, Line.length() - SepPos - 1 ) );
FTranslations[ Text ] = Translation;
}
delete( Stream );
}
else
{
Env->Logger->LogP( L_NOTICE, "Locale %s not found", FileName.c_str() );
}
this->SendAsync( L_EVENT_LOCALE_CHANGED, LEventArgs(), false );
unguard();
}
示例4: SendCommand
void clConsole::SendCommand( const LString& CMDName )
{
guard( "%s", CMDName.c_str() );
FSendCommandResult.assign( "" );
if ( CMDName.size() == 0 )
{
return;
}
bool IsScript = ( LStr::GetUpper( LStr::GetToken( CMDName, 1 ) ) == "RS" );
// split command
size_t CommandsSeparator = FindCommandsSeparator( CMDName );
LString ThisCMDString = CMDName;
LString RestCMDString( "" );
if ( !IsScript )
{
if ( CommandsSeparator )
{
ThisCMDString = CMDName.substr( 0, CommandsSeparator );
RestCMDString = CMDName.substr( CommandsSeparator,
CMDName.length() - CommandsSeparator );
if ( RestCMDString.length() > 0 )
{
LStr::pop_front( &RestCMDString );
}
}
}
// extract command name and parameters
LString ThisCMDName = LStr::GetToken( ThisCMDString, 1 );
LString ThisCMDParam = ThisCMDString.substr( ThisCMDName.length(),
ThisCMDString.length() - ThisCMDName.length() );
if ( ThisCMDParam.length() > 0 )
{
LStr::pop_front( &ThisCMDParam );
}
LStr::ToUpper( &ThisCMDName );
if ( IsScript )
{
// execute script and return
ExecuteStatement( ThisCMDParam );
return;
}
if ( ThisCMDName.find( "WAIT" ) == 0 )
{
// Leave the rest of the command until the next frame
if ( CommandsSeparator )
{
QueryCommand( RestCMDString );
}
return;
}
else
{
clCommandsList::const_iterator i = FCommandsList.find( ThisCMDName );
if ( i != FCommandsList.end() )
{
( i->second ).Exec( clFileSystem::ReplaceEnvVars( ThisCMDParam ) );
}
else
{
clAliasesList::const_iterator j = FAliasesList.find( ThisCMDName );
if ( j != FAliasesList.end() )
{
QueryCommand( j->second );
}
else
{
DisplayError( "Unknown command: " + ThisCMDName );
}
}
}
if ( CommandsSeparator )
{
SendCommand( RestCMDString );
}
unguard();
}