##// END OF EJS Templates
Sync
jeandet -
r3:e85fcd939626 default
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,147
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 const char* add_net_c = "(add_net";
23 const char* area_c = "(area";
24 const char* at_c = "(at";
25 const char* attr_c = "(attr";
26 const char* center_c = "(center";
27 const char* clearance_c = "(clearance";
28 const char* code_c = "(code";
29 const char* component_c = "(component";
30 const char* components_c = "(components";
31 const char* date_c = "(date";
32 const char* design_c = "(design";
33 const char* drawings_c = "(drawings";
34 const char* drillshape_c = "(drillshape";
35 const char* edge_width_c = "(edge_width";
36 const char* effects_c = "(effects";
37 const char* end_c = "(end";
38 const char* excludeedgelayer_c = "(excludeedgelayer";
39 const char* export_c = "(export";
40 const char* field_c = "(field";
41 const char* fields_c = "(fields";
42 const char* font_c = "(font";
43 const char* fp_circle_c = "(fp_circle";
44 const char* fp_line_c = "(fp_line";
45 const char* fp_text_c = "(fp_text";
46 const char* general_c = "(general";
47 const char* host_c = "(host";
48 const char* hpglpendiameter_c = "(hpglpendiameter";
49 const char* hpglpennumber_c = "(hpglpennumber";
50 const char* hpglpenoverlay_c = "(hpglpenoverlay";
51 const char* hpglpenspeed_c = "(hpglpenspeed";
52 const char* last_trace_width_c = "(last_trace_width";
53 const char* layers_c = "(layers";
54 const char* layerselection_c = "(layerselection";
55 const char* lib_c = "(lib";
56 const char* libpart_c = "(libpart";
57 const char* libparts_c = "(libparts";
58 const char* libraries_c = "(libraries";
59 const char* library_c = "(library";
60 const char* libsource_c = "(libsource";
61 const char* linewidth_c = "(linewidth";
62 const char* links_c = "(links";
63 const char* logical_c = "(logical";
64 const char* mirror_c = "(mirror";
65 const char* mod_edge_width_c = "(mod_edge_width";
66 const char* mod_text_size_c = "(mod_text_size";
67 const char* mode_c = "(mode";
68 const char* model_c = "(model";
69 const char* module_c = "(module";
70 const char* modules_c = "(modules";
71 const char* name_c = "(name";
72 const char* names_c = "(names";
73 const char* net_c = "(net";
74 const char* net_class_c = "(net_class";
75 const char* nets_c = "(nets";
76 const char* no_connect_c = "(no_connect";
77 const char* node_c = "(node";
78 const char* num_c = "(num";
79 const char* outputdirectory_c = "(outputdirectory";
80 const char* outputformat_c = "(outputformat";
81 const char* pad_c = "(pad";
82 const char* pad_drill_c = "(pad_drill";
83 const char* pad_size_c = "(pad_size";
84 const char* pad_to_mask_clearance_c = "(pad_to_mask_clearance";
85 const char* padsonsilk_c = "(padsonsilk";
86 const char* page_c = "(page";
87 const char* part_c = "(part";
88 const char* path_c = "(path";
89 const char* pcb_text_size_c = "(pcb_text_size";
90 const char* pcb_text_width_c = "(pcb_text_width";
91 const char* pcbplotparams_c = "(pcbplotparams";
92 const char* pin_c = "(pin";
93 const char* pins_c = "(pins";
94 const char* plotframeref_c = "(plotframeref";
95 const char* plotinvisibletext_c = "(plotinvisibletext";
96 const char* plotothertext_c = "(plotothertext";
97 const char* plotreference_c = "(plotreference";
98 const char* plotvalue_c = "(plotvalue";
99 const char* psa4output_c = "(psa4output";
100 const char* psnegative_c = "(psnegative";
101 const char* ref_c = "(ref";
102 const char* rotate = "(rota";
103 const char* scale_c = "(scale";
104 const char* scaleselection_c = "(scaleselection";
105 const char* segment_width_c = "(segment_width";
106 const char* setup_c = "(setup";
107 const char* sheetpath_c = "(sheetpath";
108 const char* source_c = "(source";
109 const char* start_c = "(start";
110 const char* subtractmaskfromsilk_c = "(subtractmaskfromsilk";
111 const char* tags_c = "(tags";
112 const char* tedit_c = "(tedit";
113 const char* thickness_c = "(thickness";
114 const char* tool_c = "(tool";
115 const char* trace_clearance_c = "(trace_clearance";
116 const char* trace_min_c = "(trace_min";
117 const char* trace_width_c = "(trace_width";
118 const char* tracks_c = "(tracks";
119 const char* tstamp_c = "(tstamp";
120 const char* tstamps_c = "(tstamps";
121 const char* type_c = "(type";
122 const char* uri_c = "(uri";
123 const char* useauxorigin_c = "(useauxorigin";
124 const char* usegerberextensions_c = "(usegerberextensions";
125 const char* uvia_dia_c = "(uvia_dia";
126 const char* uvia_drill_c = "(uvia_drill";
127 const char* uvia_min_drill_c = "(uvia_min_drill";
128 const char* uvia_min_size_c = "(uvia_min_size";
129 const char* uvia_size_c = "(uvia_size";
130 const char* uvias_allowed_c = "(uvias_allowed";
131 const char* value_c = "(value";
132 const char* version_c = "(version";
133 const char* via_dia_c = "(via_dia";
134 const char* via_drill_c = "(via_drill";
135 const char* via_min_drill_c = "(via_min_drill";
136 const char* via_min_size_c = "(via_min_size";
137 const char* via_size_c = "(via_size";
138 const char* viasonmask_c = "(viasonmask";
139 const char* visible_elements_c = "(visible_elements";
140 const char* width_c = "(width";
141 const char* xyz = "(x";
142 const char* zone_45_only_c = "(zone_45_only";
143 const char* zone_clearance_c = "(zone_clearance";
144 const char* zones_c = "(zones";
145
146
147
@@ -0,0 +1,158
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 /*
23 * Have a look to LispLikeLexique.ods
24 */
25 #ifndef LEXIQUE_H
26 #define LEXIQUE_H
27
28 namespace QIlib{
29
30 namespace Lexique
31 {
32 extern "C" const char* add_net_c;
33 extern "C" const char* area_c;
34 extern "C" const char* at_c;
35 extern "C" const char* attr_c;
36 extern "C" const char* center_c;
37 extern "C" const char* clearance_c;
38 extern "C" const char* code_c;
39 extern "C" const char* component_c;
40 extern "C" const char* components_c;
41 extern "C" const char* date_c;
42 extern "C" const char* design_c;
43 extern "C" const char* drawings_c;
44 extern "C" const char* drillshape_c;
45 extern "C" const char* edge_width_c;
46 extern "C" const char* effects_c;
47 extern "C" const char* end_c;
48 extern "C" const char* excludeedgelayer_c;
49 extern "C" const char* export_c;
50 extern "C" const char* field_c;
51 extern "C" const char* fields_c;
52 extern "C" const char* font_c;
53 extern "C" const char* fp_circle_c;
54 extern "C" const char* fp_line_c;
55 extern "C" const char* fp_text_c;
56 extern "C" const char* general_c;
57 extern "C" const char* host_c;
58 extern "C" const char* hpglpendiameter_c;
59 extern "C" const char* hpglpennumber_c;
60 extern "C" const char* hpglpenoverlay_c;
61 extern "C" const char* hpglpenspeed_c;
62 extern "C" const char* last_trace_width_c;
63 extern "C" const char* layers_c;
64 extern "C" const char* layerselection_c;
65 extern "C" const char* lib_c;
66 extern "C" const char* libpart_c;
67 extern "C" const char* libparts_c;
68 extern "C" const char* libraries_c;
69 extern "C" const char* library_c;
70 extern "C" const char* libsource_c;
71 extern "C" const char* linewidth_c;
72 extern "C" const char* links_c;
73 extern "C" const char* logical_c;
74 extern "C" const char* mirror_c;
75 extern "C" const char* mod_edge_width_c;
76 extern "C" const char* mod_text_size_c;
77 extern "C" const char* mode_c;
78 extern "C" const char* model_c;
79 extern "C" const char* module_c;
80 extern "C" const char* modules_c;
81 extern "C" const char* name_c;
82 extern "C" const char* names_c;
83 extern "C" const char* net_c;
84 extern "C" const char* net_class_c;
85 extern "C" const char* nets_c;
86 extern "C" const char* no_connect_c;
87 extern "C" const char* node_c;
88 extern "C" const char* num_c;
89 extern "C" const char* outputdirectory_c;
90 extern "C" const char* outputformat_c;
91 extern "C" const char* pad_c;
92 extern "C" const char* pad_drill_c;
93 extern "C" const char* pad_size_c;
94 extern "C" const char* pad_to_mask_clearance_c;
95 extern "C" const char* padsonsilk_c;
96 extern "C" const char* page_c;
97 extern "C" const char* part_c;
98 extern "C" const char* path_c;
99 extern "C" const char* pcb_text_size_c;
100 extern "C" const char* pcb_text_width_c;
101 extern "C" const char* pcbplotparams_c;
102 extern "C" const char* pin_c;
103 extern "C" const char* pins_c;
104 extern "C" const char* plotframeref_c;
105 extern "C" const char* plotinvisibletext_c;
106 extern "C" const char* plotothertext_c;
107 extern "C" const char* plotreference_c;
108 extern "C" const char* plotvalue_c;
109 extern "C" const char* psa4output_c;
110 extern "C" const char* psnegative_c;
111 extern "C" const char* ref_c;
112 extern "C" const char* rotate;
113 extern "C" const char* scale_c;
114 extern "C" const char* scaleselection_c;
115 extern "C" const char* segment_width_c;
116 extern "C" const char* setup_c;
117 extern "C" const char* sheetpath_c;
118 extern "C" const char* source_c;
119 extern "C" const char* start_c;
120 extern "C" const char* subtractmaskfromsilk_c;
121 extern "C" const char* tags_c;
122 extern "C" const char* tedit_c;
123 extern "C" const char* thickness_c;
124 extern "C" const char* tool_c;
125 extern "C" const char* trace_clearance_c;
126 extern "C" const char* trace_min_c;
127 extern "C" const char* trace_width_c;
128 extern "C" const char* tracks_c;
129 extern "C" const char* tstamp_c;
130 extern "C" const char* tstamps_c;
131 extern "C" const char* type_c;
132 extern "C" const char* uri_c;
133 extern "C" const char* useauxorigin_c;
134 extern "C" const char* usegerberextensions_c;
135 extern "C" const char* uvia_dia_c;
136 extern "C" const char* uvia_drill_c;
137 extern "C" const char* uvia_min_drill_c;
138 extern "C" const char* uvia_min_size_c;
139 extern "C" const char* uvia_size_c;
140 extern "C" const char* uvias_allowed_c;
141 extern "C" const char* value_c;
142 extern "C" const char* version_c;
143 extern "C" const char* via_dia_c;
144 extern "C" const char* via_drill_c;
145 extern "C" const char* via_min_drill_c;
146 extern "C" const char* via_min_size_c;
147 extern "C" const char* via_size_c;
148 extern "C" const char* viasonmask_c;
149 extern "C" const char* visible_elements_c;
150 extern "C" const char* width_c;
151 extern "C" const char* xyz;
152 extern "C" const char* zone_45_only_c;
153 extern "C" const char* zone_clearance_c;
154 extern "C" const char* zones_c;
155 }
156 }
157
158 #endif // LEXIQUE_H
@@ -0,0 +1,39
1 #include "qicadpcb.h"
2
3
4 QIlib::QIcadPcb::QIcadPcb()
5 {
6
7 }
8
9 bool QIlib::QIcadPcb::parsePcb(const QString &pcb)
10 {
11 parse(pcb.toStdString().c_str());
12 updateConcreteTree();
13 return false;
14 }
15
16 QString QIlib::QIcadPcb::toString()
17 {
18
19 }
20
21 QString QIlib::QIcadPcb::print()
22 {
23 return rootNode.print();
24 }
25
26
27 void QIlib::QIcadPcb::updateConcreteTree()
28 {
29 // if(this->rootNode.nodes.count())
30 // {
31 // if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::root_c)
32 // {
33 // if(this->netlistRoot==NULL)
34 // {
35 // this->netlistRoot = new QIcadNetListRoot(this->rootNode.nodes.at(0));
36 // }
37 // }
38 // }
39 }
@@ -0,0 +1,56
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #ifndef QICADPCB_H
23 #define QICADPCB_H
24 #include <QString>
25 #include <QStringList>
26 #include <QList>
27 #include <QFile>
28 #include <parsers/lispLike_driver.h>
29 #include <qicadlisplikelexique.h>
30
31 namespace QIlib{
32
33 class QIcadPcbRoot : public QIcadAbstractNodeWrapper
34 {
35 public:
36 QIcadPcbRoot(QIlib::AbstractNode* node);
37 QIcadAbstractNodeWrapper version;
38 QIcadAbstractNodeWrapper host;
39 void setNode(QIlib::AbstractNode* node);
40 };
41
42 class QIcadPcb : private lispLike_Driver
43 {
44 public:
45 QIcadPcb();
46 bool parsePcb(const QString& pcb);
47 QString toString();
48 QString fileName;
49 QString print();
50 private:
51 void updateConcreteTree();
52 };
53
54
55 }
56 #endif // QICADPCB_H
@@ -1,75 +1,75
1 %{
1 %{
2 /* C++ string header, for string ops below */
2 /* C++ string header, for string ops below */
3 #include <string>
3 #include <string>
4 #include <QString>
4 #include <QString>
5 /* Implementation of yyFlexScanner */
5 /* Implementation of yyFlexScanner */
6 #include "lispLike_scanner.h"
6 #include "lispLike_scanner.h"
7 #include "lispLike.hpp"
7 #include "lispLike.hpp"
8
8
9 /* typedef to make the returns for the tokens shorter */
9 /* typedef to make the returns for the tokens shorter */
10 typedef QIlib::lispLike_Parser::token token;
10 typedef QIlib::lispLike_Parser::token token;
11
11
12 /* define to keep from re-typing the same code over and over */
12 /* define to keep from re-typing the same code over and over */
13 #define STOKEN( x ) ( new QString( x ) )
13 #define STOKEN( x ) ( new QString( x ) )
14
14
15 /* define yyterminate as this instead of NULL */
15 /* define yyterminate as this instead of NULL */
16 //#define yyterminate() return( token::END )
16 //#define yyterminate() return( token::END )
17
17
18 /* msvc2010 requires that we exclude this header file. */
18 /* msvc2010 requires that we exclude this header file. */
19 #define YY_NO_UNISTD_H
19 #define YY_NO_UNISTD_H
20 %}
20 %}
21
21
22 %option debug
22 %option debug
23 %option nodefault
23 %option nodefault
24 %option yyclass="lispLike_Scanner"
24 %option yyclass="lispLike_Scanner"
25 %option noyywrap
25 %option noyywrap
26 %option c++
26 %option c++
27
27
28
28
29 /* . { return yytext[0]; }*/
29 /* . { return yytext[0]; }*/
30
30
31 %%
31 %%
32
32
33 [ \t\n]+ { }
33 [ \t\n]+ { }
34
34
35
35
36 \"[a-zA-Z0-9\-\/\(\)\. \:]+\" {
36 \"[a-zA-Z0-9\-\/\(\)\. \:]+\" {
37 yylval->sval = STOKEN( yytext );
37 yylval->sval = STOKEN( yytext );
38 return( token::VALUE );
38 return( token::VALUE );
39 }
39 }
40
40
41 \([a-zA-Z0-9]+ {
41 \([a-zA-Z0-9\_]+ {
42 yylval->sval = STOKEN( yytext );
42 yylval->sval = STOKEN( yytext );
43 return( token::NODE );
43 return( token::NODE );
44 }
44 }
45
45
46
46
47 \) {
47 \) {
48 return( token::CLOSENODE );
48 return( token::CLOSENODE );
49 }
49 }
50
50
51
51
52 [a-zA-Z0-9\-\/\.\_\~\?\*]+ {
52 [a-zA-Z0-9\-\/\.\_\~\?\*]+ {
53 yylval->sval = STOKEN( yytext );
53 yylval->sval = STOKEN( yytext );
54 return( token::VALUE );
54 return( token::VALUE );
55 }
55 }
56
56
57
57
58
58
59 \"\" {
59 \"\" {
60 yylval->sval = STOKEN( yytext );
60 yylval->sval = STOKEN( yytext );
61 return( token::VALUE );
61 return( token::VALUE );
62 }
62 }
63
63
64
64
65 .|\n {}
65 .|\n {}
66
66
67
67
68 %%
68 %%
69
69
70
70
71
71
72
72
73
73
74
74
75
75
@@ -1,154 +1,202
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/
22 /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/
23 #include "lispLike_driver.h"
23 #include "lispLike_driver.h"
24 #include<assert.h>
24 #include<assert.h>
25
25
26
27 QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node)
28 {
29 this->p_node = node;
30 }
31
32 QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper()
33 {
34 /*First delete all the childs*/
35 for(int i=0;i<this->childs.count();i++)
36 {
37 if(this->childs.at(i))
38 delete this->childs.at(i);
39 }
40 }
41
42 QString QIlib::QIcadAbstractNodeWrapper::value()
43 {
44 if((p_node->Values.count()>0) && p_node)
45 return p_node->Values.at(0);
46 return QString("");
47 }
48
49 QString QIlib::QIcadAbstractNodeWrapper::value(int index)
50 {
51 if((p_node->Values.count()>index) && p_node)
52 return p_node->Values.at(index);
53 return QString("");
54 }
55
56 QString QIlib::QIcadAbstractNodeWrapper::catValues()
57 {
58 if(p_node)
59 {
60 QString result("");
61 for(int i=0;i<p_node->Values.count();i++)
62 {
63 result.append(p_node->Values.at(i));
64 }
65 return result;
66 }
67 }
68
69 void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node)
70 {
71 this->p_node = node;
72 }
73
26 QIlib::lispLike_Driver::lispLike_Driver()
74 QIlib::lispLike_Driver::lispLike_Driver()
27 :parser( NULL ),scanner( NULL )
75 :parser( NULL ),scanner( NULL )
28 {
76 {
29 currentNode = &rootNode;
77 currentNode = &rootNode;
30 }
78 }
31
79
32 QIlib::lispLike_Driver::~lispLike_Driver()
80 QIlib::lispLike_Driver::~lispLike_Driver()
33 {
81 {
34 delete(scanner);
82 delete(scanner);
35 scanner = NULL;
83 scanner = NULL;
36 delete(parser);
84 delete(parser);
37 parser = NULL;
85 parser = NULL;
38 }
86 }
39
87
40 bool QIlib::lispLike_Driver::parse(const char *filename)
88 bool QIlib::lispLike_Driver::parse(const char *filename)
41 {
89 {
42 if(filename!=NULL)
90 if(filename!=NULL)
43 {
91 {
44 std::ifstream in_file( filename );
92 std::ifstream in_file( filename );
45 if( ! in_file.good() ) return false;
93 if( ! in_file.good() ) return false;
46
94
47 delete(scanner);
95 delete(scanner);
48 try
96 try
49 {
97 {
50 scanner = new QIlib::lispLike_Scanner( &in_file );
98 scanner = new QIlib::lispLike_Scanner( &in_file );
51 }
99 }
52 catch( std::bad_alloc &ba )
100 catch( std::bad_alloc &ba )
53 {
101 {
54 std::cerr << "Failed to allocate scanner: (" <<
102 std::cerr << "Failed to allocate scanner: (" <<
55 ba.what() << ")\n";
103 ba.what() << ")\n";
56 return false;
104 return false;
57 }
105 }
58
106
59 delete(parser);
107 delete(parser);
60 try
108 try
61 {
109 {
62 parser = new QIlib::lispLike_Parser( (*scanner) /* scanner */,
110 parser = new QIlib::lispLike_Parser( (*scanner) /* scanner */,
63 (*this) /* driver */ );
111 (*this) /* driver */ );
64 }
112 }
65 catch( std::bad_alloc &ba )
113 catch( std::bad_alloc &ba )
66 {
114 {
67 std::cerr << "Failed to allocate parser: (" <<
115 std::cerr << "Failed to allocate parser: (" <<
68 ba.what() << ")\n";
116 ba.what() << ")\n";
69 return false;
117 return false;
70 }
118 }
71 const int accept( 0 );
119 const int accept( 0 );
72 if( parser->parse() != accept )
120 if( parser->parse() != accept )
73 {
121 {
74 std::cerr << "Parse failed!!\n";
122 std::cerr << "Parse failed!!\n";
75 return false;
123 return false;
76 }
124 }
77 return true;
125 return true;
78 }
126 }
79 return false;
127 return false;
80 }
128 }
81
129
82 void QIlib::lispLike_Driver::add_node(const QString &node)
130 void QIlib::lispLike_Driver::add_node(const QString &node)
83 {
131 {
84 QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,currentNode);
132 QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,currentNode);
85 currentNode = newNode;
133 currentNode = newNode;
86 }
134 }
87
135
88 void QIlib::lispLike_Driver::add_node(const QString &node, const QString &value)
136 void QIlib::lispLike_Driver::add_node(const QString &node, const QString &value)
89 {
137 {
90 QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,value,currentNode);
138 QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,value,currentNode);
91 currentNode = newNode;
139 currentNode = newNode;
92 }
140 }
93
141
94 void QIlib::lispLike_Driver::add_value(const QString &value)
142 void QIlib::lispLike_Driver::add_value(const QString &value)
95 {
143 {
96 currentNode->Values.append(value);
144 currentNode->Values.append(value);
97 }
145 }
98
146
99 void QIlib::lispLike_Driver::close_node()
147 void QIlib::lispLike_Driver::close_node()
100 {
148 {
101 if(currentNode->parent)
149 if(currentNode->parent)
102 currentNode = currentNode->parent;
150 currentNode = currentNode->parent;
103 }
151 }
104
152
105
153
106
154
107
155
108
156
109
157
110
158
111
159
112
160
113
161
114 QIlib::AbstractNode::AbstractNode(QIlib::AbstractNode *parent)
162 QIlib::AbstractNode::AbstractNode(QIlib::AbstractNode *parent)
115 {
163 {
116 this->parent =parent;
164 this->parent =parent;
117 if(parent)
165 if(parent)
118 parent->nodes.append(this);
166 parent->nodes.append(this);
119 }
167 }
120
168
121
169
122 QIlib::AbstractNode::AbstractNode(const QString &Name, QIlib::AbstractNode *parent)
170 QIlib::AbstractNode::AbstractNode(const QString &Name, QIlib::AbstractNode *parent)
123 :name(Name)
171 :name(Name)
124 {
172 {
125 this->parent = parent;
173 this->parent = parent;
126 if(parent)
174 if(parent)
127 parent->nodes.append(this);
175 parent->nodes.append(this);
128 }
176 }
129
177
130
178
131 QIlib::AbstractNode::AbstractNode(const QString &Name, const QString &Value, QIlib::AbstractNode *parent)
179 QIlib::AbstractNode::AbstractNode(const QString &Name, const QString &Value, QIlib::AbstractNode *parent)
132 :name(Name)
180 :name(Name)
133 {
181 {
134 this->parent = parent;
182 this->parent = parent;
135 if(parent)
183 if(parent)
136 parent->nodes.append(this);
184 parent->nodes.append(this);
137 Values.append(Value);
185 Values.append(Value);
138 }
186 }
139
187
140 QString QIlib::AbstractNode::print()
188 QString QIlib::AbstractNode::print()
141 {
189 {
142 QString result;
190 QString result;
143 result.append(this->name+" ");
191 result.append(this->name+" ");
144 for(int i=0;i<this->nodes.count();i++)
192 for(int i=0;i<this->nodes.count();i++)
145 {
193 {
146 result.append(this->nodes.at(i)->print());
194 result.append(this->nodes.at(i)->print());
147 }
195 }
148 for(int i=0;i<this->Values.count();i++)
196 for(int i=0;i<this->Values.count();i++)
149 {
197 {
150 result.append(Values.at(i)+" ");
198 result.append(Values.at(i)+" ");
151 }
199 }
152 result.append(")");
200 result.append(")");
153 return result;
201 return result;
154 }
202 }
@@ -1,70 +1,86
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef LISPLIKE_DRIVER_H
22 #ifndef LISPLIKE_DRIVER_H
23 #define LISPLIKE_DRIVER_H
23 #define LISPLIKE_DRIVER_H
24 #include <string>
24 #include <string>
25 #include "lispLike_scanner.h"
25 #include "lispLike_scanner.h"
26 #include <lispLike/lispLike.hpp>
26 #include <lispLike/lispLike.hpp>
27 #include <QString>
27 #include <QString>
28 #include <QList>
28 #include <QList>
29 #include <QStringList>
29 #include <QStringList>
30 #include <iostream>
30 #include <iostream>
31 #include <cstdlib>
31 #include <cstdlib>
32 #include <fstream>
32 #include <fstream>
33
33
34 namespace QIlib{
34 namespace QIlib{
35
35
36 class AbstractNode
36 class AbstractNode
37 {
37 {
38 public:
38 public:
39 AbstractNode( QIlib::AbstractNode* parent=NULL);
39 AbstractNode( QIlib::AbstractNode* parent=NULL);
40 AbstractNode(const QString& Name, QIlib::AbstractNode* parent=NULL);
40 AbstractNode(const QString& Name, QIlib::AbstractNode* parent=NULL);
41 AbstractNode(const QString& Name,const QString& Value, QIlib::AbstractNode* parent=NULL);
41 AbstractNode(const QString& Name,const QString& Value, QIlib::AbstractNode* parent=NULL);
42 QString print();
42 QString print();
43 QList<QIlib::AbstractNode*> nodes;
43 QList<QIlib::AbstractNode*> nodes;
44 QString name;
44 QString name;
45 QStringList Values;
45 QStringList Values;
46 QIlib::AbstractNode* parent;
46 QIlib::AbstractNode* parent;
47 };
47 };
48
48
49 class QIcadAbstractNodeWrapper
50 {
51 public:
52 QIcadAbstractNodeWrapper(QIlib::AbstractNode* node);
53 QIcadAbstractNodeWrapper(){}
54 ~QIcadAbstractNodeWrapper();
55 QString value();
56 QString value(int index);
57 QString catValues();
58 QList<QIcadAbstractNodeWrapper*> childs;
59 QIcadAbstractNodeWrapper* parent;
60 virtual void setNode(QIlib::AbstractNode* node);
61
62 QIlib::AbstractNode* p_node;
63 };
64
49 class lispLike_Driver
65 class lispLike_Driver
50 {
66 {
51 public:
67 public:
52 lispLike_Driver();
68 lispLike_Driver();
53
69
54 virtual ~lispLike_Driver();
70 virtual ~lispLike_Driver();
55 bool parse( const char *filename );
71 bool parse( const char *filename );
56 void add_node( const QString &node );
72 void add_node( const QString &node );
57 void add_node( const QString &node , const QString &value);
73 void add_node( const QString &node , const QString &value);
58 void add_value( const QString &value );
74 void add_value( const QString &value );
59 void close_node();
75 void close_node();
60
76
61
77
62 protected:
78 protected:
63
79
64 QIlib::lispLike_Parser *parser;
80 QIlib::lispLike_Parser *parser;
65 QIlib::lispLike_Scanner *scanner;
81 QIlib::lispLike_Scanner *scanner;
66 QIlib::AbstractNode rootNode;
82 QIlib::AbstractNode rootNode;
67 QIlib::AbstractNode* currentNode;
83 QIlib::AbstractNode* currentNode;
68 };
84 };
69 }
85 }
70 #endif // LISPLIKE_DRIVER_H
86 #endif // LISPLIKE_DRIVER_H
@@ -1,698 +1,617
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "qicadnetlist.h"
22 #include "qicadnetlist.h"
23 #include <QRegularExpression>
23 #include <QRegularExpression>
24
24
25
25
26 const char* root_c ="(export";
27 const char* version_c ="(version";
28 const char* design_c ="(design";
29 const char* source_c ="(source";
30 const char* date_c ="(date";
31 const char* tool_c ="(tool";
32 const char* components_c ="(components";
33 const char* component_c ="(comp";
34 const char* ref_c ="(ref";
35 const char* value_c ="(value";
36 const char* libsource_c ="(libsource";
37 const char* lib_c ="(lib";
38 const char* part_c ="(part";
39 const char* sheetpath_c ="(sheetpath";
40 const char* names_c ="(names";
41 const char* tstamps_c ="(tstamps";
42 const char* tstamp_c ="(tstamp";
43 const char* libparts_c ="(libparts";
44 const char* libpart_c ="(libpart";
45 const char* fields_c ="(fields";
46 const char* field_c ="(field";
47 const char* name_c ="(name";
48 const char* pins_c ="(pins";
49 const char* pin_c ="(pin";
50 const char* num_c ="(num";
51 const char* type_c ="(type";
52 const char* libraries_c ="(libraries";
53 const char* library_c ="(library";
54 const char* logical_c ="(logical";
55 const char* uri_c ="(uri";
56 const char* nets_c ="(nets";
57 const char* net_c ="(net";
58 const char* code_c ="(code";
59 const char* node_c ="(node";
60
61
26
62 QIlib::QIcadNetList::QIcadNetList()
27 QIlib::QIcadNetList::QIcadNetList()
63 :netlistRoot(NULL)
28 :netlistRoot(NULL)
64 {
29 {
65
30
66 }
31 }
67
32
68
33
69 bool QIlib::QIcadNetList::parseNetList(const QString &netlist)
34 bool QIlib::QIcadNetList::parseNetList(const QString &netlist)
70 {
35 {
71
36
72 parse(netlist.toStdString().c_str());
37 parse(netlist.toStdString().c_str());
73 updateConcreteTree();
38 updateConcreteTree();
74 return false;
39 return false;
75 }
40 }
76
41
77 QString QIlib::QIcadNetList::print()
42 QString QIlib::QIcadNetList::print()
78 {
43 {
79 return rootNode.print();
44 return rootNode.print();
80 }
45 }
81
46
82 QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(const QString &node, int index)
47 QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(const QString &node, int index)
83 {
48 {
84 return getAbstractNode(&rootNode,node,&index);
49 return getAbstractNode(&rootNode,node,&index);
85 }
50 }
86
51
87 QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(QIlib::AbstractNode *rootNode, const QString &node, int* index)
52 QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(QIlib::AbstractNode *rootNode, const QString &node, int* index)
88 {
53 {
89 for(int i=0;i<rootNode->nodes.count();i++)
54 for(int i=0;i<rootNode->nodes.count();i++)
90 {
55 {
91 if(rootNode->nodes.at(i)->name==node)
56 if(rootNode->nodes.at(i)->name==node)
92 {
57 {
93 if((*index)==0)
58 if((*index)==0)
94 {
59 {
95 return rootNode->nodes.at(i);
60 return rootNode->nodes.at(i);
96 }
61 }
97 (*index)-=1;
62 (*index)-=1;
98 }
63 }
99 else
64 else
100 {
65 {
101 if(0<rootNode->nodes.at(i)->nodes.count())
66 if(0<rootNode->nodes.at(i)->nodes.count())
102 {
67 {
103 QIlib::AbstractNode *result=getAbstractNode(rootNode->nodes.at(i),node,index);
68 QIlib::AbstractNode *result=getAbstractNode(rootNode->nodes.at(i),node,index);
104 if(NULL!=result)return result;
69 if(NULL!=result)return result;
105 }
70 }
106 }
71 }
107 }
72 }
108 return NULL;
73 return NULL;
109 }
74 }
110
75
111
76
112 void QIlib::QIcadNetList::updateConcreteTree()
77 void QIlib::QIcadNetList::updateConcreteTree()
113 {
78 {
114 if(this->rootNode.nodes.count())
79 if(this->rootNode.nodes.count())
115 {
80 {
116 if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::root_c)
81 if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::export_c)
117 {
82 {
118 if(this->netlistRoot==NULL)
83 if(this->netlistRoot==NULL)
119 {
84 {
120 this->netlistRoot = new QIcadNetListRoot(this->rootNode.nodes.at(0));
85 this->netlistRoot = new QIcadNetListRoot(this->rootNode.nodes.at(0));
121 }
86 }
122 }
87 }
123 }
88 }
124 }
89 }
125
90
126
91
127
92
128 QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node)
129 {
130 this->p_node = node;
131 }
132
133 QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper()
134 {
135 /*First delete all the childs*/
136 for(int i=0;i<this->childs.count();i++)
137 {
138 if(this->childs.at(i))
139 delete this->childs.at(i);
140 }
141 }
142
143 QString QIlib::QIcadAbstractNodeWrapper::value()
144 {
145 if((p_node->Values.count()>0) && p_node)
146 return p_node->Values.at(0);
147 return QString("");
148 }
149
150 QString QIlib::QIcadAbstractNodeWrapper::value(int index)
151 {
152 if((p_node->Values.count()>index) && p_node)
153 return p_node->Values.at(index);
154 return QString("");
155 }
156
157 QString QIlib::QIcadAbstractNodeWrapper::catValues()
158 {
159 if(p_node)
160 {
161 QString result("");
162 for(int i=0;i<p_node->Values.count();i++)
163 {
164 result.append(p_node->Values.at(i));
165 }
166 return result;
167 }
168 }
169
170 void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node)
171 {
172 this->p_node = node;
173 }
174
93
175
94
176
95
177 QIlib::QIcadNetListRoot::QIcadNetListRoot(QIlib::AbstractNode *node)
96 QIlib::QIcadNetListRoot::QIcadNetListRoot(QIlib::AbstractNode *node)
178 :QIcadAbstractNodeWrapper(node)
97 :QIcadAbstractNodeWrapper(node)
179 {
98 {
180 this->setNode(node);
99 this->setNode(node);
181 }
100 }
182
101
183 void QIlib::QIcadNetListRoot::setNode(QIlib::AbstractNode *node)
102 void QIlib::QIcadNetListRoot::setNode(QIlib::AbstractNode *node)
184 {
103 {
185 this->p_node = node;
104 this->p_node = node;
186 if(node->name==QIlib::Lexique::root_c)
105 if(node->name==QIlib::Lexique::export_c)
187 {
106 {
188 for(int i=0;i<node->nodes.count();i++)
107 for(int i=0;i<node->nodes.count();i++)
189 {
108 {
190 if(node->nodes.at(i)->name==QIlib::Lexique::design_c)
109 if(node->nodes.at(i)->name==QIlib::Lexique::design_c)
191 {
110 {
192 this->design.setNode(node->nodes.at(i));
111 this->design.setNode(node->nodes.at(i));
193 }
112 }
194 if(node->nodes.at(i)->name==QIlib::Lexique::components_c)
113 if(node->nodes.at(i)->name==QIlib::Lexique::components_c)
195 {
114 {
196 this->setComponents(node->nodes.at(i));
115 this->setComponents(node->nodes.at(i));
197 }
116 }
198 if(node->nodes.at(i)->name==QIlib::Lexique::libparts_c)
117 if(node->nodes.at(i)->name==QIlib::Lexique::libparts_c)
199 {
118 {
200 this->setLibParts(node->nodes.at(i));
119 this->setLibParts(node->nodes.at(i));
201 }
120 }
202 if(node->nodes.at(i)->name==QIlib::Lexique::libraries_c)
121 if(node->nodes.at(i)->name==QIlib::Lexique::libraries_c)
203 {
122 {
204 this->setLibraries(node->nodes.at(i));
123 this->setLibraries(node->nodes.at(i));
205 }
124 }
206 if(node->nodes.at(i)->name==QIlib::Lexique::nets_c)
125 if(node->nodes.at(i)->name==QIlib::Lexique::nets_c)
207 {
126 {
208 this->setNets(node->nodes.at(i));
127 this->setNets(node->nodes.at(i));
209 }
128 }
210 }
129 }
211 }
130 }
212 }
131 }
213
132
214 void QIlib::QIcadNetListRoot::setComponents(QIlib::AbstractNode *node)
133 void QIlib::QIcadNetListRoot::setComponents(QIlib::AbstractNode *node)
215 {
134 {
216 while(components.count())
135 while(components.count())
217 {
136 {
218 QIcadNetListComponent* component;
137 QIcadNetListComponent* component;
219 component = components.last();
138 component = components.last();
220 components.removeLast();
139 components.removeLast();
221 delete component;
140 delete component;
222 }
141 }
223 apendComponents(node);
142 apendComponents(node);
224 }
143 }
225
144
226 void QIlib::QIcadNetListRoot::apendComponents(QIlib::AbstractNode *node)
145 void QIlib::QIcadNetListRoot::apendComponents(QIlib::AbstractNode *node)
227 {
146 {
228 if(node->name==QIlib::Lexique::components_c)
147 if(node->name==QIlib::Lexique::components_c)
229 {
148 {
230 for(int i=0;i<node->nodes.count();i++)
149 for(int i=0;i<node->nodes.count();i++)
231 {
150 {
232 if(node->nodes.at(i)->name==QIlib::Lexique::component_c)
151 if(node->nodes.at(i)->name==QIlib::Lexique::component_c)
233 {
152 {
234 this->components.append(new QIcadNetListComponent(node->nodes.at(i)));
153 this->components.append(new QIcadNetListComponent(node->nodes.at(i)));
235 }
154 }
236 }
155 }
237 }
156 }
238 }
157 }
239
158
240 void QIlib::QIcadNetListRoot::setLibParts(QIlib::AbstractNode *node)
159 void QIlib::QIcadNetListRoot::setLibParts(QIlib::AbstractNode *node)
241 {
160 {
242 while(libparts.count())
161 while(libparts.count())
243 {
162 {
244 QIcadNetListLibPart* libpart;
163 QIcadNetListLibPart* libpart;
245 libpart = libparts.last();
164 libpart = libparts.last();
246 libparts.removeLast();
165 libparts.removeLast();
247 delete libpart;
166 delete libpart;
248 }
167 }
249 apendLibParts(node);
168 apendLibParts(node);
250 }
169 }
251
170
252 void QIlib::QIcadNetListRoot::apendLibParts(QIlib::AbstractNode *node)
171 void QIlib::QIcadNetListRoot::apendLibParts(QIlib::AbstractNode *node)
253 {
172 {
254 if(node->name==QIlib::Lexique::libparts_c)
173 if(node->name==QIlib::Lexique::libparts_c)
255 {
174 {
256 for(int i=0;i<node->nodes.count();i++)
175 for(int i=0;i<node->nodes.count();i++)
257 {
176 {
258 if(node->nodes.at(i)->name==QIlib::Lexique::libpart_c)
177 if(node->nodes.at(i)->name==QIlib::Lexique::libpart_c)
259 {
178 {
260 this->libparts.append(new QIcadNetListLibPart(node->nodes.at(i)));
179 this->libparts.append(new QIcadNetListLibPart(node->nodes.at(i)));
261 }
180 }
262 }
181 }
263 }
182 }
264 }
183 }
265
184
266 void QIlib::QIcadNetListRoot::setLibraries(QIlib::AbstractNode *node)
185 void QIlib::QIcadNetListRoot::setLibraries(QIlib::AbstractNode *node)
267 {
186 {
268 while(libraries.count())
187 while(libraries.count())
269 {
188 {
270 QIcadNetListLibrary* lib;
189 QIcadNetListLibrary* lib;
271 lib = libraries.last();
190 lib = libraries.last();
272 libraries.removeLast();
191 libraries.removeLast();
273 delete lib;
192 delete lib;
274 }
193 }
275 apendLibraries(node);
194 apendLibraries(node);
276 }
195 }
277
196
278 void QIlib::QIcadNetListRoot::apendLibraries(QIlib::AbstractNode *node)
197 void QIlib::QIcadNetListRoot::apendLibraries(QIlib::AbstractNode *node)
279 {
198 {
280 if(node->name==QIlib::Lexique::libraries_c)
199 if(node->name==QIlib::Lexique::libraries_c)
281 {
200 {
282 for(int i=0;i<node->nodes.count();i++)
201 for(int i=0;i<node->nodes.count();i++)
283 {
202 {
284 if(node->nodes.at(i)->name==QIlib::Lexique::library_c)
203 if(node->nodes.at(i)->name==QIlib::Lexique::library_c)
285 {
204 {
286 this->libraries.append(new QIcadNetListLibrary(node->nodes.at(i)));
205 this->libraries.append(new QIcadNetListLibrary(node->nodes.at(i)));
287 }
206 }
288 }
207 }
289 }
208 }
290 }
209 }
291
210
292 void QIlib::QIcadNetListRoot::setNets(QIlib::AbstractNode *node)
211 void QIlib::QIcadNetListRoot::setNets(QIlib::AbstractNode *node)
293 {
212 {
294 while(nets.count())
213 while(nets.count())
295 {
214 {
296 QIcadNetListNet* net;
215 QIcadNetListNet* net;
297 net = nets.last();
216 net = nets.last();
298 nets.removeLast();
217 nets.removeLast();
299 delete net;
218 delete net;
300 }
219 }
301 apendNets(node);
220 apendNets(node);
302 }
221 }
303
222
304 void QIlib::QIcadNetListRoot::apendNets(QIlib::AbstractNode *node)
223 void QIlib::QIcadNetListRoot::apendNets(QIlib::AbstractNode *node)
305 {
224 {
306 if(node->name==QIlib::Lexique::nets_c)
225 if(node->name==QIlib::Lexique::nets_c)
307 {
226 {
308 for(int i=0;i<node->nodes.count();i++)
227 for(int i=0;i<node->nodes.count();i++)
309 {
228 {
310 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
229 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
311 {
230 {
312 this->nets.append(new QIcadNetListNet(node->nodes.at(i)));
231 this->nets.append(new QIcadNetListNet(node->nodes.at(i)));
313 }
232 }
314 }
233 }
315 }
234 }
316 }
235 }
317
236
318
237
319 QIlib::QIcadNetListComponent::QIcadNetListComponent(QIlib::AbstractNode *node)
238 QIlib::QIcadNetListComponent::QIcadNetListComponent(QIlib::AbstractNode *node)
320 :QIcadAbstractNodeWrapper(node)
239 :QIcadAbstractNodeWrapper(node)
321 {
240 {
322 setNode(node);
241 setNode(node);
323 }
242 }
324
243
325 void QIlib::QIcadNetListComponent::setNode(QIlib::AbstractNode *node)
244 void QIlib::QIcadNetListComponent::setNode(QIlib::AbstractNode *node)
326 {
245 {
327 if(node->name==QIlib::Lexique::component_c)
246 if(node->name==QIlib::Lexique::component_c)
328 {
247 {
329 for(int i=0;i<node->nodes.count();i++)
248 for(int i=0;i<node->nodes.count();i++)
330 {
249 {
331 if(node->nodes.at(i)->name==QIlib::Lexique::ref_c)
250 if(node->nodes.at(i)->name==QIlib::Lexique::ref_c)
332 {
251 {
333 this->ref.setNode(node->nodes.at(i));
252 this->ref.setNode(node->nodes.at(i));
334 }
253 }
335 if(node->nodes.at(i)->name==QIlib::Lexique::value_c)
254 if(node->nodes.at(i)->name==QIlib::Lexique::value_c)
336 {
255 {
337 this->value.setNode(node->nodes.at(i));
256 this->value.setNode(node->nodes.at(i));
338 }
257 }
339 if(node->nodes.at(i)->name==QIlib::Lexique::libsource_c)
258 if(node->nodes.at(i)->name==QIlib::Lexique::libsource_c)
340 {
259 {
341 this->libsource.setNode(node->nodes.at(i));
260 this->libsource.setNode(node->nodes.at(i));
342 }
261 }
343 if(node->nodes.at(i)->name==QIlib::Lexique::sheetpath_c)
262 if(node->nodes.at(i)->name==QIlib::Lexique::sheetpath_c)
344 {
263 {
345 this->sheetpath.setNode(node->nodes.at(i));
264 this->sheetpath.setNode(node->nodes.at(i));
346 }
265 }
347 if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c)
266 if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c)
348 {
267 {
349 this->tstamp.setNode(node->nodes.at(i));
268 this->tstamp.setNode(node->nodes.at(i));
350 }
269 }
351 }
270 }
352 }
271 }
353 }
272 }
354
273
355
274
356 QIlib::QIcadNetListDesign::QIcadNetListDesign(QIlib::AbstractNode *node)
275 QIlib::QIcadNetListDesign::QIcadNetListDesign(QIlib::AbstractNode *node)
357 :QIcadAbstractNodeWrapper(node)
276 :QIcadAbstractNodeWrapper(node)
358 {
277 {
359 this->setNode(node);
278 this->setNode(node);
360 }
279 }
361
280
362 void QIlib::QIcadNetListDesign::setNode(QIlib::AbstractNode *node)
281 void QIlib::QIcadNetListDesign::setNode(QIlib::AbstractNode *node)
363 {
282 {
364 if(node->name==QIlib::Lexique::design_c)
283 if(node->name==QIlib::Lexique::design_c)
365 {
284 {
366 this->p_node = node;
285 this->p_node = node;
367 for(int i=0;i<node->nodes.count();i++)
286 for(int i=0;i<node->nodes.count();i++)
368 {
287 {
369 if(node->nodes.at(i)->name==QIlib::Lexique::source_c)
288 if(node->nodes.at(i)->name==QIlib::Lexique::source_c)
370 {
289 {
371 this->source.setNode(node->nodes.at(i));
290 this->source.setNode(node->nodes.at(i));
372 }
291 }
373 if(node->nodes.at(i)->name==QIlib::Lexique::date_c)
292 if(node->nodes.at(i)->name==QIlib::Lexique::date_c)
374 {
293 {
375 this->date.setNode(node->nodes.at(i));
294 this->date.setNode(node->nodes.at(i));
376 }
295 }
377 if(node->nodes.at(i)->name==QIlib::Lexique::tool_c)
296 if(node->nodes.at(i)->name==QIlib::Lexique::tool_c)
378 {
297 {
379 this->tool.setNode(node->nodes.at(i));
298 this->tool.setNode(node->nodes.at(i));
380 }
299 }
381 }
300 }
382 }
301 }
383 }
302 }
384
303
385 QIlib::QIcadNetListLibPart::QIcadNetListLibPart(QIlib::AbstractNode *node)
304 QIlib::QIcadNetListLibPart::QIcadNetListLibPart(QIlib::AbstractNode *node)
386 {
305 {
387 setNode(node);
306 setNode(node);
388 }
307 }
389 /*
308 /*
390 (libparts
309 (libparts
391 (libpart (lib guan) (part 24L-MOD-8)
310 (libpart (lib guan) (part 24L-MOD-8)
392 (fields
311 (fields
393 (field (name Reference) IC)
312 (field (name Reference) IC)
394 (field (name Value) 24L-MOD-8))
313 (field (name Value) 24L-MOD-8))
395 (pins
314 (pins
396 (pin (num 1) (name GND) (type power_in))
315 (pin (num 1) (name GND) (type power_in))
397 (pin (num 2) (name VCC) (type power_in))
316 (pin (num 2) (name VCC) (type power_in))
398 */
317 */
399 void QIlib::QIcadNetListLibPart::setNode(QIlib::AbstractNode *node)
318 void QIlib::QIcadNetListLibPart::setNode(QIlib::AbstractNode *node)
400 {
319 {
401 if(node->name==QIlib::Lexique::libpart_c)
320 if(node->name==QIlib::Lexique::libpart_c)
402 {
321 {
403 this->p_node = node;
322 this->p_node = node;
404 for(int i=0;i<node->nodes.count();i++)
323 for(int i=0;i<node->nodes.count();i++)
405 {
324 {
406 if(node->nodes.at(i)->name==QIlib::Lexique::lib_c)
325 if(node->nodes.at(i)->name==QIlib::Lexique::lib_c)
407 {
326 {
408 this->lib.setNode(node->nodes.at(i));
327 this->lib.setNode(node->nodes.at(i));
409 }
328 }
410 if(node->nodes.at(i)->name==QIlib::Lexique::part_c)
329 if(node->nodes.at(i)->name==QIlib::Lexique::part_c)
411 {
330 {
412 this->part.setNode(node->nodes.at(i));
331 this->part.setNode(node->nodes.at(i));
413 }
332 }
414 if(node->nodes.at(i)->name==QIlib::Lexique::fields_c)
333 if(node->nodes.at(i)->name==QIlib::Lexique::fields_c)
415 {
334 {
416 setFields(node->nodes.at(i));
335 setFields(node->nodes.at(i));
417 }
336 }
418 if(node->nodes.at(i)->name==QIlib::Lexique::pins_c)
337 if(node->nodes.at(i)->name==QIlib::Lexique::pins_c)
419 {
338 {
420 setPins(node->nodes.at(i));
339 setPins(node->nodes.at(i));
421 }
340 }
422 }
341 }
423 }
342 }
424 }
343 }
425
344
426 void QIlib::QIcadNetListLibPart::setFields(QIlib::AbstractNode *node)
345 void QIlib::QIcadNetListLibPart::setFields(QIlib::AbstractNode *node)
427 {
346 {
428 while(fields.count())
347 while(fields.count())
429 {
348 {
430 QIcadNetListField* field;
349 QIcadNetListField* field;
431 field = fields.last();
350 field = fields.last();
432 fields.removeLast();
351 fields.removeLast();
433 delete field;
352 delete field;
434 }
353 }
435 apendFields(node);
354 apendFields(node);
436 }
355 }
437
356
438 void QIlib::QIcadNetListLibPart::apendFields(QIlib::AbstractNode *node)
357 void QIlib::QIcadNetListLibPart::apendFields(QIlib::AbstractNode *node)
439 {
358 {
440 if(node->name==QIlib::Lexique::fields_c)
359 if(node->name==QIlib::Lexique::fields_c)
441 {
360 {
442 for(int i=0;i<node->nodes.count();i++)
361 for(int i=0;i<node->nodes.count();i++)
443 {
362 {
444 if(node->nodes.at(i)->name==QIlib::Lexique::field_c)
363 if(node->nodes.at(i)->name==QIlib::Lexique::field_c)
445 {
364 {
446 this->fields.append(new QIcadNetListField(node->nodes.at(i)));
365 this->fields.append(new QIcadNetListField(node->nodes.at(i)));
447 }
366 }
448 }
367 }
449 }
368 }
450 }
369 }
451
370
452 void QIlib::QIcadNetListLibPart::setPins(QIlib::AbstractNode *node)
371 void QIlib::QIcadNetListLibPart::setPins(QIlib::AbstractNode *node)
453 {
372 {
454 while(pins.count())
373 while(pins.count())
455 {
374 {
456 QIcadNetListPin* pin;
375 QIcadNetListPin* pin;
457 pin = pins.last();
376 pin = pins.last();
458 pins.removeLast();
377 pins.removeLast();
459 delete pin;
378 delete pin;
460 }
379 }
461 apendPins(node);
380 apendPins(node);
462 }
381 }
463
382
464 void QIlib::QIcadNetListLibPart::apendPins(QIlib::AbstractNode *node)
383 void QIlib::QIcadNetListLibPart::apendPins(QIlib::AbstractNode *node)
465 {
384 {
466 if(node->name==QIlib::Lexique::pins_c)
385 if(node->name==QIlib::Lexique::pins_c)
467 {
386 {
468 for(int i=0;i<node->nodes.count();i++)
387 for(int i=0;i<node->nodes.count();i++)
469 {
388 {
470 if(node->nodes.at(i)->name==QIlib::Lexique::pin_c)
389 if(node->nodes.at(i)->name==QIlib::Lexique::pin_c)
471 {
390 {
472 this->pins.append(new QIcadNetListPin(node->nodes.at(i)));
391 this->pins.append(new QIcadNetListPin(node->nodes.at(i)));
473 }
392 }
474 }
393 }
475 }
394 }
476 }
395 }
477
396
478
397
479 QIlib::QIcadNetListLibrary::QIcadNetListLibrary(QIlib::AbstractNode *node)
398 QIlib::QIcadNetListLibrary::QIcadNetListLibrary(QIlib::AbstractNode *node)
480 {
399 {
481 setNode(node);
400 setNode(node);
482 }
401 }
483
402
484 void QIlib::QIcadNetListLibrary::setNode(QIlib::AbstractNode *node)
403 void QIlib::QIcadNetListLibrary::setNode(QIlib::AbstractNode *node)
485 {
404 {
486 /*
405 /*
487 (library (logical guan)
406 (library (logical guan)
488 (uri /home/guan/boards/guan.lib))
407 (uri /home/guan/boards/guan.lib))
489 */
408 */
490 if(node->name==QIlib::Lexique::library_c)
409 if(node->name==QIlib::Lexique::library_c)
491 {
410 {
492 this->p_node = node;
411 this->p_node = node;
493 for(int i=0;i<node->nodes.count();i++)
412 for(int i=0;i<node->nodes.count();i++)
494 {
413 {
495 if(node->nodes.at(i)->name==QIlib::Lexique::logical_c)
414 if(node->nodes.at(i)->name==QIlib::Lexique::logical_c)
496 {
415 {
497 this->logical.setNode(node->nodes.at(i));
416 this->logical.setNode(node->nodes.at(i));
498 }
417 }
499 if(node->nodes.at(i)->name==QIlib::Lexique::uri_c)
418 if(node->nodes.at(i)->name==QIlib::Lexique::uri_c)
500 {
419 {
501 this->uri.setNode(node->nodes.at(i));
420 this->uri.setNode(node->nodes.at(i));
502 }
421 }
503 }
422 }
504 }
423 }
505 }
424 }
506
425
507
426
508
427
509 QIlib::QIcadNetListField::QIcadNetListField(QIlib::AbstractNode *node)
428 QIlib::QIcadNetListField::QIcadNetListField(QIlib::AbstractNode *node)
510 {
429 {
511 setNode(node);
430 setNode(node);
512 }
431 }
513
432
514 void QIlib::QIcadNetListField::setNode(QIlib::AbstractNode *node)
433 void QIlib::QIcadNetListField::setNode(QIlib::AbstractNode *node)
515 {
434 {
516 if(node->name==QIlib::Lexique::field_c)
435 if(node->name==QIlib::Lexique::field_c)
517 {
436 {
518 this->p_node = node;
437 this->p_node = node;
519 for(int i=0;i<node->nodes.count();i++)
438 for(int i=0;i<node->nodes.count();i++)
520 {
439 {
521 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
440 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
522 {
441 {
523 this->name.setNode(node->nodes.at(i));
442 this->name.setNode(node->nodes.at(i));
524 }
443 }
525 }
444 }
526 }
445 }
527 }
446 }
528
447
529
448
530 QIlib::QIcadNetListLibPart::QIcadNetListPin::QIcadNetListPin(QIlib::AbstractNode *node)
449 QIlib::QIcadNetListLibPart::QIcadNetListPin::QIcadNetListPin(QIlib::AbstractNode *node)
531 {
450 {
532 setNode(node);
451 setNode(node);
533 }
452 }
534
453
535 void QIlib::QIcadNetListLibPart::QIcadNetListPin::setNode(QIlib::AbstractNode *node)
454 void QIlib::QIcadNetListLibPart::QIcadNetListPin::setNode(QIlib::AbstractNode *node)
536 {
455 {
537 //(pin (num 1) (name GND) (type power_in))
456 //(pin (num 1) (name GND) (type power_in))
538 if(node->name==QIlib::Lexique::pin_c)
457 if(node->name==QIlib::Lexique::pin_c)
539 {
458 {
540 this->p_node = node;
459 this->p_node = node;
541 for(int i=0;i<node->nodes.count();i++)
460 for(int i=0;i<node->nodes.count();i++)
542 {
461 {
543 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
462 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
544 {
463 {
545 this->name.setNode(node->nodes.at(i));
464 this->name.setNode(node->nodes.at(i));
546 }
465 }
547 if(node->nodes.at(i)->name==QIlib::Lexique::num_c)
466 if(node->nodes.at(i)->name==QIlib::Lexique::num_c)
548 {
467 {
549 this->num.setNode(node->nodes.at(i));
468 this->num.setNode(node->nodes.at(i));
550 }
469 }
551 if(node->nodes.at(i)->name==QIlib::Lexique::type_c)
470 if(node->nodes.at(i)->name==QIlib::Lexique::type_c)
552 {
471 {
553 this->type.setNode(node->nodes.at(i));
472 this->type.setNode(node->nodes.at(i));
554 }
473 }
555 }
474 }
556 }
475 }
557 }
476 }
558
477
559 QIlib::QIcadNetListComponent::QIcadNetListLibSource::QIcadNetListLibSource(QIlib::AbstractNode *node)
478 QIlib::QIcadNetListComponent::QIcadNetListLibSource::QIcadNetListLibSource(QIlib::AbstractNode *node)
560 {
479 {
561 setNode(node);
480 setNode(node);
562 }
481 }
563
482
564 void QIlib::QIcadNetListComponent::QIcadNetListLibSource::setNode(QIlib::AbstractNode *node)
483 void QIlib::QIcadNetListComponent::QIcadNetListLibSource::setNode(QIlib::AbstractNode *node)
565 {
484 {
566 //(libsource (lib guan) (part 24L-MOD-8))
485 //(libsource (lib guan) (part 24L-MOD-8))
567 if(node->name==QIlib::Lexique::libsource_c)
486 if(node->name==QIlib::Lexique::libsource_c)
568 {
487 {
569 this->p_node = node;
488 this->p_node = node;
570 for(int i=0;i<node->nodes.count();i++)
489 for(int i=0;i<node->nodes.count();i++)
571 {
490 {
572 if(node->nodes.at(i)->name==QIlib::Lexique::lib_c)
491 if(node->nodes.at(i)->name==QIlib::Lexique::lib_c)
573 {
492 {
574 this->lib.setNode(node->nodes.at(i));
493 this->lib.setNode(node->nodes.at(i));
575 }
494 }
576 if(node->nodes.at(i)->name==QIlib::Lexique::part_c)
495 if(node->nodes.at(i)->name==QIlib::Lexique::part_c)
577 {
496 {
578 this->part.setNode(node->nodes.at(i));
497 this->part.setNode(node->nodes.at(i));
579 }
498 }
580 }
499 }
581 }
500 }
582 }
501 }
583
502
584 QIlib::QIcadNetListComponent::QIcadNetListSheetPath::QIcadNetListSheetPath(QIlib::AbstractNode *node)
503 QIlib::QIcadNetListComponent::QIcadNetListSheetPath::QIcadNetListSheetPath(QIlib::AbstractNode *node)
585 {
504 {
586 setNode(node);
505 setNode(node);
587 }
506 }
588
507
589 void QIlib::QIcadNetListComponent::QIcadNetListSheetPath::setNode(QIlib::AbstractNode *node)
508 void QIlib::QIcadNetListComponent::QIcadNetListSheetPath::setNode(QIlib::AbstractNode *node)
590 {
509 {
591 //(sheetpath (names /) (tstamps /))
510 //(sheetpath (names /) (tstamps /))
592 if(node->name==QIlib::Lexique::sheetpath_c)
511 if(node->name==QIlib::Lexique::sheetpath_c)
593 {
512 {
594 this->p_node = node;
513 this->p_node = node;
595 for(int i=0;i<node->nodes.count();i++)
514 for(int i=0;i<node->nodes.count();i++)
596 {
515 {
597 if(node->nodes.at(i)->name==QIlib::Lexique::names_c)
516 if(node->nodes.at(i)->name==QIlib::Lexique::names_c)
598 {
517 {
599 this->names.setNode(node->nodes.at(i));
518 this->names.setNode(node->nodes.at(i));
600 }
519 }
601 if(node->nodes.at(i)->name==QIlib::Lexique::tstamps_c)
520 if(node->nodes.at(i)->name==QIlib::Lexique::tstamps_c)
602 {
521 {
603 this->tstamps.setNode(node->nodes.at(i));
522 this->tstamps.setNode(node->nodes.at(i));
604 }
523 }
605 }
524 }
606 }
525 }
607 }
526 }
608
527
609 QIlib::QIcadNetListNet::QIcadNetListNet(QIlib::AbstractNode *node)
528 QIlib::QIcadNetListNet::QIcadNetListNet(QIlib::AbstractNode *node)
610 {
529 {
611 setNode(node);
530 setNode(node);
612 }
531 }
613
532
614 void QIlib::QIcadNetListNet::setNode(QIlib::AbstractNode *node)
533 void QIlib::QIcadNetListNet::setNode(QIlib::AbstractNode *node)
615 {
534 {
616 /*
535 /*
617 (nets
536 (nets
618 (net (code 15) (name "")
537 (net (code 15) (name "")
619 (node (ref C4) (pin 1))
538 (node (ref C4) (pin 1))
620 (node (ref U2) (pin 4)))
539 (node (ref U2) (pin 4)))
621 (net (code 16) (name GND)
540 (net (code 16) (name GND)
622 (node (ref D1) (pin 2))
541 (node (ref D1) (pin 2))
623 (node (ref C1) (pin 2))
542 (node (ref C1) (pin 2))
624 (node (ref IC1) (pin 1))
543 (node (ref IC1) (pin 1))
625 */
544 */
626 if(node->name==QIlib::Lexique::net_c)
545 if(node->name==QIlib::Lexique::net_c)
627 {
546 {
628 this->p_node = node;
547 this->p_node = node;
629 while(NetNodes.count())
548 while(NetNodes.count())
630 {
549 {
631 QIcadNetListNetNode* net;
550 QIcadNetListNetNode* net;
632 net = NetNodes.last();
551 net = NetNodes.last();
633 NetNodes.removeLast();
552 NetNodes.removeLast();
634 delete net;
553 delete net;
635 }
554 }
636 for(int i=0;i<node->nodes.count();i++)
555 for(int i=0;i<node->nodes.count();i++)
637 {
556 {
638 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
557 if(node->nodes.at(i)->name==QIlib::Lexique::name_c)
639 {
558 {
640 this->name.setNode(node->nodes.at(i));
559 this->name.setNode(node->nodes.at(i));
641 }
560 }
642 if(node->nodes.at(i)->name==QIlib::Lexique::code_c)
561 if(node->nodes.at(i)->name==QIlib::Lexique::code_c)
643 {
562 {
644 this->code.setNode(node->nodes.at(i));
563 this->code.setNode(node->nodes.at(i));
645 }
564 }
646 if(node->nodes.at(i)->name==QIlib::Lexique::node_c)
565 if(node->nodes.at(i)->name==QIlib::Lexique::node_c)
647 {
566 {
648 NetNodes.append(new QIcadNetListNetNode(node->nodes.at(i)));
567 NetNodes.append(new QIcadNetListNetNode(node->nodes.at(i)));
649 }
568 }
650 }
569 }
651 }
570 }
652 }
571 }
653
572
654 QIlib::QIcadNetListNet::QIcadNetListNetNode::QIcadNetListNetNode(QIlib::AbstractNode *node)
573 QIlib::QIcadNetListNet::QIcadNetListNetNode::QIcadNetListNetNode(QIlib::AbstractNode *node)
655 {
574 {
656 setNode(node);
575 setNode(node);
657 }
576 }
658
577
659 void QIlib::QIcadNetListNet::QIcadNetListNetNode::setNode(QIlib::AbstractNode *node)
578 void QIlib::QIcadNetListNet::QIcadNetListNetNode::setNode(QIlib::AbstractNode *node)
660 {
579 {
661 //(node (ref D1) (pin 2))
580 //(node (ref D1) (pin 2))
662 if(node->name==QIlib::Lexique::node_c)
581 if(node->name==QIlib::Lexique::node_c)
663 {
582 {
664 this->p_node = node;
583 this->p_node = node;
665 for(int i=0;i<node->nodes.count();i++)
584 for(int i=0;i<node->nodes.count();i++)
666 {
585 {
667 if(node->nodes.at(i)->name==QIlib::Lexique::ref_c)
586 if(node->nodes.at(i)->name==QIlib::Lexique::ref_c)
668 {
587 {
669 this->ref.setNode(node->nodes.at(i));
588 this->ref.setNode(node->nodes.at(i));
670 }
589 }
671 if(node->nodes.at(i)->name==QIlib::Lexique::pin_c)
590 if(node->nodes.at(i)->name==QIlib::Lexique::pin_c)
672 {
591 {
673 this->pin.setNode(node->nodes.at(i));
592 this->pin.setNode(node->nodes.at(i));
674 }
593 }
675 }
594 }
676 }
595 }
677 }
596 }
678
597
679
598
680
599
681
600
682
601
683
602
684
603
685
604
686
605
687
606
688
607
689
608
690
609
691
610
692
611
693
612
694
613
695
614
696
615
697
616
698
617
@@ -1,268 +1,213
1 #ifndef QICADNETLIST_H
2 #define QICADNETLIST_H
3 #include <QString>
4 #include <QStringList>
5 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
6 -- This file is a part of the Kicad Tools Software
2 -- This file is a part of the Kicad Tools Software
7 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
8 --
4 --
9 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
10 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
11 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
12 -- (at your option) any later version.
8 -- (at your option) any later version.
13 --
9 --
14 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
18 --
14 --
19 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
20 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
21 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
23 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
24 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
25 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef QICADNETLIST_H
23 #define QICADNETLIST_H
24 #include <QString>
25 #include <QStringList>
26 #include <QList>
26 #include <QList>
27 #include <QFile>
27 #include <QFile>
28 #include <parsers/lispLike_driver.h>
28 #include <parsers/lispLike_driver.h>
29 #include <qicadnet.h>
29 #include <qicadlisplikelexique.h>
30
30
31 namespace QIlib{
31 namespace QIlib{
32
32
33 namespace Lexique
34 {
35 extern "C" const char* root_c ;
36 extern "C" const char* version_c ;
37 extern "C" const char* design_c ;
38 extern "C" const char* source_c ;
39 extern "C" const char* date_c ;
40 extern "C" const char* tool_c ;
41 extern "C" const char* components_c ;
42 extern "C" const char* component_c ;
43 extern "C" const char* ref_c ;
44 extern "C" const char* value_c ;
45 extern "C" const char* libsource_c ;
46 extern "C" const char* lib_c ;
47 extern "C" const char* part_c ;
48 extern "C" const char* sheetpath_c ;
49 extern "C" const char* names_c ;
50 extern "C" const char* tstamps_c ;
51 extern "C" const char* tstamp_c ;
52 extern "C" const char* libparts_c ;
53 extern "C" const char* libpart_c ;
54 extern "C" const char* fields_c ;
55 extern "C" const char* field_c ;
56 extern "C" const char* name_c ;
57 extern "C" const char* pins_c ;
58 extern "C" const char* pin_c ;
59 extern "C" const char* num_c ;
60 extern "C" const char* type_c ;
61 extern "C" const char* libraries_c ;
62 extern "C" const char* library_c ;
63 extern "C" const char* logical_c ;
64 extern "C" const char* uri_c ;
65 extern "C" const char* nets_c ;
66 extern "C" const char* net_c ;
67 extern "C" const char* code_c ;
68 extern "C" const char* node_c ;
69
33
70 }
71
72
73
74 class QIcadAbstractNodeWrapper
75 {
76 public:
77 QIcadAbstractNodeWrapper(QIlib::AbstractNode* node);
78 QIcadAbstractNodeWrapper(){}
79 ~QIcadAbstractNodeWrapper();
80 QString value();
81 QString value(int index);
82 QString catValues();
83 QList<QIcadAbstractNodeWrapper*> childs;
84 QIcadAbstractNodeWrapper* parent;
85 virtual void setNode(QIlib::AbstractNode* node);
86
87 QIlib::AbstractNode* p_node;
88 };
89
34
90 class QIcadNetListDesign : public QIcadAbstractNodeWrapper
35 class QIcadNetListDesign : public QIcadAbstractNodeWrapper
91 {
36 {
92 public:
37 public:
93 QIcadNetListDesign(QIlib::AbstractNode* node);
38 QIcadNetListDesign(QIlib::AbstractNode* node);
94 QIcadNetListDesign(){}
39 QIcadNetListDesign(){}
95 QIcadAbstractNodeWrapper source;
40 QIcadAbstractNodeWrapper source;
96 QIcadAbstractNodeWrapper date;
41 QIcadAbstractNodeWrapper date;
97 QIcadAbstractNodeWrapper tool;
42 QIcadAbstractNodeWrapper tool;
98 void setNode(QIlib::AbstractNode* node);
43 void setNode(QIlib::AbstractNode* node);
99 };
44 };
100
45
101
46
102
47
103 /*
48 /*
104 * (comp (ref IC1)
49 * (comp (ref IC1)
105 (value 24L-MOD-8)
50 (value 24L-MOD-8)
106 (libsource (lib guan) (part 24L-MOD-8))
51 (libsource (lib guan) (part 24L-MOD-8))
107 (sheetpath (names /) (tstamps /))
52 (sheetpath (names /) (tstamps /))
108 (tstamp 52533BBE))
53 (tstamp 52533BBE))
109 */
54 */
110 class QIcadNetListComponent:public QIcadAbstractNodeWrapper
55 class QIcadNetListComponent:public QIcadAbstractNodeWrapper
111 {
56 {
112 class QIcadNetListLibSource : QIcadAbstractNodeWrapper
57 class QIcadNetListLibSource : QIcadAbstractNodeWrapper
113 {
58 {
114 public:
59 public:
115 QIcadNetListLibSource(AbstractNode* node);
60 QIcadNetListLibSource(AbstractNode* node);
116 QIcadNetListLibSource(){}
61 QIcadNetListLibSource(){}
117 QIcadAbstractNodeWrapper lib;
62 QIcadAbstractNodeWrapper lib;
118 QIcadAbstractNodeWrapper part;
63 QIcadAbstractNodeWrapper part;
119 void setNode(AbstractNode* node);
64 void setNode(AbstractNode* node);
120 };
65 };
121 class QIcadNetListSheetPath : QIcadAbstractNodeWrapper
66 class QIcadNetListSheetPath : QIcadAbstractNodeWrapper
122 {
67 {
123 public:
68 public:
124 QIcadNetListSheetPath(AbstractNode* node);
69 QIcadNetListSheetPath(AbstractNode* node);
125 QIcadNetListSheetPath(){}
70 QIcadNetListSheetPath(){}
126 QIcadAbstractNodeWrapper names;
71 QIcadAbstractNodeWrapper names;
127 QIcadAbstractNodeWrapper tstamps;
72 QIcadAbstractNodeWrapper tstamps;
128 void setNode(AbstractNode* node);
73 void setNode(AbstractNode* node);
129 };
74 };
130 public:
75 public:
131 QIcadNetListComponent(AbstractNode* node);
76 QIcadNetListComponent(AbstractNode* node);
132 QIcadAbstractNodeWrapper ref;
77 QIcadAbstractNodeWrapper ref;
133 QIcadAbstractNodeWrapper value;
78 QIcadAbstractNodeWrapper value;
134 QIcadNetListLibSource libsource;
79 QIcadNetListLibSource libsource;
135 QIcadNetListSheetPath sheetpath;
80 QIcadNetListSheetPath sheetpath;
136 QIcadAbstractNodeWrapper tstamp;
81 QIcadAbstractNodeWrapper tstamp;
137 void setNode(QIlib::AbstractNode* node);
82 void setNode(QIlib::AbstractNode* node);
138 };
83 };
139
84
140
85
141 /*
86 /*
142 (libparts
87 (libparts
143 (libpart (lib guan) (part 24L-MOD-8)
88 (libpart (lib guan) (part 24L-MOD-8)
144 (fields
89 (fields
145 (field (name Reference) IC)
90 (field (name Reference) IC)
146 (field (name Value) 24L-MOD-8))
91 (field (name Value) 24L-MOD-8))
147 (pins
92 (pins
148 (pin (num 1) (name GND) (type power_in))
93 (pin (num 1) (name GND) (type power_in))
149 (pin (num 2) (name VCC) (type power_in))
94 (pin (num 2) (name VCC) (type power_in))
150 */
95 */
151 class QIcadNetListField : QIcadAbstractNodeWrapper
96 class QIcadNetListField : QIcadAbstractNodeWrapper
152 {
97 {
153 public:
98 public:
154 QIcadNetListField(AbstractNode* node);
99 QIcadNetListField(AbstractNode* node);
155 QIcadAbstractNodeWrapper name;
100 QIcadAbstractNodeWrapper name;
156 void setNode(AbstractNode* node);
101 void setNode(AbstractNode* node);
157 };
102 };
158
103
159
104
160 class QIcadNetListLibPart : QIcadAbstractNodeWrapper
105 class QIcadNetListLibPart : QIcadAbstractNodeWrapper
161 {
106 {
162 class QIcadNetListPin : QIcadAbstractNodeWrapper
107 class QIcadNetListPin : QIcadAbstractNodeWrapper
163 {
108 {
164 public:
109 public:
165 QIcadNetListPin(AbstractNode* node);
110 QIcadNetListPin(AbstractNode* node);
166 QIcadAbstractNodeWrapper type;
111 QIcadAbstractNodeWrapper type;
167 QIcadAbstractNodeWrapper num;
112 QIcadAbstractNodeWrapper num;
168 QIcadAbstractNodeWrapper name;
113 QIcadAbstractNodeWrapper name;
169 void setNode(AbstractNode* node);
114 void setNode(AbstractNode* node);
170 };
115 };
171 public:
116 public:
172 QIcadNetListLibPart(AbstractNode* node);
117 QIcadNetListLibPart(AbstractNode* node);
173 QIcadAbstractNodeWrapper lib;
118 QIcadAbstractNodeWrapper lib;
174 QIcadAbstractNodeWrapper part;
119 QIcadAbstractNodeWrapper part;
175 QList<QIcadNetListField*> fields;
120 QList<QIcadNetListField*> fields;
176 QList<QIcadNetListPin*> pins;
121 QList<QIcadNetListPin*> pins;
177 void setNode(AbstractNode* node);
122 void setNode(AbstractNode* node);
178 void setFields(QIlib::AbstractNode* node);
123 void setFields(QIlib::AbstractNode* node);
179 void apendFields(QIlib::AbstractNode* node);
124 void apendFields(QIlib::AbstractNode* node);
180 void setPins(QIlib::AbstractNode* node);
125 void setPins(QIlib::AbstractNode* node);
181 void apendPins(QIlib::AbstractNode* node);
126 void apendPins(QIlib::AbstractNode* node);
182 };
127 };
183
128
184 /*
129 /*
185 (libraries
130 (libraries
186 (library (logical guan)
131 (library (logical guan)
187 (uri /home/guan/boards/guan.lib))
132 (uri /home/guan/boards/guan.lib))
188 (library (logical device)
133 (library (logical device)
189 (uri /usr/share/kicad/library/device.lib))
134 (uri /usr/share/kicad/library/device.lib))
190 (library (logical conn)
135 (library (logical conn)
191 (uri /usr/share/kicad/library/conn.lib)))
136 (uri /usr/share/kicad/library/conn.lib)))
192 */
137 */
193
138
194 class QIcadNetListLibrary : QIcadAbstractNodeWrapper
139 class QIcadNetListLibrary : QIcadAbstractNodeWrapper
195 {
140 {
196 public:
141 public:
197 QIcadNetListLibrary(AbstractNode* node);
142 QIcadNetListLibrary(AbstractNode* node);
198 QIcadAbstractNodeWrapper uri;
143 QIcadAbstractNodeWrapper uri;
199 QIcadAbstractNodeWrapper logical;
144 QIcadAbstractNodeWrapper logical;
200 void setNode(AbstractNode* node);
145 void setNode(AbstractNode* node);
201 };
146 };
202 /*
147 /*
203 (nets
148 (nets
204 (net (code 15) (name "")
149 (net (code 15) (name "")
205 (node (ref C4) (pin 1))
150 (node (ref C4) (pin 1))
206 (node (ref U2) (pin 4)))
151 (node (ref U2) (pin 4)))
207 (net (code 16) (name GND)
152 (net (code 16) (name GND)
208 (node (ref D1) (pin 2))
153 (node (ref D1) (pin 2))
209 (node (ref C1) (pin 2))
154 (node (ref C1) (pin 2))
210 (node (ref IC1) (pin 1))
155 (node (ref IC1) (pin 1))
211 */
156 */
212
157
213 class QIcadNetListNet : QIcadAbstractNodeWrapper
158 class QIcadNetListNet : QIcadAbstractNodeWrapper
214 {
159 {
215 class QIcadNetListNetNode: QIcadAbstractNodeWrapper
160 class QIcadNetListNetNode: QIcadAbstractNodeWrapper
216 {
161 {
217 public:
162 public:
218 QIcadNetListNetNode(AbstractNode* node);
163 QIcadNetListNetNode(AbstractNode* node);
219 QIcadAbstractNodeWrapper ref;
164 QIcadAbstractNodeWrapper ref;
220 QIcadAbstractNodeWrapper pin;
165 QIcadAbstractNodeWrapper pin;
221 void setNode(AbstractNode* node);
166 void setNode(AbstractNode* node);
222 };
167 };
223 public:
168 public:
224 QIcadNetListNet(AbstractNode* node);
169 QIcadNetListNet(AbstractNode* node);
225 QList<QIcadNetListNetNode*> NetNodes;
170 QList<QIcadNetListNetNode*> NetNodes;
226 QIcadAbstractNodeWrapper code;
171 QIcadAbstractNodeWrapper code;
227 QIcadAbstractNodeWrapper name;
172 QIcadAbstractNodeWrapper name;
228 void setNode(AbstractNode* node);
173 void setNode(AbstractNode* node);
229
174
230 };
175 };
231
176
232 class QIcadNetListRoot : public QIcadAbstractNodeWrapper
177 class QIcadNetListRoot : public QIcadAbstractNodeWrapper
233 {
178 {
234 public:
179 public:
235 QIcadNetListRoot(QIlib::AbstractNode* node);
180 QIcadNetListRoot(QIlib::AbstractNode* node);
236 QIcadNetListDesign design;
181 QIcadNetListDesign design;
237 QList<QIcadNetListComponent*> components;
182 QList<QIcadNetListComponent*> components;
238 QList<QIcadNetListLibPart*> libparts;
183 QList<QIcadNetListLibPart*> libparts;
239 QList<QIcadNetListLibrary*> libraries;
184 QList<QIcadNetListLibrary*> libraries;
240 QList<QIcadNetListNet*> nets;
185 QList<QIcadNetListNet*> nets;
241 void setNode(QIlib::AbstractNode* node);
186 void setNode(QIlib::AbstractNode* node);
242 void setComponents(QIlib::AbstractNode* node);
187 void setComponents(QIlib::AbstractNode* node);
243 void apendComponents(QIlib::AbstractNode* node);
188 void apendComponents(QIlib::AbstractNode* node);
244 void setLibParts(QIlib::AbstractNode* node);
189 void setLibParts(QIlib::AbstractNode* node);
245 void apendLibParts(QIlib::AbstractNode* node);
190 void apendLibParts(QIlib::AbstractNode* node);
246 void setLibraries(QIlib::AbstractNode* node);
191 void setLibraries(QIlib::AbstractNode* node);
247 void apendLibraries(QIlib::AbstractNode* node);
192 void apendLibraries(QIlib::AbstractNode* node);
248 void setNets(QIlib::AbstractNode* node);
193 void setNets(QIlib::AbstractNode* node);
249 void apendNets(QIlib::AbstractNode* node);
194 void apendNets(QIlib::AbstractNode* node);
250 };
195 };
251
196
252
197
253 class QIcadNetList : private lispLike_Driver
198 class QIcadNetList : private lispLike_Driver
254 {
199 {
255 public:
200 public:
256 QIcadNetList();
201 QIcadNetList();
257 bool parseNetList(const QString& netlist);
202 bool parseNetList(const QString& netlist);
258 QString toString();
203 // QString toString();
259 QString fileName;
204 QString fileName;
260 QString print();
205 QString print();
261 QIcadNetListRoot* netlistRoot;
206 QIcadNetListRoot* netlistRoot;
262 private:
207 private:
263 QIlib::AbstractNode* getAbstractNode(const QString& node,int index);
208 QIlib::AbstractNode* getAbstractNode(const QString& node,int index);
264 QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index);
209 QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index);
265 void updateConcreteTree();
210 void updateConcreteTree();
266 };
211 };
267 }
212 }
268 #endif // QICADNETLIST_H
213 #endif // QICADNETLIST_H
@@ -1,64 +1,67
1 #==================================================
1 #==================================================
2 #
2 #
3 # _|_| _|_|_| _| _| _|
3 # _|_| _|_|_| _| _| _|
4 # _| _| _| _| _|_|_|
4 # _| _| _| _| _|_|_|
5 # _| _|_| _| _| _| _| _|
5 # _| _|_| _| _| _| _| _|
6 # _| _| _| _| _| _| _|
6 # _| _| _| _| _| _| _|
7 # _|_| _| _|_|_| _| _| _|_|_|
7 # _|_| _| _|_|_| _| _| _|_|_|
8 #
8 #
9 #==================================================
9 #==================================================
10 #
10 #
11 #
11 #
12
12
13 QT += core gui
13 QT += core gui
14
14
15 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
15 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
16
16
17 TARGET = QIlib
17 TARGET = QIlib
18 TEMPLATE = lib
18 TEMPLATE = lib
19
19
20 LIBS += -lfl
20 LIBS += -lfl
21
21
22 MOC_DIR = moc
22 MOC_DIR = moc
23 RCC_DIR = resources
23 RCC_DIR = resources
24 OBJECTS_DIR = obj
24 OBJECTS_DIR = obj
25 DESTDIR = lib
25 DESTDIR = lib
26
26
27 include ( ./parsers/Flex_Bison_FIles/Flex_Bison_FIles.pri )
27 include ( ./parsers/Flex_Bison_FIles/Flex_Bison_FIles.pri )
28
28
29 qilibcfg.path = $$[QT_INSTALL_PREFIX]/mkspecs/features
29 qilibcfg.path = $$[QT_INSTALL_PREFIX]/mkspecs/features
30 qilibcfg.files = \
30 qilibcfg.files = \
31 qilib.prf
31 qilib.prf
32
32
33 target.path = $$[QT_INSTALL_LIBS]
33 target.path = $$[QT_INSTALL_LIBS]
34
34
35 qilibHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib
35 qilibHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib
36 qilibHeaders.files = \
36 qilibHeaders.files = \
37 qicadnetlist.h \
37 qicadnetlist.h \
38 qicadnet.h \
38 qicadpcb.h \
39 qicadlisplikelexique.h
39
40
40 qilibParsersHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib/parsers
41 qilibParsersHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib/parsers
41 qilibParsersHeaders.files = \
42 qilibParsersHeaders.files = \
42 parsers/lispLike_driver.h \
43 parsers/lispLike_driver.h \
43 parsers/lispLike_scanner.h
44 parsers/lispLike_scanner.h
44
45
45
46
46 INSTALLS += target qilibHeaders qilibParsersHeaders qilibcfg
47 INSTALLS += target qilibHeaders qilibParsersHeaders qilibcfg
47
48
48 INCLUDEPATH += ./parsers
49 INCLUDEPATH += ./parsers
49
50
50 SOURCES += \
51 SOURCES += \
51 qicadnetlist.cpp \
52 qicadnetlist.cpp \
52 qicadnet.cpp \
53 parsers/lispLike_driver.cpp \
53 parsers/lispLike_driver.cpp \
54 parsers/lispLike_scanner.cpp
54 parsers/lispLike_scanner.cpp \
55 qicadpcb.cpp \
56 qicadlisplikelexique.cpp
55
57
56
58
57 HEADERS += \
59 HEADERS += \
58 qicadnetlist.h \
60 qicadnetlist.h \
59 qicadnet.h \
60 parsers/lispLike_driver.h \
61 parsers/lispLike_driver.h \
61 parsers/lispLike_scanner.h
62 parsers/lispLike_scanner.h \
63 qicadpcb.h \
64 qicadlisplikelexique.h
62
65
63 OTHER_FILES += qilib.prf
66 OTHER_FILES += qilib.prf
64
67
@@ -1,59 +1,81
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the Kicad Tools Software
2 -- This file is a part of the Kicad Tools Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include <QDir>
22 #include <QDir>
23 #include <QFile>
23 #include <QFile>
24 #include <QApplication>
24 #include <QApplication>
25 #include <qicadnetlist.h>
25 #include <qicadnetlist.h>
26 #include <qicadpcb.h>
26 #include <QDebug>
27 #include <QDebug>
27 #include <QTime>
28 #include <QTime>
28 /*
29 /*
29 #include <lispLike_driver.h>
30 #include <lispLike_driver.h>
30 */
31 */
31
32
32 int main(int argc, char *argv[])
33 int main(int argc, char *argv[])
33 {
34 {
34 QApplication ap(argc,argv);
35 QApplication ap(argc,argv);
35 QIlib::QIcadNetList NetListdriver;
36 if(argc>1)
36 if(argc>1)
37 {
37 {
38 if(QFile::exists(argv[1]))
38 if(QFile::exists(argv[1]))
39 {
39 {
40 QTime tm;
40 QTime tm;
41 if(ap.arguments().contains("--netList"))
42 {
43 QIlib::QIcadNetList NetListdriver;
41 tm.start();
44 tm.start();
42 NetListdriver.parseNetList(argv[1]);
45 NetListdriver.parseNetList(argv[1]);
43 qDebug()<<"File parsed in "<<tm.elapsed()<<"ms";
46 qDebug()<<"File parsed in "<<tm.elapsed()<<"ms";
44 if(ap.arguments().contains("--print"))
47 if(ap.arguments().contains("--print"))
45 {
48 {
46 std::cout<<NetListdriver.print().toStdString();
49 std::cout<<NetListdriver.print().toStdString();
47 }
50 }
48 else
51 else
49 {
52 {
50 for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++)
53 for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++)
51 {
54 {
52 std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n";
55 std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n";
53 }
56 }
54 }
57 }
55 }
58 }
59 else
60 {
61 QIlib::QIcadPcb pcbDriver;
62 tm.start();
63 pcbDriver.parsePcb(argv[1]);
64 qDebug()<<"File parsed in "<<tm.elapsed()<<"ms";
65 if(ap.arguments().contains("--print"))
66 {
67 std::cout<<pcbDriver.print().toStdString();
68 }
69 else
70 {
71 // for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++)
72 // {
73 // std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n";
74 // }
75 }
76 }
77 }
56
78
57 }
79 }
58 return 0;
80 return 0;
59 }
81 }
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now