23#include <fast_float/fast_float.h>
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;
143 const char*
end = aLine;
144 fast_float::from_chars_result
result =
145 fast_float::from_chars( aLine, aLine + strlen( aLine ), retv, fast_float::chars_format::skip_white_space );
152 if(
result.ec != std::errc() )
158 const char*
next = *aOutput;
172 while( *aCurrentToken && isspace( *aCurrentToken ) )
175 if( !*aCurrentToken )
178 if( !isspace( *( aCurrentToken + 1 ) ) )
179 SCH_PARSE_ERROR(
"expected single character token", aReader, aCurrentToken );
183 const char*
next = aCurrentToken + 2;
191 return *aCurrentToken;
196 const char** aNextToken,
bool aCanBeEmpty )
198 if( !*aCurrentToken )
206 const char* tmp = aCurrentToken;
208 while( *tmp && isspace( *tmp ) )
221 while( *tmp && !isspace( *tmp ) )
226 if( aString.IsEmpty() && !aCanBeEmpty )
231 const char*
next = tmp;
242 const char** aNextToken,
bool aCanBeEmpty )
244 if( !*aCurrentToken )
252 const char* tmp = aCurrentToken;
254 while( *tmp && isspace( *tmp ) )
284 if( *tmp !=
'"' && *tmp !=
'\\' )
289 else if( *tmp ==
'"' )
303 if( aString.IsEmpty() && !aCanBeEmpty )
306 if( *tmp && *tmp !=
'"' )
314 const char*
next = tmp;
316 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)
wxString result
Test unit parsing edge cases and error handling.