本文整理汇总了C++中SkipWhiteSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ SkipWhiteSpace函数的具体用法?C++ SkipWhiteSpace怎么用?C++ SkipWhiteSpace使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkipWhiteSpace函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkipWhiteSpace
const wchar_t* TiXmlAttribute::Parse( const wchar_t* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p ) return 0;
// int tabsize = 4;
// if ( document )
// tabsize = document->TabSize();
if ( data )
{
data->Stamp( p, encoding );
location = data->Cursor();
}
// Read the name, the '=' and the fvalue.
const wchar_t* pErr = p;
p = ReadName( p, &name, encoding );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
return 0;
}
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p || *p != '=' )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
return 0;
}
++p; // skip '='
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
return 0;
}
const wchar_t* end;
const wchar_t SINGLE_QUOTE = '\'';
const wchar_t DOUBLE_QUOTE = '\"';
if ( *p == SINGLE_QUOTE )
{
++p;
end = L"\'"; // single quote in string
p = ReadText( p, &fvalue, false, end, false, encoding );
}
else if ( *p == DOUBLE_QUOTE )
{
++p;
end = L"\""; // double quote in string
p = ReadText( p, &fvalue, false, end, false, encoding );
}
else
{
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
fvalue = L"";
while ( p && *p // existence
&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
&& *p != '/' && *p != '>' ) // tag end
{
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
// We did not have an opening quote but seem to have a
// closing one. Give up and throw an error.
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
return 0;
}
fvalue += *p;
++p;
}
}
return p;
}
示例2: SkipWhiteSpace
TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace( p, encoding );
if( !p || !*p || *p != '<' )
{
return 0;
}
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
return 0;
}
// What is this thing?
// - Elements start with a letter or underscore, but xml is reserved.
// - Comments: <!--
// - Decleration: <?xml
// - Everthing else is unknown to tinyxml.
//
const char* xmlHeader = { "<?xml" };
const char* commentHeader = { "<!--" };
const char* dtdHeader = { "<!" };
const char* cdataHeader = { "<![CDATA[" };
if ( StringEqual( p, xmlHeader, true, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Declaration\n" );
#endif
returnNode = new TiXmlDeclaration();
}
else if ( StringEqual( p, commentHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Comment\n" );
#endif
returnNode = new TiXmlComment();
}
else if ( StringEqual( p, cdataHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing CDATA\n" );
#endif
TiXmlText* text = new TiXmlText( "" );
text->SetCDATA( true );
returnNode = text;
}
else if ( StringEqual( p, dtdHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(1)\n" );
#endif
returnNode = new TiXmlUnknown();
}
else if ( IsAlpha( *(p+1), encoding )
|| *(p+1) == '_' )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Element\n" );
#endif
returnNode = new TiXmlElement( "" );
}
else
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(2)\n" );
#endif
returnNode = new TiXmlUnknown();
}
if ( returnNode )
{
// Set the parent, so it can report errors
returnNode->parent = this;
}
return returnNode;
}
示例3: GetDocument
const wchar_t* TiXmlElement::ReadValue( const wchar_t* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
TiXmlDocument* document = GetDocument();
// Read in text and elements in any order.
const wchar_t* pWithWhiteSpace = p;
p = SkipWhiteSpace( p, encoding );
while ( p && *p )
{
if ( *p != '<' )
{
// Take what we have, make a text element.
TiXmlText* textNode = new TiXmlText( L"" );
if ( !textNode )
{
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
return 0;
}
if ( TiXmlBase::IsWhiteSpaceCondensed() )
{
p = textNode->Parse( p, data, encoding );
}
else
{
// Special case: we want to keep the white space
// so that leading spaces aren't removed.
p = textNode->Parse( pWithWhiteSpace, data, encoding );
}
if ( !textNode->Blank() )
LinkEndChild( textNode );
else
delete textNode;
}
else
{
// We hit a '<'
// Have we hit a new element or an end tag? This could also be
// a TiXmlText in the L"CDATA" style.
if ( StringEqual( p, L"</", false, encoding ) )
{
return p;
}
else
{
TiXmlNode* node = Identify( p, encoding );
if ( node )
{
p = node->Parse( p, data, encoding );
LinkEndChild( node );
}
else
{
return 0;
}
}
}
pWithWhiteSpace = p;
//p = SkipWhiteSpace( p, encoding );
}
if ( !p )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
}
return p;
}
示例4: while
const char* TiXmlBase::ReadText( const char* p,
TIXML_STRING * text,
bool trimWhiteSpace,
const char* endTag,
bool caseInsensitive,
TiXmlEncoding encoding )
{
*text = "";
if ( !trimWhiteSpace // certain tags always keep whitespace
|| !condenseWhiteSpace ) // if true, whitespace is always kept
{
// Keep all the white space.
while ( p && *p
&& !StringEqual( p, endTag, caseInsensitive, encoding )
)
{
int len;
char cArr[4] = { 0, 0, 0, 0 };
p = GetChar( p, cArr, &len, encoding );
text->append( cArr, len );
}
}
else
{
bool whitespace = false;
// Remove leading white space:
p = SkipWhiteSpace( p, encoding );
while ( p && *p
&& !StringEqual( p, endTag, caseInsensitive, encoding ) )
{
if ( *p == '\r' || *p == '\n' )
{
whitespace = true;
++p;
}
else if ( IsWhiteSpace( *p ) )
{
whitespace = true;
++p;
}
else
{
// If we've found whitespace, add it before the
// new character. Any whitespace just becomes a space.
if ( whitespace )
{
(*text) += ' ';
whitespace = false;
}
int len;
char cArr[4] = { 0, 0, 0, 0 };
p = GetChar( p, cArr, &len, encoding );
if ( len == 1 )
(*text) += cArr[0]; // more efficient
else
text->append( cArr, len );
}
}
}
if ( p && *p )
p += strlen( endTag );
return ( p && *p ) ? p : 0;
}
示例5: ClearError
const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
{
ClearError();
// Parse away, at the document level. Since a document
// contains nothing but other tags, most of what happens
// here is skipping white space.
if ( !p || !*p )
{
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}
// Note that, for a document, this needs to come
// before the while space skip, so that parsing
// starts from the pointer we are given.
location.Clear();
if ( prevData )
{
location.row = prevData->cursor.row;
location.col = prevData->cursor.col;
}
else
{
location.row = 0;
location.col = 0;
}
TiXmlParsingData data( p, TabSize(), location.row, location.col );
location = data.Cursor();
if ( encoding == TIXML_ENCODING_UNKNOWN )
{
// Check for the Microsoft UTF-8 lead bytes.
const unsigned char* pU = (const unsigned char*)p;
if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
&& *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
&& *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
{
encoding = TIXML_ENCODING_UTF8;
useMicrosoftBOM = true;
}
}
p = SkipWhiteSpace( p, encoding );
if ( !p )
{
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}
while ( p && *p )
{
TiXmlNode* node = Identify( p, encoding );
if ( node )
{
p = node->Parse( p, &data, encoding );
LinkEndChild( node );
}
else
{
break;
}
// Did we get encoding info?
if ( encoding == TIXML_ENCODING_UNKNOWN
&& node->ToDeclaration() )
{
TiXmlDeclaration* dec = node->ToDeclaration();
const char* enc = dec->Encoding();
assert( enc );
if ( *enc == 0 )
encoding = TIXML_ENCODING_UTF8;
else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
encoding = TIXML_ENCODING_UTF8;
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
else
encoding = TIXML_ENCODING_LEGACY;
}
p = SkipWhiteSpace( p, encoding );
}
// Was this empty?
if ( !firstChild ) {
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
return 0;
}
// All is well.
return p;
}
示例6: Sym_Init
/*
==================
Sym_Init
==================
*/
void Sym_Init(long addr)
{
TCHAR moduleName[MAX_STRING_CHARS];
MEMORY_BASIC_INFORMATION mbi;
VirtualQuery((void *)addr, &mbi, sizeof(mbi));
GetModuleFileName((HMODULE)mbi.AllocationBase, moduleName, sizeof(moduleName));
char *ext = moduleName + strlen(moduleName);
while (ext > moduleName && *ext != '.') {
ext--;
}
if (ext == moduleName) {
strcat(moduleName, ".map");
} else {
strcpy(ext, ".map");
}
module_t *module = (module_t *) malloc(sizeof(module_t));
module->name = (char *) malloc(strlen(moduleName) + 1);
strcpy(module->name, moduleName);
module->address = (int)mbi.AllocationBase;
module->symbols = NULL;
module->next = modules;
modules = module;
FILE *fp = fopen(moduleName, "rb");
if (fp == NULL) {
return;
}
int pos = ftell(fp);
fseek(fp, 0, SEEK_END);
int length = ftell(fp);
fseek(fp, pos, SEEK_SET);
char *text = (char *) malloc(length+1);
fread(text, 1, length, fp);
text[length] = '\0';
fclose(fp);
const char *ptr = text;
// skip up to " Address" on a new line
while (*ptr != '\0') {
SkipWhiteSpace(&ptr);
if (idStr::Cmpn(ptr, "Address", 7) == 0) {
SkipRestOfLine(&ptr);
break;
}
SkipRestOfLine(&ptr);
}
int symbolAddress;
int symbolLength;
char symbolName[MAX_STRING_CHARS];
symbol_t *symbol;
// parse symbols
while (*ptr != '\0') {
SkipWhiteSpace(&ptr);
ParseHexNumber(&ptr);
if (*ptr == ':') {
ptr++;
} else {
break;
}
ParseHexNumber(&ptr);
SkipWhiteSpace(&ptr);
// parse symbol name
symbolLength = 0;
while (*ptr != '\0' && *ptr != ' ') {
symbolName[symbolLength++] = *ptr++;
if (symbolLength >= sizeof(symbolName) - 1) {
break;
}
}
symbolName[symbolLength++] = '\0';
SkipWhiteSpace(&ptr);
//.........这里部分代码省略.........
示例7: SkipWhiteSpace
DWORD CReg::ConvertData(LPDWORD pdwType, LPBYTE pData, LPDWORD pdwData, LPBYTE buf, DWORD size)
{_STTEX();
DWORD i = 0;
DWORD dwDataSize = pdwData ? *pdwData : 0;
// Assume nothing
if ( pdwData ) *pdwData = 0;
// Skip to the data
i = SkipWhiteSpace( buf, size, i );
// Check for string
if ( buf[ i ] == '\"' )
{ if ( pdwType != NULL ) *pdwType = REG_SZ;
DWORD dsize = GetToken( pData, dwDataSize, &buf[ i ], size, 0 );
InplaceDecode( (LPTSTR)pData );
if ( pdwData != NULL ) *pdwData = strlen( (char*)pData );
return ( i + dsize );
} // end if
char token[ 1024 ];
DWORD x = 0;
// Copy type token
while ( i < size && buf[ i ] != 0 && buf[ i ] != ':' &&
buf[ i ] != '\r' && buf[ i ] != '\n' ) token[ x++ ] = buf[ i++ ];
token[ x ] = 0;
// Did we get a type token?
if ( buf[ i ] != ':' || *token == 0 )
{
if ( pdwType != NULL ) *pdwType = REG_SZ;
// The token is a string then
strcpy( (char*)pData, token );
// Save Size of data
if ( pdwData != NULL ) *pdwData = strlen( (char*)pData );
return i;
} // end if
// Skip ':'
i++;
// Skip to the data
i = SkipWhiteSpace( buf, size, i );
// check for dword
if ( !strcmpi( token, "dword" ) )
{
if ( pdwType != NULL ) *pdwType = REG_DWORD;
// Verify we got a hex number
if ( ( buf[ i ] < '0' || buf[ i ] > '9' ) &&
( buf[ i ] < 'A' || buf[ i ] > 'F' ) &&
( buf[ i ] < 'a' || buf[ i ] > 'f' ) ) return 0;
// Get DWORD value
*( (LPDWORD)pData ) = strtoul( (char*)&buf[ i ], NULL, 16 );
if ( pdwData != NULL ) *pdwData = sizeof( DWORD );
} // end else if
// check for hex
else if ( !strcmpi( token, "hex" ) )
{
if ( pdwType != NULL ) *pdwType = REG_BINARY;
DWORD x = 0;
// While we have characters
while ( ( buf[ i ] >= '0' && buf[ i ] <= '9' ) ||
( buf[ i ] >= 'A' && buf[ i ] <= 'F' ) ||
( buf[ i ] >= 'a' && buf[ i ] <= 'f' ) )
{
// Get byte value
pData[ x++ ] = (BYTE)ahtoul( (char*)&buf[ i ], 2 );
i += 2;
// Find next character or end of line
while ( i < size && buf[ i ] != 0 &&
buf[ i ] != '\r' && buf[ i ] != '\n' &&
( buf[ i ] < '0' || buf[ i ] > '9' ) &&
( buf[ i ] < 'A' || buf[ i ] > 'F' ) &&
( buf[ i ] < 'a' || buf[ i ] > 'f' ) )
{
// Check for continue to new line character
if ( buf[ i ] == '\\' )
i = NextLine( buf, size, i );
else i++;
} // end while
} // end if
if ( pdwData != NULL ) *pdwData = x;
} // end else if
//.........这里部分代码省略.........
示例8: SkipWhiteSpace
TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace( p, encoding );
if( !p || !*p || *p != '<' )
{
return 0;
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
return 0;
}
// What is this thing?
// - Elements start with a letter or underscore, but xml is reserved.
// - Comments: <!--
// - Decleration: <?xml
// - Everthing else is unknown to tinyxml.
//
const char* xmlHeader = { "<?xml" };
const char* commentHeader = { "<!--" };
const char* dtdHeader = { "<!" };
if ( StringEqual( p, xmlHeader, true, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Declaration\n" );
#endif
returnNode = new TiXmlDeclaration();
}
else if ( StringEqual( p, commentHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Comment\n" );
#endif
returnNode = new TiXmlComment();
}
else if ( StringEqual( p, dtdHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(1)\n" );
#endif
returnNode = new TiXmlUnknown();
}
else if ( IsAlpha( *(p+1), encoding )
|| *(p+1) == '_' )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Element\n" );
#endif
returnNode = new TiXmlElement( "" );
}
else
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(2)\n" );
#endif
returnNode = new TiXmlUnknown();
}
if ( returnNode )
{
// Set the parent, so it can report errors
returnNode->parent = this;
}
else
{
if ( doc )
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
}
return returnNode;
}