KiCad PCB EDA Suite
eagle_parser.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
6  * Copyright (C) 2017 CERN
7  * @author Alejandro GarcĂ­a Montoro <alejandro.garciamontoro@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 
28 #ifndef _EAGLE_PARSER_H_
29 #define _EAGLE_PARSER_H_
30 
31 #include <errno.h>
32 #include <unordered_map>
33 
34 #include <wx/xml/xml.h>
35 #include <wx/string.h>
36 #include <wx/filename.h>
37 
39 #include <convert_to_biu.h>
40 #include <macros.h>
41 #include <trigo.h>
42 #include <kicad_string.h>
43 #include <common.h>
44 
45 class MODULE;
46 struct EINSTANCE;
47 struct EPART;
48 struct ETEXT;
49 
50 typedef std::unordered_map<wxString, wxXmlNode*> NODE_MAP;
51 typedef std::map<wxString, MODULE*> MODULE_MAP;
52 typedef std::map<wxString, EINSTANCE*> EINSTANCE_MAP;
53 typedef std::map<wxString, std::unique_ptr<EPART>> EPART_MAP;
54 
56 wxString escapeName( const wxString& aNetName );
57 
58 static inline wxXmlNode* getChildrenNodes( NODE_MAP& aMap, const wxString& aName )
59 {
60  auto it = aMap.find( aName );
61  return it == aMap.end() ? nullptr : it->second->GetChildren();
62 }
63 
64 
70 struct XML_PARSER_ERROR : std::runtime_error
71 {
78  XML_PARSER_ERROR( const wxString& aMessage ) noexcept :
79  std::runtime_error( "XML parser failed - " + aMessage.ToStdString() )
80  {}
81 };
82 
83 
85 struct TRIPLET
86 {
87  const char* element;
88  const char* attribute;
89  const char* value;
90 
91  TRIPLET( const char* aElement, const char* aAttribute = "", const char* aValue = "" ) :
92  element( aElement ),
93  attribute( aAttribute ),
94  value( aValue )
95  {}
96 };
97 
98 
112 class XPATH
113 {
114  std::vector<TRIPLET> p;
115 
116 public:
117  void push( const char* aPathSegment, const char* aAttribute="" )
118  {
119  p.push_back( TRIPLET( aPathSegment, aAttribute ) );
120  }
121 
122  void clear() { p.clear(); }
123 
124  void pop() { p.pop_back(); }
125 
127  void Value( const char* aValue )
128  {
129  p.back().value = aValue;
130  }
131 
133  void Attribute( const char* aAttribute )
134  {
135  p.back().attribute = aAttribute;
136  }
137 
139  wxString Contents()
140  {
141  typedef std::vector<TRIPLET>::const_iterator CITER_TRIPLET;
142 
143  wxString ret;
144 
145  for( CITER_TRIPLET it = p.begin(); it != p.end(); ++it )
146  {
147  if( it != p.begin() )
148  ret += '.';
149 
150  ret += it->element;
151 
152  if( it->attribute[0] && it->value[0] )
153  {
154  ret += '[';
155  ret += it->attribute;
156  ret += '=';
157  ret += it->value;
158  ret += ']';
159  }
160  }
161 
162  return ret;
163  }
164 };
165 
166 
174 template<typename T>
175 T Convert( const wxString& aValue )
176 {
177  throw XML_PARSER_ERROR( "Conversion failed. Unknown type." );
178 }
179 
180 template <>
181 wxString Convert<wxString>( const wxString& aValue );
182 
189 template <typename T>
191 {
192 private:
195 
198 
199 public:
205  m_isAvailable( false ),
206  m_data( T() )
207  {}
208 
215  OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
216  {
217  m_data = T();
218  m_isAvailable = !aData.IsEmpty();
219 
220  if( m_isAvailable )
221  Set( aData );
222  }
223 
229  template<typename V = T>
231  m_isAvailable( true ),
232  m_data( aData )
233  {}
234 
239  operator bool() const
240  {
241  return m_isAvailable;
242  }
243 
250  OPTIONAL_XML_ATTRIBUTE<T>& operator =( const wxString& aData )
251  {
252  m_isAvailable = !aData.IsEmpty();
253 
254  if( m_isAvailable )
255  Set( aData );
256 
257  return *this;
258  }
259 
267  {
268  m_data = aData;
269  m_isAvailable = true;
270 
271  return *this;
272  }
273 
279  bool operator ==( const T& aOther ) const
280  {
281  return m_isAvailable && ( aOther == m_data );
282  }
283 
289  void Set( const wxString& aString )
290  {
291  m_data = Convert<T>( aString );
292  m_isAvailable = !aString.IsEmpty();
293  }
294 
300  T& Get()
301  {
302  assert( m_isAvailable );
303  return m_data;
304  }
305 
311  const T& CGet() const
312  {
313  assert( m_isAvailable );
314  return m_data;
315  }
316 
323  {
324  return Get();
325  }
326 
332  const T& operator*() const
333  {
334  return CGet();
335  }
336 
343  {
344  return &Get();
345  }
346 
352  const T* operator->() const
353  {
354  return &CGet();
355  }
356 };
357 
358 
366 NODE_MAP MapChildren( wxXmlNode* aCurrentNode );
367 
369 timestamp_t EagleTimeStamp( wxXmlNode* aTree );
370 
372 timestamp_t EagleModuleTstamp( const wxString& aName, const wxString& aValue, int aUnit );
373 
375 wxPoint ConvertArcCenter( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
376 
377 // Pre-declare for typedefs
378 struct EROT;
379 struct ECOORD;
386 
387 
388 // All of the 'E'STRUCTS below merely hold Eagle XML information verbatim, in binary.
389 // For maintenance and troubleshooting purposes, it was thought that we'd need to
390 // separate the conversion process into distinct steps. There is no intent to have KiCad
391 // forms of information in these 'E'STRUCTS. They are only binary forms
392 // of the Eagle information in the corresponding Eagle XML nodes.
393 
394 // Eagle coordinates
395 struct ECOORD
396 {
398  {
403  };
404 
406  long long int value;
407 
409  static constexpr EAGLE_UNIT ECOORD_UNIT = EU_NM;
410 
412  : value( 0 )
413  {
414  }
415 
416  ECOORD( int aValue, enum EAGLE_UNIT aUnit )
417  : value( ConvertToNm( aValue, aUnit ) )
418  {
419  }
420 
421  ECOORD( const wxString& aValue, enum EAGLE_UNIT aUnit );
422 
423  int ToMils() const
424  {
425  return value / 25400;
426  }
427 
428  int ToNanoMeters() const
429  {
430  return value;
431  }
432 
433  float ToMm() const
434  {
435  return value / 1000000.0;
436  }
437 
438  int ToSchUnits() const { return ToMils(); }
439  int ToPcbUnits() const { return ToNanoMeters(); }
440 
441  ECOORD operator+( const ECOORD& aOther ) const
442  {
443  return ECOORD( value + aOther.value, ECOORD_UNIT );
444  }
445 
446  ECOORD operator-( const ECOORD& aOther ) const
447  {
448  return ECOORD( value - aOther.value, ECOORD_UNIT );
449  }
450 
451  bool operator==( const ECOORD& aOther ) const
452  {
453  return value == aOther.value;
454  }
455 
457  static long long int ConvertToNm( int aValue, enum EAGLE_UNIT aUnit );
458 };
459 
460 
462 struct ENET
463 {
464  int netcode;
465  wxString netname;
466 
467  ENET( int aNetCode, const wxString& aNetName ) :
468  netcode( aNetCode ),
469  netname( aNetName )
470  {}
471 
472  ENET() :
473  netcode( 0 )
474  {}
475 };
476 
477 
479 struct EROT
480 {
481  bool mirror;
482  bool spin;
483  double degrees;
484 
485  EROT() :
486  mirror( false ),
487  spin( false ),
488  degrees( 0 )
489  {}
490 
491  EROT( double aDegrees ) :
492  mirror( false ),
493  spin( false ),
494  degrees( aDegrees )
495  {}
496 };
497 
498 
500 struct EWIRE
501 {
508 
509  // for style: (continuous | longdash | shortdash | dashdot)
510  enum {
515  };
518 
519  // for cap: (flat | round)
520  enum {
523  };
525 
526  EWIRE( wxXmlNode* aWire );
527 };
528 
529 
531 struct EJUNCTION
532 {
535 
536  EJUNCTION( wxXmlNode* aJunction);
537 };
538 
539 
541 struct ELABEL
542 {
549  wxString netname;
550 
551  ELABEL( wxXmlNode* aLabel, const wxString& aNetName );
552 };
553 
554 
556 struct EVIA
557 {
565 
566  EVIA( wxXmlNode* aVia );
567 };
568 
569 
571 struct ECIRCLE
572 {
578 
579  ECIRCLE( wxXmlNode* aCircle );
580 };
581 
582 
584 struct ERECT
585 {
590  int layer;
592 
593  ERECT( wxXmlNode* aRect );
594 };
595 
596 
603 struct EATTR
604 {
605  wxString name;
613 
614  enum { // for 'display'
619  };
622 
623  EATTR( wxXmlNode* aTree );
624  EATTR() {}
625 };
626 
627 
630 {
637  int layer;
638 
640 
641  EDIMENSION( wxXmlNode* aDimension );
642 };
643 
644 
646 struct ETEXT
647 {
648  wxString text;
652  int layer;
656 
657  enum { // for align
663 
664  // opposites are -1 x above, used by code tricks in here
669  };
670 
672 
673  ETEXT( wxXmlNode* aText );
674 
676  wxSize ConvertSize() const;
677 };
678 
679 
682 {
683  wxString name;
688 
689  EPAD_COMMON( wxXmlNode* aPad );
690 };
691 
692 
694 struct EPAD : public EPAD_COMMON
695 {
698 
699  // for shape: (square | round | octagon | long | offset)
700  enum {
701  UNDEF = -1,
707  };
710 
711  EPAD( wxXmlNode* aPad );
712 };
713 
714 
716 struct ESMD : public EPAD_COMMON
717 {
720  int layer;
723 
724  ESMD( wxXmlNode* aSMD );
725 };
726 
727 
729 struct EPIN
730 {
731  wxString name;
734 
738  opt_wxString function;
741 
742  EPIN( wxXmlNode* aPin );
743 };
744 
745 
747 struct EVERTEX
748 {
752 
753  EVERTEX( wxXmlNode* aVertex );
754 };
755 
756 
758 struct EPOLYGON
759 {
761  int layer;
763 
764  // KiCad priority is opposite of Eagle rank, that is:
765  // - Eagle Low rank drawn first
766  // - KiCad high priority drawn first
767  // So since Eagle has an upper limit we define this, used for the cases
768  // where no rank is specified.
769  static const int max_priority = 6;
770 
771  enum { // for pour
775  };
776  int pour;
781 
782  EPOLYGON( wxXmlNode* aPolygon );
783 };
784 
785 
787 struct EHOLE
788 {
792 
793  EHOLE( wxXmlNode* aHole );
794 };
795 
796 
798 struct EELEMENT
799 {
800  wxString name;
801  wxString library;
802  wxString package;
803  wxString value;
809 
810  EELEMENT( wxXmlNode* aElement );
811 };
812 
813 
814 struct ELAYER
815 {
816  int number;
817  wxString name;
818  int color;
819  int fill;
822 
823  ELAYER( wxXmlNode* aLayer );
824 };
825 
826 
828 {
829  enum
830  {
831  TOP = 1,
832  ROUTE2 = 2,
833  ROUTE3 = 3,
834  ROUTE4 = 4,
835  ROUTE5 = 5,
836  ROUTE6 = 6,
837  ROUTE7 = 7,
838  ROUTE8 = 8,
839  ROUTE9 = 9,
840  ROUTE10 = 10,
841  ROUTE11 = 11,
842  ROUTE12 = 12,
843  ROUTE13 = 13,
844  ROUTE14 = 14,
845  ROUTE15 = 15,
846  BOTTOM = 16,
847  PADS = 17,
848  VIAS = 18,
849  UNROUTED = 19,
850  DIMENSION = 20,
851  TPLACE = 21,
852  BPLACE = 22,
853  TORIGINS = 23,
854  BORIGINS = 24,
855  TNAMES = 25,
856  BNAMES = 26,
857  TVALUES = 27,
858  BVALUES = 28,
859  TSTOP = 29,
860  BSTOP = 30,
861  TCREAM = 31,
862  BCREAM = 32,
863  TFINISH = 33,
864  BFINISH = 34,
865  TGLUE = 35,
866  BGLUE = 36,
867  TTEST = 37,
868  BTEST = 38,
869  TKEEPOUT = 39,
870  BKEEPOUT = 40,
871  TRESTRICT = 41,
872  BRESTRICT = 42,
873  VRESTRICT = 43,
874  DRILLS = 44,
875  HOLES = 45,
876  MILLING = 46,
877  MEASURES = 47,
878  DOCUMENT = 48,
881  TDOCU = 51,
882  BDOCU = 52,
883  NETS = 91,
884  BUSSES = 92,
885  PINS = 93,
886  SYMBOLS = 94,
887  NAMES = 95,
888  VALUES = 96,
889  INFO = 97,
890  GUIDE = 98,
891  USERLAYER1 = 160,
893  };
894 };
895 
896 
897 struct EPART
898 {
899  /*
900  * <!ELEMENT part (attribute*, variant*)>
901  * <!ATTLIST part
902  * name %String; #REQUIRED
903  * library %String; #REQUIRED
904  * deviceset %String; #REQUIRED
905  * device %String; #REQUIRED
906  * technology %String; ""
907  * value %String; #IMPLIED
908  * >
909  */
910 
911  wxString name;
912  wxString library;
913  wxString deviceset;
914  wxString device;
917  std::map<std::string,std::string> attribute;
918  std::map<std::string,std::string> variant;
919 
920  EPART( wxXmlNode* aPart );
921 };
922 
923 
924 struct EINSTANCE
925 {
926  /*
927  * <!ELEMENT instance (attribute)*>
928  * <!ATTLIST instance
929  * part %String; #REQUIRED
930  * gate %String; #REQUIRED
931  * x %Coord; #REQUIRED
932  * y %Coord; #REQUIRED
933  * smashed %Bool; "no"
934  * rot %Rotation; "R0"
935  * >
936  */
937 
938  wxString part;
939  wxString gate;
944 
945  EINSTANCE( wxXmlNode* aInstance );
946 };
947 
948 
949 struct EGATE
950 {
951  /*
952  * <!ELEMENT gate EMPTY>
953  * <!ATTLIST gate
954  * name %String; #REQUIRED
955  * symbol %String; #REQUIRED
956  * x %Coord; #REQUIRED
957  * y %Coord; #REQUIRED
958  * addlevel %GateAddLevel; "next"
959  * swaplevel %Int; "0"
960  * >
961  */
962 
963  wxString name;
964  wxString symbol;
965 
968 
971 
972  enum
973  {
979  };
980 
981  EGATE( wxXmlNode* aGate );
982 };
983 
984 
985 struct ECONNECT
986 {
987  /*
988  * <!ELEMENT connect EMPTY>
989  * <!ATTLIST connect
990  * gate %String; #REQUIRED
991  * pin %String; #REQUIRED
992  * pad %String; #REQUIRED
993  * route %ContactRoute; "all"
994  * >
995  */
996  wxString gate;
997  wxString pin;
998  wxString pad;
999  //int contactroute; // TODO
1000 
1001  ECONNECT( wxXmlNode* aConnect );
1002 };
1003 
1004 
1005 struct EDEVICE
1006 {
1007  /*
1008  <!ELEMENT device (connects?, technologies?)>
1009  <!ATTLIST device
1010  name %String; ""
1011  package %String; #IMPLIED
1012  >
1013 */
1014  wxString name;
1016 
1017  std::vector<ECONNECT> connects;
1018 
1019  EDEVICE( wxXmlNode* aDevice );
1020 };
1021 
1022 
1024 {
1025  /*
1026  <!ELEMENT deviceset (description?, gates, devices)>
1027  <!ATTLIST deviceset
1028  name %String; #REQUIRED
1029  prefix %String; ""
1030  uservalue %Bool; "no"
1031  >
1032  */
1033 
1034  wxString name;
1037  //std::vector<EDEVICE> devices;
1038  //std::vector<EGATE> gates;
1039 
1040 
1041  EDEVICE_SET( wxXmlNode* aDeviceSet );
1042 };
1043 
1044 
1045 #endif // _EAGLE_PARSER_H_
void Set(const wxString &aString)
Function Set tries to convert a string to the base type.
Definition: eagle_parser.h:289
wxString name
wxString Contents()
return the contents of the XPATH as a single string
Definition: eagle_parser.h:139
Eagle vertex.
Definition: eagle_parser.h:747
Eagle rotation.
Definition: eagle_parser.h:479
wxString deviceset
Definition: eagle_parser.h:913
Eagle Junction.
Definition: eagle_parser.h:531
timestamp_t EagleModuleTstamp(const wxString &aName, const wxString &aValue, int aUnit)
Computes module timestamp basing on its name, value and unit
bool mirror
Definition: eagle_parser.h:481
opt_double curve
range is -359.9..359.9
Definition: eagle_parser.h:517
ECOORD x
Definition: eagle_parser.h:732
timestamp_t EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp
wxString pad
Definition: eagle_parser.h:998
wxString Convert< wxString >(const wxString &aValue)
opt_int rank
Definition: eagle_parser.h:780
wxString part
Definition: eagle_parser.h:938
int ToSchUnits() const
Definition: eagle_parser.h:438
wxString name
Definition: eagle_parser.h:911
OPTIONAL_XML_ATTRIBUTE< T > & operator=(const wxString &aData)
Assignment operator to a string (optionally) containing the data.
Definition: eagle_parser.h:250
int ToNanoMeters() const
Definition: eagle_parser.h:428
ECOORD x
Definition: eagle_parser.h:543
opt_ecoord diam
Definition: eagle_parser.h:563
opt_wxString technology
Definition: eagle_parser.h:915
wxString library
Definition: eagle_parser.h:912
opt_wxString direction
Definition: eagle_parser.h:737
void clear()
Definition: eagle_parser.h:122
opt_erot rot
Definition: eagle_parser.h:547
float ToMm() const
Definition: eagle_parser.h:433
opt_int cap
Definition: eagle_parser.h:524
ECOORD operator-(const ECOORD &aOther) const
Definition: eagle_parser.h:446
const T & CGet() const
Function CGet returns a constant reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:311
T & operator *()
Operator * returns a reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:322
ECOORD drill
< inclusive
Definition: eagle_parser.h:562
T & Get()
Function Get returns a reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:300
opt_wxString shape
Definition: eagle_parser.h:564
ECOORD y
Definition: eagle_parser.h:750
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
Eagle element element.
Definition: eagle_parser.h:798
Class XPATH keeps track of what we are working on within a PTREE.
Definition: eagle_parser.h:112
ECOORD x2
Definition: eagle_parser.h:588
static const int max_priority
Definition: eagle_parser.h:769
opt_double ratio
Definition: eagle_parser.h:654
opt_bool visible
Definition: eagle_parser.h:820
void Attribute(const char *aAttribute)
modify the last path node's attribute
Definition: eagle_parser.h:133
int number
Definition: eagle_parser.h:816
OPTIONAL_XML_ATTRIBUTE()
Constructor OPTIONAL_XML_ATTRIBUTE construct a default OPTIONAL_XML_ATTRIBUTE, whose data is not avai...
Definition: eagle_parser.h:204
opt_wxString xref
Definition: eagle_parser.h:548
opt_erot rot
Definition: eagle_parser.h:808
wxString gate
Definition: eagle_parser.h:996
ECOORD width
Definition: eagle_parser.h:506
opt_bool thermals
Definition: eagle_parser.h:779
opt_bool smashed
Definition: eagle_parser.h:807
bool operator==(const ECOORD &aOther) const
Definition: eagle_parser.h:451
std::map< std::string, std::string > variant
Definition: eagle_parser.h:918
OPTIONAL_XML_ATTRIBUTE(T aData)
Constructor OPTIONAL_XML_ATTRIBUTE.
Definition: eagle_parser.h:230
wxString name
Definition: eagle_parser.h:683
const char * element
Definition: eagle_parser.h:87
wxPoint ConvertArcCenter(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC
opt_erot rot
Definition: eagle_parser.h:591
double degrees
Definition: eagle_parser.h:483
ECOORD width
Definition: eagle_parser.h:760
ECOORD x
Definition: eagle_parser.h:940
Eagle SMD pad.
Definition: eagle_parser.h:716
ECOORD y
Definition: eagle_parser.h:574
ECOORD operator+(const ECOORD &aOther) const
Definition: eagle_parser.h:441
ECOORD y
Definition: eagle_parser.h:805
ECOORD y
Definition: eagle_parser.h:534
Eagle hole element.
Definition: eagle_parser.h:787
Class XML_PARSER_ERROR implements a simple wrapper around runtime_error to isolate the errors thrown ...
Definition: eagle_parser.h:70
OPTIONAL_XML_ATTRIBUTE< int > opt_int
Definition: eagle_parser.h:381
wxString netname
Definition: eagle_parser.h:549
Eagle text element.
Definition: eagle_parser.h:646
opt_erot rot
Definition: eagle_parser.h:612
std::map< wxString, MODULE * > MODULE_MAP
Definition: eagle_parser.h:51
ELAYER(wxXmlNode *aLayer)
opt_bool thermals
Definition: eagle_parser.h:687
ECOORD width
Definition: eagle_parser.h:576
opt_int swaplevel
Definition: eagle_parser.h:739
ECOORD x
Definition: eagle_parser.h:573
Eagle pin element.
Definition: eagle_parser.h:729
EPIN(wxXmlNode *aPin)
int fill
Definition: eagle_parser.h:819
Eagle label.
Definition: eagle_parser.h:541
opt_wxString value
Definition: eagle_parser.h:916
nanometers
Definition: eagle_parser.h:399
This file contains miscellaneous commonly used macros and functions.
EDEVICE(wxXmlNode *aDevice)
ECOORD y
Definition: eagle_parser.h:544
EPART(wxXmlNode *aPart)
OPTIONAL_XML_ATTRIBUTE< wxString > opt_wxString
Definition: eagle_parser.h:379
int layer_back_most
< extent
Definition: eagle_parser.h:561
segment (element) of our XPATH into the Eagle XML document tree in PTREE form.
Definition: eagle_parser.h:85
ECONNECT(wxXmlNode *aConnect)
EVERTEX(wxXmlNode *aVertex)
wxString name
opt_int align
Definition: eagle_parser.h:621
ECOORD dy
Definition: eagle_parser.h:719
wxString gate
Definition: eagle_parser.h:939
ESMD(wxXmlNode *aSMD)
opt_ecoord isolate
Definition: eagle_parser.h:777
wxString name
Definition: eagle_parser.h:605
T * operator->()
Operator -> returns a pointer to the value of the attribute assuming it is available.
Definition: eagle_parser.h:342
wxString name
Definition: eagle_parser.h:817
ECOORD y1
Definition: eagle_parser.h:503
EJUNCTION(wxXmlNode *aJunction)
wxString value
Definition: eagle_parser.h:803
OPTIONAL_XML_ATTRIBUTE< double > opt_double
Definition: eagle_parser.h:382
opt_int style
Definition: eagle_parser.h:516
ECOORD x
Definition: eagle_parser.h:789
wxString escapeName(const wxString &aNetName)
Translates Eagle special characters to their counterparts in KiCad.
OPTIONAL_XML_ATTRIBUTE< bool > opt_bool
Definition: eagle_parser.h:383
EDIMENSION(wxXmlNode *aDimension)
LAYER_NUM layer
Definition: eagle_parser.h:507
opt_ecoord y
Definition: eagle_parser.h:608
ELABEL(wxXmlNode *aLabel, const wxString &aNetName)
int layer
Definition: eagle_parser.h:590
Eagle thru hole pad.
Definition: eagle_parser.h:694
opt_ecoord spacing
Definition: eagle_parser.h:762
wxString name
Definition: eagle_parser.h:800
ECOORD size
Definition: eagle_parser.h:545
const T * operator->() const
Operator -> returns a constant pointer to the value of the attribute assuming it is available.
Definition: eagle_parser.h:352
EWIRE(wxXmlNode *aWire)
EHOLE(wxXmlNode *aHole)
static constexpr EAGLE_UNIT ECOORD_UNIT
Unit used for the value field
Definition: eagle_parser.h:409
ECOORD y1
Definition: eagle_parser.h:587
Eagle circle.
Definition: eagle_parser.h:571
ECOORD dx
Definition: eagle_parser.h:718
wxString symbol
Definition: eagle_parser.h:964
EPOLYGON(wxXmlNode *aPolygon)
std::vector< TRIPLET > p
Definition: eagle_parser.h:114
ECOORD x
Definition: eagle_parser.h:649
bool m_isAvailable
A boolean indicating if the data is present or not.
Definition: eagle_parser.h:194
std::map< std::string, std::string > attribute
Definition: eagle_parser.h:917
wxSize ConvertSize() const
Calculate text size based on font type and size.
Class OPTIONAL_XML_ATTRIBUTE models an optional XML attribute.
Definition: eagle_parser.h:190
ECOORD size
Definition: eagle_parser.h:651
EDEVICE_SET(wxXmlNode *aDeviceSet)
int layer
Definition: eagle_parser.h:720
opt_int swaplevel
Definition: eagle_parser.h:970
opt_wxString value
Definition: eagle_parser.h:606
wxString text
Definition: eagle_parser.h:648
std::map< wxString, EINSTANCE * > EINSTANCE_MAP
Definition: eagle_parser.h:52
EVIA(wxXmlNode *aVia)
wxString name
Definition: eagle_parser.h:963
EGATE(wxXmlNode *aGate)
ECOORD x
Definition: eagle_parser.h:804
opt_int roundness
Definition: eagle_parser.h:721
mils/thous
Definition: eagle_parser.h:402
LAYER_NUM layer
Definition: eagle_parser.h:577
Eagle XML rectangle in binary.
Definition: eagle_parser.h:584
opt_int align
Definition: eagle_parser.h:671
Eagle net.
Definition: eagle_parser.h:462
opt_double curve
range is -359.9..359.9
Definition: eagle_parser.h:751
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
millimeters
Definition: eagle_parser.h:400
ECOORD y2
Definition: eagle_parser.h:505
opt_wxString prefix
Class EATTR parses an Eagle "attribute" XML element.
Definition: eagle_parser.h:603
opt_ecoord x
Definition: eagle_parser.h:607
opt_int layer
Definition: eagle_parser.h:610
Eagle via.
Definition: eagle_parser.h:556
bool operator==(const T &aOther) const
Equal operator to an object of the base type.
Definition: eagle_parser.h:279
ECOORD x1
Definition: eagle_parser.h:586
opt_wxString dimensionType
Definition: eagle_parser.h:639
opt_int addlevel
Definition: eagle_parser.h:969
EPAD_COMMON(wxXmlNode *aPad)
opt_erot rot
Definition: eagle_parser.h:655
int netcode
Definition: eagle_parser.h:464
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Function MapChildren provides an easy access to the children of an XML node via their names.
Board layer functions and definitions.
opt_wxString font
Definition: eagle_parser.h:653
ECOORD x
Definition: eagle_parser.h:749
opt_ecoord diameter
Definition: eagle_parser.h:697
std::map< wxString, std::unique_ptr< EPART > > EPART_MAP
Definition: eagle_parser.h:53
TRIPLET(const char *aElement, const char *aAttribute="", const char *aValue="")
Definition: eagle_parser.h:91
Structure holding common properties for through-hole and SMD pads.
Definition: eagle_parser.h:681
T m_data
The actual data if m_isAvailable is true; otherwise, garbage.
Definition: eagle_parser.h:197
OPTIONAL_XML_ATTRIBUTE(const wxString &aData)
Constructor OPTIONAL_XML_ATTRIBUTE.
Definition: eagle_parser.h:215
wxString netname
Definition: eagle_parser.h:465
ECOORD radius
Definition: eagle_parser.h:575
std::vector< ECONNECT > connects
opt_double ratio
Definition: eagle_parser.h:611
opt_erot rot
Definition: eagle_parser.h:685
ECOORD x
Definition: eagle_parser.h:966
ECOORD y
Definition: eagle_parser.h:559
opt_bool smashed
Definition: eagle_parser.h:942
The common library.
ECOORD x
Definition: eagle_parser.h:533
ECOORD(int aValue, enum EAGLE_UNIT aUnit)
Definition: eagle_parser.h:416
LAYER_NUM layer
Definition: eagle_parser.h:546
opt_bool first
Definition: eagle_parser.h:709
Eagle wire.
Definition: eagle_parser.h:500
opt_bool orphans
Definition: eagle_parser.h:778
opt_bool uservalue
ECOORD x
Definition: eagle_parser.h:558
T Convert(const wxString &aValue)
Function Convert converts a wxString to a generic type T.
Definition: eagle_parser.h:175
ECOORD y
Definition: eagle_parser.h:733
ERECT(wxXmlNode *aRect)
wxString name
Definition: eagle_parser.h:731
opt_wxString package
opt_erot rot
Definition: eagle_parser.h:943
opt_int shape
Definition: eagle_parser.h:708
Eagle dimension element.
Definition: eagle_parser.h:629
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:50
wxString package
Definition: eagle_parser.h:802
bool spin
Definition: eagle_parser.h:482
ECOORD y
Definition: eagle_parser.h:941
ECOORD y2
Definition: eagle_parser.h:589
EROT(double aDegrees)
Definition: eagle_parser.h:491
ECOORD y
Definition: eagle_parser.h:650
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:758
opt_int display
Definition: eagle_parser.h:620
void pop()
Definition: eagle_parser.h:124
ECOORD drill
Definition: eagle_parser.h:696
ECOORD y
Definition: eagle_parser.h:790
const char * value
Definition: eagle_parser.h:89
ENET(int aNetCode, const wxString &aNetName)
Definition: eagle_parser.h:467
opt_bool stop
Definition: eagle_parser.h:686
int layer
Definition: eagle_parser.h:652
wxString device
Definition: eagle_parser.h:914
ECOORD x1
Definition: eagle_parser.h:502
const char * attribute
Definition: eagle_parser.h:88
int ToMils() const
Definition: eagle_parser.h:423
wxString library
Definition: eagle_parser.h:801
XML_PARSER_ERROR(const wxString &aMessage) noexcept
Constructor XML_PARSER_ERROR build an XML error by just calling its parent class constructor,...
Definition: eagle_parser.h:78
ECIRCLE(wxXmlNode *aCircle)
opt_wxString visible
Definition: eagle_parser.h:735
ECOORD drill
Definition: eagle_parser.h:791
ETEXT(wxXmlNode *aText)
EELEMENT(wxXmlNode *aElement)
wxString pin
Definition: eagle_parser.h:997
opt_wxString length
Definition: eagle_parser.h:736
int color
Definition: eagle_parser.h:818
static long long int ConvertToNm(int aValue, enum EAGLE_UNIT aUnit)
Converts a size expressed in a certain unit to nanometers.
Class DIMENSION.
opt_bool active
Definition: eagle_parser.h:821
ECOORD x2
Definition: eagle_parser.h:504
OPTIONAL_XML_ATTRIBUTE< ECOORD > opt_ecoord
Definition: eagle_parser.h:385
int ToPcbUnits() const
Definition: eagle_parser.h:439
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:48
long long int value
Value expressed in nanometers
Definition: eagle_parser.h:406
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
Definition: eagle_parser.h:58
OPTIONAL_XML_ATTRIBUTE< EROT > opt_erot
Definition: eagle_parser.h:384
EINSTANCE(wxXmlNode *aInstance)
opt_ecoord size
Definition: eagle_parser.h:609
EPAD(wxXmlNode *aPad)
void Value(const char *aValue)
modify the last path node's value
Definition: eagle_parser.h:127
int layer_front_most
Definition: eagle_parser.h:560
ECOORD y
Definition: eagle_parser.h:967
opt_bool cream
Definition: eagle_parser.h:722
opt_bool locked
Definition: eagle_parser.h:806
opt_erot rot
Definition: eagle_parser.h:740