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 ) )
87 long retv = strtol( aLine, (
char**) aOutput, 10 );
96 const char*
next = *aOutput;
115 unsigned long long retv;
119 retv = strtoull( aLine, (
char**) aOutput, 16 );
122 if( errno == ERANGE )
128 const char*
next = *aOutput;
136 return (uint32_t)retv;
147 const char*
end = aLine;
148 fast_float::from_chars_result
result =
149 fast_float::from_chars( aLine, aLine + strlen( aLine ), retv, fast_float::chars_format::skip_white_space );
156 if(
result.ec != std::errc() )
162 const char*
next = *aOutput;
176 while( *aCurrentToken && isspace( *aCurrentToken ) )
179 if( !*aCurrentToken )
182 if( !isspace( *( aCurrentToken + 1 ) ) )
183 SCH_PARSE_ERROR(
"expected single character token", aReader, aCurrentToken );
187 const char*
next = aCurrentToken + 2;
195 return *aCurrentToken;
200 const char** aNextToken,
bool aCanBeEmpty )
202 if( !*aCurrentToken )
210 const char* tmp = aCurrentToken;
212 while( *tmp && isspace( *tmp ) )
225 while( *tmp && !isspace( *tmp ) )
230 if( aString.IsEmpty() && !aCanBeEmpty )
235 const char*
next = tmp;
246 const char** aNextToken,
bool aCanBeEmpty )
248 if( !*aCurrentToken )
256 const char* tmp = aCurrentToken;
258 while( *tmp && isspace( *tmp ) )
288 if( *tmp !=
'"' && *tmp !=
'\\' )
293 else if( *tmp ==
'"' )
307 if( aString.IsEmpty() && !aCanBeEmpty )
310 if( *tmp && *tmp !=
'"' )
318 const char*
next = tmp;
320 while( *
next ==
' ' )
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
char * Line() const
Return a pointer to the last line that was read in.
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
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 result
Test unit parsing edge cases and error handling.