本文整理汇总了C++中AStackString::Trim方法的典型用法代码示例。如果您正苦于以下问题:C++ AStackString::Trim方法的具体用法?C++ AStackString::Trim怎么用?C++ AStackString::Trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStackString
的用法示例。
在下文中一共展示了AStackString::Trim方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trim
// Trim
//------------------------------------------------------------------------------
void TestAString::Trim() const
{
{
// No trim
AStackString<> empty;
empty.Trim( 0, 0 );
}
{
// Left trim
AStackString<> test( "zzHello" );
test.Trim( 2, 0 );
TEST_ASSERT( test.GetLength() == 5 );
TEST_ASSERT( test == "Hello" );
}
{
// Right trim
AStackString<> test( "Hellozz" );
test.Trim( 0, 2 );
TEST_ASSERT( test.GetLength() == 5 );
TEST_ASSERT( test == "Hello" );
}
{
// Trim left and right
AStackString<> test( "zzHellozz" );
test.Trim( 2, 2 );
TEST_ASSERT( test.GetLength() == 5 );
TEST_ASSERT( test == "Hello" );
}
}
示例2: 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 );
}
}
}
示例3: GetPrecompiledHeaderNode
// GetPrecompiledHeaderNode
//------------------------------------------------------------------------------
bool FunctionObjectList::GetPrecompiledHeaderNode( NodeGraph & nodeGraph,
const BFFIterator & iter,
CompilerNode * compilerNode,
const BFFVariable * compilerOptions,
const Dependencies & compilerForceUsing,
ObjectNode * & precompiledHeaderNode,
bool deoptimizeWritableFiles,
bool deoptimizeWritableFilesWithToken,
bool allowDistribution,
bool allowCaching,
const AString& compilerOutputExtension ) const
{
const BFFVariable * pchInputFile = nullptr;
const BFFVariable * pchOutputFile = nullptr;
const BFFVariable * pchOptions = nullptr;
if ( !GetString( iter, pchInputFile, ".PCHInputFile" ) ||
!GetString( iter, pchOutputFile, ".PCHOutputFile" ) ||
!GetString( iter, pchOptions, ".PCHOptions" ) )
{
return false;
}
precompiledHeaderNode = nullptr;
AStackString<> pchObjectName;
if ( pchInputFile )
{
if ( !pchOutputFile || !pchOptions )
{
Error::Error_1300_MissingPCHArgs( iter, this );
return false;
}
Node * pchInputNode = nodeGraph.FindNode( pchInputFile->GetString() );
if ( pchInputNode )
{
// is it a file?
if ( pchInputNode->IsAFile() == false )
{
Error::Error_1103_NotAFile( iter, this, "PCHInputFile", pchInputNode->GetName(), pchInputNode->GetType() );
return false;
}
}
else
{
// Create input node
pchInputNode = nodeGraph.CreateFileNode( pchInputFile->GetString() );
}
if ( nodeGraph.FindNode( pchOutputFile->GetString() ) )
{
Error::Error_1301_AlreadyDefinedPCH( iter, this, pchOutputFile->GetString().Get() );
return false;
}
uint32_t pchFlags = ObjectNode::DetermineFlags( compilerNode, pchOptions->GetString(), true, false );
if ( pchFlags & ObjectNode::FLAG_MSVC )
{
// sanity check arguments
bool foundYcInPCHOptions = false;
bool foundFpInPCHOptions = false;
// Find /Fo option to obtain pch object file name
Array< AString > pchTokens;
pchOptions->GetString().Tokenize( pchTokens );
for ( const AString & token : pchTokens )
{
if ( ObjectNode::IsStartOfCompilerArg_MSVC( token, "Fo" ) )
{
// Extract filename (and remove quotes if found)
pchObjectName = token.Get() + 3;
pchObjectName.Trim( pchObjectName.BeginsWith( '"' ) ? 1 : 0, pchObjectName.EndsWith( '"' ) ? 1 : 0 );
// Auto-generate name?
if ( pchObjectName == "%3" )
{
// example 'PrecompiledHeader.pch' to 'PrecompiledHeader.pch.obj'
pchObjectName = pchOutputFile->GetString();
pchObjectName += compilerOutputExtension;
}
}
else if ( ObjectNode::IsStartOfCompilerArg_MSVC( token, "Yc" ) )
{
foundYcInPCHOptions = true;
}
else if ( ObjectNode::IsStartOfCompilerArg_MSVC( token, "Fp" ) )
{
foundFpInPCHOptions = true;
}
}
// PCH must have "Create PCH" (e.g. /Yc"PrecompiledHeader.h")
if ( foundYcInPCHOptions == false )
{
Error::Error_1302_MissingPCHCompilerOption( iter, this, "Yc", "PCHOptions" );
return false;
}
//.........这里部分代码省略.........