44 if( c ==
'\n' || c ==
'\r' || c == 0 )
51bool strCompare(
const char* aString,
const char* aLine,
const char** aOutput )
53 size_t len = strlen( aString );
54 bool retv = ( strncasecmp( aLine, aString, len ) == 0 ) &&
55 ( isspace( aLine[ len ] ) || aLine[ len ] == 0 );
59 const char* tmp = aLine;
65 while( *tmp && isspace( *tmp ) )
83 long retv = strtol( aLine, (
char**) aOutput, 10 );
92 const char*
next = *aOutput;
111 unsigned long long retv;
115 retv = strtoull( aLine, (
char**) aOutput, 16 );
118 if( errno == ERANGE )
124 const char*
next = *aOutput;
132 return (uint32_t)retv;
144 double retv = strtod( aLine, (
char**) aOutput );
147 if( errno == ERANGE )
153 const char*
next = *aOutput;
167 while( *aCurrentToken && isspace( *aCurrentToken ) )
170 if( !*aCurrentToken )
173 if( !isspace( *( aCurrentToken + 1 ) ) )
174 SCH_PARSE_ERROR(
"expected single character token", aReader, aCurrentToken );
178 const char*
next = aCurrentToken + 2;
186 return *aCurrentToken;
191 const char** aNextToken,
bool aCanBeEmpty )
193 if( !*aCurrentToken )
201 const char* tmp = aCurrentToken;
203 while( *tmp && isspace( *tmp ) )
216 while( *tmp && !isspace( *tmp ) )
221 if( aString.IsEmpty() && !aCanBeEmpty )
226 const char*
next = tmp;
237 const char** aNextToken,
bool aCanBeEmpty )
239 if( !*aCurrentToken )
247 const char* tmp = aCurrentToken;
249 while( *tmp && isspace( *tmp ) )
279 if( *tmp !=
'"' && *tmp !=
'\\' )
284 else if( *tmp ==
'"' )
298 if( aString.IsEmpty() && !aCanBeEmpty )
301 if( *tmp && *tmp !=
'"' )
309 const char*
next = tmp;
311 while( *
next ==
' ' )
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
int parseInt(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
bool strCompare(const char *aString, const char *aLine, const char **aOutput)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void parseQuotedString(wxString &aString, LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken, bool aCanBeEmpty)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
void parseUnquotedString(wxString &aString, LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken, bool aCanBeEmpty)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
uint32_t parseHex(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
char parseChar(LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
double parseDouble(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parses an ASCII point string with possible leading whitespace into a double precision floating point ...
#define SCH_PARSE_ERROR(text, reader, pos)
wxString From_UTF8(const char *cstring)