KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_kicad_legacy_helpers.cpp File Reference
#include <errno.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <string_utils.h>
#include <richio.h>
#include <config.h>
#include "sch_io_kicad_legacy_helpers.h"

Go to the source code of this file.

Functions

bool is_eol (char c)
 
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 and returns the new pointer position in aOutput if it is not NULL.
 
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 pointer at aOutput if it is not NULL, just like "man strtol()".
 
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 the pointer at aOutput if it is not NULL, just like "man strtoll".
 
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 number and updates the pointer at aOutput if it is not NULL, just like "man strtod".
 
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.
 
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.
 
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.
 

Variables

const char * delims = " \t\r\n"
 

Function Documentation

◆ is_eol()

bool is_eol ( char  c)

◆ parseChar()

char parseChar ( LINE_READER aReader,
const char *  aCurrentToken,
const char **  aNextToken = nullptr 
)

Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.

Parameters
aReader- The line reader used to generate exception throw information.
aCurrentToken- A pointer the current position in a string.
aNextToken- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
Returns
A valid ASCII character.
Exceptions
IO_ERRORon an unexpected end of line.
PARSE_ERRORif the parsed token is not a single character token.

Definition at line 165 of file sch_io_kicad_legacy_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), SCH_IO_KICAD_LEGACY::loadSheet(), SCH_IO_KICAD_LEGACY::loadSymbol(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText(), and SCH_IO_KICAD_LEGACY_LIB_CACHE::parseFillMode().

◆ parseDouble()

double parseDouble ( LINE_READER aReader,
const char *  aLine,
const char **  aOutput = nullptr 
)

Parses an ASCII point string with possible leading whitespace into a double precision floating point number and updates the pointer at aOutput if it is not NULL, just like "man strtod".

Parameters
aReader- The line reader used to generate exception throw information.
aLine- A pointer the current position in a string.
aOutput- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
Returns
A valid double value.
Exceptions
IO_ERRORon an unexpected end of line.
PARSE_ERRORif the parsed token is not a valid integer.

Definition at line 136 of file sch_io_kicad_legacy_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY::loadBitmap(), PCB_IO_KICAD_SEXPR_PARSER::parse3DModel(), PCB_IO_KICAD_SEXPR_PARSER::parseBoardStackup(), PCB_IO_KICAD_SEXPR_PARSER::parseBoardUnits(), DSNLEXER::parseDouble(), PCB_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT(), SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT(), SCH_IO_KICAD_SEXPR_PARSER::parseFill(), PCB_IO_KICAD_SEXPR_PARSER::parseFOOTPRINT_unchecked(), PCB_IO_KICAD_SEXPR_PARSER::parseGENERATOR(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), SCH_IO_KICAD_SEXPR_PARSER::parseInternalUnits(), SCH_IO_KICAD_SEXPR_PARSER::parseJunction(), PCB_IO_KICAD_SEXPR_PARSER::parsePAD(), PCB_IO_KICAD_SEXPR_PARSER::parsePAGE_INFO(), SCH_IO_KICAD_SEXPR_PARSER::parsePAGE_INFO(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_REFERENCE_IMAGE(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_SHAPE(), PCB_IO_KICAD_SEXPR_PARSER::parsePCB_TEXT_effects(), SCH_IO_KICAD_SEXPR_PARSER::parseProperty(), PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache(), SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol(), SCH_IO_KICAD_SEXPR_PARSER::parseSchField(), SCH_IO_KICAD_SEXPR_PARSER::parseSchSheetPin(), SCH_IO_KICAD_SEXPR_PARSER::parseSchText(), SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent(), PCB_IO_KICAD_SEXPR_PARSER::parseSetup(), SCH_IO_KICAD_SEXPR_PARSER::parseSymbolArc(), SCH_IO_KICAD_SEXPR_PARSER::parseSymbolText(), SCH_IO_KICAD_SEXPR_PARSER::parseSymbolTextBox(), PCB_IO_KICAD_SEXPR_PARSER::parseTEARDROP_PARAMETERS(), PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent(), and PCB_IO_KICAD_SEXPR_PARSER::parseZONE().

◆ parseHex()

uint32_t parseHex ( LINE_READER aReader,
const char *  aLine,
const char **  aOutput = nullptr 
)

Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates the pointer at aOutput if it is not NULL, just like "man strtoll".

Parameters
aReader- The line reader used to generate exception throw information.
aLine- A pointer the current position in a string.
aOutput- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
Returns
A valid uint32_t value.
Exceptions
IO_ERRORon an unexpected end of line.
PARSE_ERRORif the parsed token is not a valid integer.

Definition at line 104 of file sch_io_kicad_legacy_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY::loadSymbol().

◆ parseInt()

int parseInt ( LINE_READER aReader,
const char *  aLine,
const char **  aOutput = nullptr 
)

Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointer at aOutput if it is not NULL, just like "man strtol()".

Parameters
aReader- The line reader used to generate exception throw information.
aLine- A pointer the current position in a string.
aOutput- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
Returns
A valid integer value.
Exceptions
AnIO_ERROR on an unexpected end of line.
APARSE_ERROR if the parsed token is not a valid integer.

Definition at line 75 of file sch_io_kicad_legacy_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::Load(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier(), SCH_IO_KICAD_LEGACY::loadBitmap(), SCH_IO_KICAD_LEGACY::loadBusEntry(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), SCH_IO_KICAD_LEGACY::loadHeader(), SCH_IO_KICAD_LEGACY::loadJunction(), SCH_IO_KICAD_LEGACY::loadNoConnect(), SCH_IO_KICAD_LEGACY::loadPageSettings(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect(), SCH_IO_KICAD_LEGACY::loadSheet(), SCH_IO_KICAD_LEGACY::loadSymbol(), SCH_IO_KICAD_LEGACY::loadText(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText(), and SCH_IO_KICAD_LEGACY::loadWire().

◆ parseQuotedString()

void parseQuotedString ( wxString &  aString,
LINE_READER aReader,
const char *  aCurrentToken,
const char **  aNextToken = nullptr,
bool  aCanBeEmpty = false 
)

Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.

The parsed string must be contained within a single line. There are no multi-line quoted strings in the legacy schematic file format.

Parameters
aString- A reference to the parsed string.
aReader- The line reader used to generate exception throw information.
aCurrentToken- A pointer the current position in a string.
aNextToken- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
aCanBeEmpty- True if the parsed string is optional. False if it is mandatory.
Exceptions
IO_ERRORon an unexpected end of line.
PARSE_ERRORif the aCanBeEmpty is false and no string was parsed.

Definition at line 236 of file sch_io_kicad_legacy_helpers.cpp.

References _, From_UTF8(), next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), SCH_IO_KICAD_LEGACY::loadPageSettings(), SCH_IO_KICAD_LEGACY::loadSheet(), SCH_IO_KICAD_LEGACY::loadSymbol(), and SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText().

◆ parseUnquotedString()

void parseUnquotedString ( wxString &  aString,
LINE_READER aReader,
const char *  aCurrentToken,
const char **  aNextToken = nullptr,
bool  aCanBeEmpty = false 
)

Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.

The parsed string must be a continuous string with no white space.

Parameters
aString- A reference to the parsed string.
aReader- The line reader used to generate exception throw information.
aCurrentToken- A pointer the current position in a string.
aNextToken- The pointer to a string pointer to copy the string pointer position when the parsing is complete.
aCanBeEmpty- True if the parsed string is optional. False if it is mandatory.
Exceptions
IO_ERRORon an unexpected end of line.
PARSE_ERRORif the aCanBeEmpty is false and no string was parsed.

Definition at line 190 of file sch_io_kicad_legacy_helpers.cpp.

References _, From_UTF8(), next(), and SCH_PARSE_ERROR.

Referenced by SCH_IO_KICAD_LEGACY::loadBusAlias(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadFootprintFilters(), SCH_IO_KICAD_LEGACY::loadJunction(), SCH_IO_KICAD_LEGACY::loadNoConnect(), SCH_IO_KICAD_LEGACY::loadPageSettings(), SCH_IO_KICAD_LEGACY::loadSheet(), SCH_IO_KICAD_LEGACY::loadSymbol(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText(), and SCH_IO_KICAD_LEGACY::loadWire().

◆ strCompare()

bool strCompare ( const char *  aString,
const char *  aLine,
const char **  aOutput = nullptr 
)

Compare aString to the string starting at aLine and advances the character point to the end of String and returns the new pointer position in aOutput if it is not NULL.

Parameters
aString- A pointer to the string to compare.
aLine- A pointer to string to begin the comparison.
aOutput- A pointer to a string pointer to the end of the comparison if not NULL.
Returns
true if aString was found starting at aLine. Otherwise false.

Definition at line 51 of file sch_io_kicad_legacy_helpers.cpp.

Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::Load(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadAliases(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier(), SCH_IO_KICAD_LEGACY::loadBitmap(), SCH_IO_KICAD_LEGACY::loadBusAlias(), SCH_IO_KICAD_LEGACY::loadBusEntry(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle(), SCH_IO_KICAD_LEGACY::LoadContent(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries(), SCH_IO_KICAD_LEGACY::loadFile(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadFootprintFilters(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadHeader(), SCH_IO_KICAD_LEGACY::loadHeader(), SCH_IO_KICAD_LEGACY::loadJunction(), SCH_IO_KICAD_LEGACY::loadNoConnect(), SCH_IO_KICAD_LEGACY::loadPageSettings(), SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect(), SCH_IO_KICAD_LEGACY::loadSheet(), SCH_IO_KICAD_LEGACY::loadSymbol(), SCH_IO_KICAD_LEGACY::loadText(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText(), and SCH_IO_KICAD_LEGACY::loadWire().

Variable Documentation

◆ delims