本文整理汇总了C++中AStackString::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ AStackString::Replace方法的具体用法?C++ AStackString::Replace怎么用?C++ AStackString::Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStackString
的用法示例。
在下文中一共展示了AStackString::Replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// ExtractIntellisenseOptions
//------------------------------------------------------------------------------
/*static*/ void ProjectGeneratorBase::ExtractIntellisenseOptions( const AString & compilerArgs,
const char * option,
const char * alternateOption,
Array< AString > & outOptions,
bool escapeQuotes )
{
ASSERT( option );
Array< AString > tokens;
compilerArgs.Tokenize( tokens );
const size_t optionLen = AString::StrLen( option );
const size_t alternateOptionLen = alternateOption ? AString::StrLen( alternateOption ) : 0;
for ( size_t i=0; i<tokens.GetSize(); ++i )
{
AString & token = tokens[ i ];
// strip quotes around token, e.g: "-IFolder/Folder"
if ( token.BeginsWith( '"' ) && token.EndsWith( '"' ) )
{
token.Assign( token.Get() + 1, token.GetEnd() - 1 );
}
AStackString<> optionBody;
// Handle space between option and payload
if ( ( token == option ) || ( token == alternateOption ) )
{
// Handle an incomplete token at the end of list
if ( i == ( tokens.GetSize() - 1 ) )
{
break;
}
// Use next token
optionBody = tokens[ i + 1 ];
}
else if ( token.BeginsWith( option ) )
{
// use everything after token
optionBody.Assign( token.Get() + optionLen );
}
else if ( alternateOption && token.BeginsWith( alternateOption ) )
{
// use everything after token
optionBody.Assign( token.Get() + alternateOptionLen );
}
// Strip quotes around body (e.g. -I"Folder/Folder")
if ( optionBody.BeginsWith( '"' ) && optionBody.EndsWith( '"' ) )
{
optionBody.Trim( 1, 1 );
}
// Did we find something?
if ( optionBody.IsEmpty() == false )
{
if ( escapeQuotes )
{
optionBody.Replace( "\"", "\\\"" );
}
outOptions.Append( optionBody );
}
}
}
示例2: ReadObject
// ReadObject
//------------------------------------------------------------------------------
bool TextReader::ReadObject()
{
// Type
AStackString<> type;
if ( !GetToken( type ) )
{
Error( "Missing type token" );
return false;
}
// ID
AStackString<> id;
if ( !GetToken( id ) )
{
Error( "Missing id token" );
return false;
}
// Name
AStackString<> name;
if ( !GetToken( name ) )
{
Error( "Missing name" );
return false;
}
// Create Object
RefObject * refObj = ReflectionInfo::CreateObject( type );
Object * obj = DynamicCast< Object >( refObj );
ASSERT( obj ); // TODO: handle this gracefully (skip)
if ( obj == nullptr )
{
Error( "Failed to create object" );
return false;
}
m_ObjectsToInit.Append( obj );
// set name
name.Replace( "\"", "" ); // strip quotes
obj->SetName( name );
// add to parent if not root
if ( m_DeserializationStack.IsEmpty() == false )
{
// get parent container
RefObject * topRefObject = (RefObject *)( m_DeserializationStack.Top().m_Base );
Container * parentContainer = DynamicCast< Container >( topRefObject );
ASSERT( parentContainer ); // parent is not a container - impossible!
// sanity check child
Object * child = DynamicCast< Object >( obj );
ASSERT( child ); // child is not an Object - impossible!
// add to parent
parentContainer->AddChild( child );
}
// Push onto stack
StackFrame sf;
sf.m_Base = obj;
sf.m_Reflection = obj->GetReflectionInfoV();
sf.m_ArrayProperty = nullptr;
#ifdef DEBUG
sf.m_RefObject = obj;
sf.m_Struct = nullptr;
#endif
m_DeserializationStack.Append( sf );
if ( m_RootObject == nullptr )
{
m_RootObject = obj;
}
return true;
}