本文整理汇总了C++中vsString::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ vsString::erase方法的具体用法?C++ vsString::erase怎么用?C++ vsString::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vsString
的用法示例。
在下文中一共展示了vsString::erase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractStringToken
static vsString ExtractStringToken( vsString &string )
{
vsAssert(string[0] == '\"', "Tried to extract a string that didn't start with \"!");
vsString result;
//result.append( 1, string[0] ); // get first '"'
string.erase(0,1);
bool escaped = false;
while( !string.empty() && string[0] ){
if ( escaped )
{
if ( string[0] == 'n' )
{
result.append( 1, '\n' );
}
else
{
result.append( 1, string[0] );
}
escaped = false;
}
else
{
if ( string[0] == '\"' )
{
break; // end of string!
}
else if ( string[0] == '\\' )
{
escaped = true;
}
else
{
result.append( 1, string[0] );
}
}
string.erase(0,1);
}
//result.append( 1, string[0] ); // get last '"'
string.erase(0,1);
return result;
}
示例2: RemoveLeadingWhitespace
static void RemoveLeadingWhitespace( vsString &string )
{
bool done = false;
while(!done)
{
done = true;
if ( !string.empty() && IsWhitespace(string[0]) )
{
string.erase(0,1);
done = false;
}
}
}
示例3: ExtractStringToken
static vsString ExtractStringToken( vsString &string )
{
vsString token;
size_t index = string.find(' ');
if ( index == vsString::npos )
{
token = string;
string = "";
}
else
{
token = string.substr(0, index);
string.erase(0,index+1);
// string = string.substr(index, vsString::npos);
}
return token;
}
示例4: ExtractWhitespaceStringToken
static vsString ExtractWhitespaceStringToken( vsString &string ) // pull out a string defined by whitespace
{
vsString label;
size_t len = string.length();
size_t index = 0;
for ( index = 0; index < len; index++ )
{
if ( IsWhitespace(string[index]) ) // this character isn't alphabetic, so isn't part of the label
{
index--; // back up one character
break; // exit the loop
}
}
label = string.substr(0, index+1);
string.erase(0,index+1);
return label;
}
示例5: ExtractNumberToken
static vsString ExtractNumberToken( vsString &string )
{
vsAssert(IsNumeric(string[0]), "Tried to extract a number from something that isn't a number!");
// okay. We need to find
vsString numberString;
size_t len = string.length();
size_t index = 0;
for ( index = 0; index < len; index++ )
{
if ( !IsNumeric(string[index]) ) // this character isn't alphabetic, so isn't part of the label
{
index--; // back up one character
break; // exit the loop
}
}
numberString = string.substr(0, index+1);
string.erase(0,index+1);
return numberString;
}
示例6: if
bool
vsToken::ExtractFrom( vsString &string )
{
m_type = Type_None;
RemoveLeadingWhitespace(string);
if ( !string.empty() )
{
if ( string[0] == '\"' )
{
m_string = ExtractStringToken(string);
m_type = Type_String;
return true;
}
else if ( string[0] == '{' )
{
m_type = Type_OpenBrace;
string.erase(0,1);
return true;
}
else if ( string[0] == '}' )
{
m_type = Type_CloseBrace;
string.erase(0,1);
return true;
}
else if ( string[0] == '\n' )
{
m_type = Type_NewLine;
string.erase(0,1);
return true;
}
else if ( ::IsAlpha(string[0]) )
{
m_string = ExtractLabelToken(string);
m_type = Type_Label;
return true;
}
else if ( ::IsNumeric( string[0]) )
{
vsString token = ExtractNumberToken(string);
if ( token == "-" ) // Ugly: handle negative nans as zeroes.
{
m_int = 0;
m_type = Type_Integer;
return false;
}
bool isAFloat = ( token.find('.') != token.npos );
if ( isAFloat )
{
bool success = (sscanf( token.c_str(), "%f", &m_float )!=0);
vsAssert(success, "Couldn't find a floating value where we expected one?");
m_type = Type_Float;
return true;
}
else
{
bool success = sscanf( token.c_str(), "%d", &m_int) != 0;
vsAssert(success, "Couldn't find an integer value?" );
m_type = Type_Integer;
return true;
}
}
else if ( string[0] == '#' )
{
// comment!
string = vsEmptyString;
}
else if ( string[0] == '=' )
{
m_type = Type_Equals;
string.erase(0,1);
return true;
}
else
{
// no clue what it was! Just treat it as a string, breaking at the next whitespace
m_string = ExtractWhitespaceStringToken(string);
m_type = Type_String;
return true;
}
}
return false;
}