KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_legacy_plugin_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_legacy_plugin_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. More...
 
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()". More...
 
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". More...
 
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". More...
 
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. More...
 
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. More...
 
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. More...
 

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_legacy_plugin_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_LEGACY_PLUGIN_CACHE::loadText(), and SCH_LEGACY_PLUGIN_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_legacy_plugin_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_LEGACY_PLUGIN::loadBitmap(), PCB_PARSER::parse3DModel(), SCH_SEXPR_PARSER::parseArc(), PCB_PARSER::parseBoardStackup(), PCB_PARSER::parseBoardUnits(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseFill(), PCB_PARSER::parseFOOTPRINT_unchecked(), PCB_PARSER::parseGENERATOR(), SCH_SEXPR_PARSER::parseImage(), SCH_SEXPR_PARSER::parseInternalUnits(), SCH_SEXPR_PARSER::parseJunction(), PCB_PARSER::parsePAD(), PCB_PARSER::parsePAGE_INFO(), SCH_SEXPR_PARSER::parsePAGE_INFO(), PCB_PARSER::parsePCB_REFERENCE_IMAGE(), PCB_PARSER::parsePCB_SHAPE(), PCB_PARSER::parsePCB_TEXT_effects(), PCB_PARSER::parsePCB_TEXTBOX(), SCH_SEXPR_PARSER::parseProperty(), PCB_PARSER::parseRenderCache(), SCH_SEXPR_PARSER::parseSchematicSymbol(), SCH_SEXPR_PARSER::parseSchField(), SCH_SEXPR_PARSER::parseSchSheetPin(), SCH_SEXPR_PARSER::parseSchText(), SCH_SEXPR_PARSER::parseSchTextBox(), PCB_PARSER::parseSetup(), PCB_PARSER::parseTEARDROP_PARAMETERS(), SCH_SEXPR_PARSER::parseText(), SCH_SEXPR_PARSER::parseTextBox(), and PCB_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_legacy_plugin_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_LEGACY_PLUGIN::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_legacy_plugin_helpers.cpp.

References _, next(), and SCH_PARSE_ERROR.

Referenced by SCH_LEGACY_PLUGIN_CACHE::Load(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), SCH_LEGACY_PLUGIN_CACHE::loadBezier(), SCH_LEGACY_PLUGIN::loadBitmap(), SCH_LEGACY_PLUGIN::loadBusEntry(), SCH_LEGACY_PLUGIN_CACHE::loadCircle(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_LEGACY_PLUGIN::loadHeader(), SCH_LEGACY_PLUGIN::loadJunction(), SCH_LEGACY_PLUGIN::loadNoConnect(), SCH_LEGACY_PLUGIN::loadPageSettings(), SCH_LEGACY_PLUGIN_CACHE::loadPolyLine(), SCH_LEGACY_PLUGIN_CACHE::loadRect(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_LEGACY_PLUGIN::loadText(), SCH_LEGACY_PLUGIN_CACHE::loadText(), and SCH_LEGACY_PLUGIN::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_legacy_plugin_helpers.cpp.

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

Referenced by SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_LEGACY_PLUGIN::loadPageSettings(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_LEGACY_PLUGIN::loadSymbol(), and SCH_LEGACY_PLUGIN_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_legacy_plugin_helpers.cpp.

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

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

◆ strCompare()

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

Variable Documentation

◆ delims