KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eagle_parser.cpp File Reference
#include <io/eagle/eagle_parser.h>
#include <core/profile.h>
#include <io/io_base.h>
#include <string_utils.h>
#include <richio.h>
#include <trace_helpers.h>
#include <wx/log.h>
#include <wx/regex.h>
#include <functional>
#include <cstdio>

Go to the source code of this file.

Functions

wxString escapeName (const wxString &aNetName)
 Interprets special characters in Eagle text and converts them to KiCAD notation.
 
wxString interpretText (const wxString &aText)
 Translates Eagle special text reference to a KiCad variable reference.
 
bool substituteVariable (wxString *aText)
 Converts Eagle's HTML description into KiCad description format.
 
wxString convertDescription (wxString aDescr)
 
size_t GetNodeCount (const wxXmlNode *aNode)
 Fetch the number of XML nodes within aNode.
 
template<>
wxString Convert< wxString > (const wxString &aValue)
 
template<>
std::string Convert< std::string > (const wxString &aValue)
 
template<>
double Convert< double > (const wxString &aValue)
 
template<>
int Convert< int > (const wxString &aValue)
 
template<>
bool Convert< bool > (const wxString &aValue)
 
template<>
EROT Convert< EROT > (const wxString &aRot)
 parse an Eagle XML "rot" field.
 
template<>
ECOORD Convert< ECOORD > (const wxString &aCoord)
 
template<typename T >
parseRequiredAttribute (wxXmlNode *aNode, const wxString &aAttribute)
 Parse aAttribute of the XML node aNode.
 
template<typename T >
OPTIONAL_XML_ATTRIBUTE< T > parseOptionalAttribute (wxXmlNode *aNode, const wxString &aAttribute)
 Parse option aAttribute of the XML node aNode.
 
NODE_MAP MapChildren (wxXmlNode *aCurrentNode)
 Provide an easy access to the children of an XML node via their names.
 
VECTOR2I ConvertArcCenter (const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
 
static int parseAlignment (const wxString &aAlignment)
 

Variables

constexpr auto DEFAULT_ALIGNMENT = ETEXT::BOTTOM_LEFT
 

Function Documentation

◆ Convert< bool >()

template<>
bool Convert< bool > ( const wxString &  aValue)

Definition at line 341 of file eagle_parser.cpp.

◆ Convert< double >()

template<>
double Convert< double > ( const wxString &  aValue)

Definition at line 318 of file eagle_parser.cpp.

◆ Convert< ECOORD >()

template<>
ECOORD Convert< ECOORD > ( const wxString &  aCoord)

Definition at line 372 of file eagle_parser.cpp.

References ECOORD::EU_MM.

◆ Convert< EROT >()

template<>
EROT Convert< EROT > ( const wxString &  aRot)

parse an Eagle XML "rot" field.

Unfortunately the DTD seems not to explain this format very well. [S][M]R<degrees>. Examples: "R90", "MR180", "SR180"

Definition at line 355 of file eagle_parser.cpp.

References EROT::degrees, EROT::mirror, and EROT::spin.

◆ Convert< int >()

template<>
int Convert< int > ( const wxString &  aValue)

Definition at line 331 of file eagle_parser.cpp.

◆ Convert< std::string >()

template<>
std::string Convert< std::string > ( const wxString &  aValue)

Definition at line 311 of file eagle_parser.cpp.

◆ Convert< wxString >()

template<>
wxString Convert< wxString > ( const wxString &  aValue)

Definition at line 304 of file eagle_parser.cpp.

◆ ConvertArcCenter()

◆ convertDescription()

wxString convertDescription ( wxString  aDescr)

Definition at line 153 of file eagle_parser.cpp.

References RemoveHTMLTags().

Referenced by SCH_IO_EAGLE::loadLibrary(), and PCB_IO_EAGLE::makeFootprint().

◆ escapeName()

wxString escapeName ( const wxString &  aNetName)

Interprets special characters in Eagle text and converts them to KiCAD notation.

Definition at line 45 of file eagle_parser.cpp.

References ConvertToNewOverbarNotation().

Referenced by SCH_IO_EAGLE::loadLabel(), SCH_IO_EAGLE::loadPlainText(), SCH_IO_EAGLE::loadSegments(), PCB_IO_EAGLE::loadSignals(), and SCH_IO_EAGLE::loadSymbol().

◆ GetNodeCount()

size_t GetNodeCount ( const wxXmlNode *  aNode)

Fetch the number of XML nodes within aNode.

Parameters
aNodeis the parent node of the children to count.
Returns
the count of all child XML nodes below aNode.

Definition at line 183 of file eagle_parser.cpp.

References PROF_TIMER::msecs(), PROF_TIMER::Stop(), and traceEagleIo.

Referenced by SCH_IO_EAGLE::LoadSchematicFile().

◆ interpretText()

wxString interpretText ( const wxString &  aText)

Translates Eagle special text reference to a KiCad variable reference.

Definition at line 55 of file eagle_parser.cpp.

References substituteVariable(), and text.

Referenced by PCB_IO_EAGLE::loadPlain(), SCH_IO_EAGLE::loadPlainText(), SCH_IO_EAGLE::loadSymbolText(), and PCB_IO_EAGLE::packageText().

◆ MapChildren()

NODE_MAP MapChildren ( wxXmlNode *  aCurrentNode)

Provide an easy access to the children of an XML node via their names.

Parameters
currentNodeis a pointer to a wxXmlNode, whose children will be mapped.
Returns
NODE_MAP is a map linking the name of each children to the children itself (via a wxXmlNode*) Convert an Eagle curve end to a KiCad center for S_ARC

Definition at line 414 of file eagle_parser.cpp.

Referenced by PCB_IO_EAGLE::cacheLib(), PCB_IO_EAGLE::loadAllSections(), and PCB_IO_EAGLE::loadLibrary().

◆ parseAlignment()

static int parseAlignment ( const wxString &  aAlignment)
static

◆ parseOptionalAttribute()

template<typename T >
OPTIONAL_XML_ATTRIBUTE< T > parseOptionalAttribute ( wxXmlNode *  aNode,
const wxString &  aAttribute 
)

Parse option aAttribute of the XML node aNode.

Parameters
aNodeis the node whose attribute will be parsed.
aAttributeis the attribute that will be parsed.
Returns
OPTIONAL_XML_ATTRIBUTE<T> - an optional XML attribute, parsed as the specified type if found.

Definition at line 408 of file eagle_parser.cpp.

◆ parseRequiredAttribute()

template<typename T >
T parseRequiredAttribute ( wxXmlNode *  aNode,
const wxString &  aAttribute 
)

Parse aAttribute of the XML node aNode.

Parameters
aNodeis the node whose attribute will be parsed.
aAttributeis the attribute that will be parsed.
Exceptions
XML_PARSER_ERROR- exception thrown if the required attribute is missing
Returns
T - the attributed parsed as the specified type.

Definition at line 388 of file eagle_parser.cpp.

◆ substituteVariable()

bool substituteVariable ( wxString *  aText)

Converts Eagle's HTML description into KiCad description format.

Definition at line 122 of file eagle_parser.cpp.

Referenced by interpretText().

Variable Documentation

◆ DEFAULT_ALIGNMENT

constexpr auto DEFAULT_ALIGNMENT = ETEXT::BOTTOM_LEFT
constexpr

Definition at line 42 of file eagle_parser.cpp.

Referenced by EATTR::EATTR(), ETEXT::ETEXT(), and parseAlignment().