Browse Source
Add Pcbnew s-expression file parser.
Add Pcbnew s-expression file parser.
* Add s-expression file parser object and keyword files. * Fix minor issues with s-expression file formatting. * Fix a minor bug the zone container fill state parsing in the legacy plugin. * Move EDA_TEXT visibility definition to eda_text.h. * Add minor BOARD_ITEM object improvements to support s-expression file parser.pull/1/head
26 changed files with 4399 additions and 1201 deletions
-
2.bzrignore
-
23d-viewer/3d_draw.cpp
-
10common/CMakeLists.txt
-
6common/eda_text.cpp
-
195common/pcb.keywords
-
24common/worksheet.cpp
-
2eeschema/general.h
-
5include/class_board_design_settings.h
-
12include/eda_text.h
-
1include/layers_id_colors_and_visibility.h
-
5kicad/tree_project_frame.cpp
-
67pcbnew/class_board.cpp
-
43pcbnew/class_board.h
-
4pcbnew/class_board_design_settings.cpp
-
24pcbnew/class_board_item.cpp
-
1pcbnew/class_dimension.h
-
14pcbnew/class_module.cpp
-
16pcbnew/class_module.h
-
18pcbnew/class_zone.cpp
-
17pcbnew/class_zone.h
-
2pcbnew/export_vrml.cpp
-
2125pcbnew/kicad_plugin.cpp
-
286pcbnew/kicad_plugin.h
-
6pcbnew/legacy_plugin.cpp
-
2499pcbnew/pcb_parser.cpp
-
214pcbnew/pcb_parser.h
@ -0,0 +1,195 @@ |
|||
# |
|||
# This program source code file is part of KiCad, a free EDA CAD application. |
|||
# |
|||
# Copyright (C) 2012 CERN. |
|||
# |
|||
# This program is free software; you can redistribute it and/or |
|||
# modify it under the terms of the GNU General Public License |
|||
# as published by the Free Software Foundation; either version 2 |
|||
# of the License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, you may find one here: |
|||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
# or you may search the http://www.gnu.org website for the version 2 license, |
|||
# or you may write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
# |
|||
|
|||
# These are the keywords for the Pcbnew s-expression file format. |
|||
|
|||
add_net |
|||
angle |
|||
arc |
|||
arc_segments |
|||
area |
|||
arrow1a |
|||
arrow1b |
|||
arrow2a |
|||
arrow2b |
|||
at |
|||
attr |
|||
autoplace_cost90 |
|||
autoplace_cost180 |
|||
aux_axis_origin |
|||
blind |
|||
bold |
|||
bottom |
|||
center |
|||
chamfer |
|||
circle |
|||
clearance |
|||
comment |
|||
company |
|||
connect |
|||
connect_pads |
|||
crossbar |
|||
date |
|||
descr |
|||
die_length |
|||
dimension |
|||
drawings |
|||
drill |
|||
edge |
|||
edge_width |
|||
effects |
|||
end |
|||
feature1 |
|||
feature2 |
|||
fill |
|||
fill_segments |
|||
filled_polygon |
|||
fillet |
|||
font |
|||
fp_arc |
|||
fp_circle |
|||
fp_curve |
|||
fp_line |
|||
fp_poly |
|||
fp_text |
|||
full |
|||
general |
|||
gr_arc |
|||
gr_circle |
|||
gr_curve |
|||
gr_line |
|||
gr_poly |
|||
gr_text |
|||
hatch |
|||
hide |
|||
italic |
|||
justify |
|||
kicad_pcb |
|||
last_trace_width |
|||
layer |
|||
layers |
|||
left |
|||
links |
|||
locked |
|||
micro |
|||
min_thickness |
|||
mirror |
|||
mod_edge_width |
|||
mod_text_size |
|||
mod_text_width |
|||
mode |
|||
model |
|||
module |
|||
net |
|||
net_class |
|||
net_name |
|||
nets |
|||
no |
|||
no_connects |
|||
none |
|||
np_thru_hole |
|||
offset |
|||
oval |
|||
pad |
|||
pad_drill |
|||
pad_size |
|||
pad_to_mask_clearance |
|||
pad_to_paste_clearance |
|||
pad_to_paste_clearance_ratio |
|||
page |
|||
path |
|||
pcb_text_size |
|||
pcb_text_width |
|||
placed |
|||
plus |
|||
polygon |
|||
portrait |
|||
priority |
|||
pts |
|||
radius |
|||
rev |
|||
rectangle |
|||
reference |
|||
right |
|||
rotate |
|||
scale |
|||
segment |
|||
segment_width |
|||
setup |
|||
size |
|||
smd |
|||
smoothing |
|||
solder_mask_margin |
|||
solder_paste_margin |
|||
solder_paste_margin_ratio |
|||
solder_paste_ratio |
|||
start |
|||
status |
|||
tags |
|||
target |
|||
title |
|||
title_block |
|||
tedit |
|||
thermal_width |
|||
thermal_gap |
|||
thermal_bridge_width |
|||
thickness |
|||
top |
|||
trace_width |
|||
tracks |
|||
trace_min |
|||
trace_clearance |
|||
trapezoid |
|||
thru |
|||
thru_hole |
|||
tstamp |
|||
use_thermal |
|||
user |
|||
user_trace_width |
|||
user_via |
|||
uvia_dia |
|||
uvia_drill |
|||
uvia_min_drill |
|||
uvia_min_size |
|||
uvia_size |
|||
uvias_allowed |
|||
value |
|||
version |
|||
via |
|||
via_dia |
|||
via_drill |
|||
via_min_drill |
|||
via_min_size |
|||
via_size |
|||
virtual |
|||
visible_elements |
|||
width |
|||
x |
|||
xy |
|||
xyz |
|||
yes |
|||
zone |
|||
zone_45_only |
|||
zone_clearance |
|||
zone_connect |
|||
zones |
2125
pcbnew/kicad_plugin.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,137 +1,149 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) CERN. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef KICAD_PLUGIN_H_ |
|||
#define KICAD_PLUGIN_H_ |
|||
|
|||
#include <io_mgr.h> |
|||
#include <string> |
|||
|
|||
class BOARD; |
|||
class BOARD_ITEM; |
|||
|
|||
|
|||
/** Current s-expression file format version. 2 was the last legacy format version. */ |
|||
#define SEXPR_BOARD_FILE_VERSION 3 |
|||
|
|||
/** Format output for the clipboard instead of a file. */ |
|||
#define CTL_CLIPBOARD (1 << 0) |
|||
|
|||
|
|||
/** |
|||
* Class PCB_IO |
|||
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. |
|||
* |
|||
* @note This class is not thread safe, but it is re-entrant multiple times in sequence. |
|||
*/ |
|||
class PCB_IO : public PLUGIN |
|||
{ |
|||
|
|||
public: |
|||
const wxString& PluginName() const |
|||
{ |
|||
static const wxString name = wxT( "KiCad" ); |
|||
return name; |
|||
} |
|||
|
|||
const wxString& GetFileExtension() const |
|||
{ |
|||
static const wxString extension = wxT( "kicad_pcb" ); |
|||
return extension; |
|||
} |
|||
|
|||
void Save( const wxString& aFileName, BOARD* aBoard, |
|||
PROPERTIES* aProperties = NULL ); // overload |
|||
|
|||
/** |
|||
* Function Format |
|||
* outputs \a aItem to \a aFormatter in s-expression format. |
|||
* |
|||
* @param aItem A pointer the an #BOARD_ITEM object to format. |
|||
* @param aFormatter The #OUTPUTFORMATTER object to write to. |
|||
* @param aNestLevel The indentation nest level. |
|||
* @param aControlBits The control bit definition for object specific formatting. |
|||
* @throw IO_ERROR on write error. |
|||
*/ |
|||
void Format( BOARD_ITEM* aItem, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
protected: |
|||
|
|||
wxString m_error; ///< for throwing exceptions |
|||
BOARD* m_board; ///< which BOARD, no ownership here |
|||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. |
|||
|
|||
LINE_READER* m_reader; ///< no ownership here. |
|||
wxString m_filename; ///< for saves only, name is in m_reader for loads |
|||
|
|||
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing? |
|||
|
|||
private: |
|||
void format( BOARD* aBoard, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( DIMENSION* aDimension, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( EDGE_MODULE* aModuleDrawing, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( DRAWSEGMENT* aSegment, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( PCB_TARGET* aTarget, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( MODULE* aModule, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( D_PAD* aPad, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TEXTE_PCB* aText, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TEXTE_MODULE* aText, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TRACK* aTrack, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( ZONE_CONTAINER* aZone, OUTPUTFORMATTER* aFormatter, int aNestLevel, |
|||
int aControlBits ) const |
|||
throw( IO_ERROR ); |
|||
}; |
|||
|
|||
#endif // KICAD_PLUGIN_H_ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 CERN. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef KICAD_PLUGIN_H_ |
|||
#define KICAD_PLUGIN_H_ |
|||
|
|||
#include <io_mgr.h> |
|||
#include <string> |
|||
|
|||
class BOARD; |
|||
class BOARD_ITEM; |
|||
|
|||
|
|||
/** Current s-expression file format version. 2 was the last legacy format version. */ |
|||
#define SEXPR_BOARD_FILE_VERSION 3 |
|||
|
|||
/** Format output for the clipboard instead of a file. */ |
|||
#define CTL_CLIPBOARD (1 << 0) |
|||
|
|||
|
|||
/** |
|||
* Class PCB_IO |
|||
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. |
|||
* |
|||
* @note This class is not thread safe, but it is re-entrant multiple times in sequence. |
|||
*/ |
|||
class PCB_IO : public PLUGIN |
|||
{ |
|||
|
|||
public: |
|||
|
|||
//-----<PLUGIN API>--------------------------------------------------------- |
|||
|
|||
const wxString& PluginName() const |
|||
{ |
|||
static const wxString name = wxT( "KiCad" ); |
|||
return name; |
|||
} |
|||
|
|||
const wxString& GetFileExtension() const |
|||
{ |
|||
static const wxString extension = wxT( "kicad_pcb" ); |
|||
return extension; |
|||
} |
|||
|
|||
void Save( const wxString& aFileName, BOARD* aBoard, |
|||
PROPERTIES* aProperties = NULL ); // overload |
|||
|
|||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); |
|||
|
|||
//-----</PLUGIN API>-------------------------------------------------------- |
|||
|
|||
PCB_IO(); |
|||
|
|||
/** |
|||
* Function Format |
|||
* outputs \a aItem to \a aFormatter in s-expression format. |
|||
* |
|||
* @param aItem A pointer the an #BOARD_ITEM object to format. |
|||
* @param aNestLevel The indentation nest level. |
|||
* @throw IO_ERROR on write error. |
|||
*/ |
|||
void Format( BOARD_ITEM* aItem, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
std::string GetStringOutput( bool doClear ) |
|||
{ |
|||
std::string ret = m_sf.GetString(); |
|||
if( doClear ) |
|||
m_sf.Clear(); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
protected: |
|||
|
|||
wxString m_error; ///< for throwing exceptions |
|||
BOARD* m_board; ///< which BOARD, no ownership here |
|||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. |
|||
|
|||
LINE_READER* m_reader; ///< no ownership here. |
|||
wxString m_filename; ///< for saves only, name is in m_reader for loads |
|||
|
|||
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing? |
|||
|
|||
STRING_FORMATTER m_sf; |
|||
OUTPUTFORMATTER* m_out; ///< output any Format()s to this, no ownership |
|||
int m_ctl; |
|||
|
|||
|
|||
private: |
|||
void format( BOARD* aBoard, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( DIMENSION* aDimension, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( EDGE_MODULE* aModuleDrawing, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( DRAWSEGMENT* aSegment, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( PCB_TARGET* aTarget, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( MODULE* aModule, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( D_PAD* aPad, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TEXTE_PCB* aText, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TEXTE_MODULE* aText, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( TRACK* aTrack, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void format( ZONE_CONTAINER* aZone, int aNestLevel = 0 ) const |
|||
throw( IO_ERROR ); |
|||
|
|||
void formatLayer( const BOARD_ITEM* aItem ) const; |
|||
}; |
|||
|
|||
#endif // KICAD_PLUGIN_H_ |
2499
pcbnew/pcb_parser.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,214 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 CERN |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/** |
|||
* @file pcb_parser.h |
|||
* @brief Pcbnew s-expression file format parser definition. |
|||
*/ |
|||
|
|||
#ifndef _PCBNEW_PARSER_H_ |
|||
#define _PCBNEW_PARSER_H_ |
|||
|
|||
#include <pcb_lexer.h> |
|||
|
|||
#include <wx/hashmap.h> |
|||
|
|||
|
|||
using namespace PCB; |
|||
|
|||
|
|||
class BOARD; |
|||
class BOARD_ITEM; |
|||
class D_PAD; |
|||
class EDGE_MODULE; |
|||
class TEXTE_MODULE; |
|||
class TEXTE_PCB; |
|||
class MODULE; |
|||
class PCB_TARGET; |
|||
class S3D_MASTER; |
|||
class ZONE_CONTAINER; |
|||
|
|||
|
|||
WX_DECLARE_STRING_HASH_MAP( int, LAYER_HASH_MAP ); |
|||
|
|||
|
|||
#define USE_LAYER_NAMES 1 // Set to 0 to format and parse layers by index number. |
|||
|
|||
|
|||
/** |
|||
* Class PCB_PARSER |
|||
* reads a Pcbnew s-expression fromatted #LINE_READER object and returns the appropriate |
|||
* #BOARD_ITEM object. |
|||
*/ |
|||
class PCB_PARSER : public PCB_LEXER |
|||
{ |
|||
BOARD* m_board; |
|||
LAYER_HASH_MAP m_layerMap; //< Map layer name to it's index saved in BOARD::m_Layer. |
|||
|
|||
void parseHeader() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseGeneralSection() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parsePAGE_INFO() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseLayers() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseSetup() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseNETCLASS() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseTEXTE_PCB( TEXTE_PCB* aText = NULL ) throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseMODULE() throw( IO_ERROR, PARSE_ERROR ); |
|||
TEXTE_MODULE* parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ); |
|||
EDGE_MODULE* parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR ); |
|||
D_PAD* parseD_PAD() throw( IO_ERROR, PARSE_ERROR ); |
|||
TRACK* parseTRACK() throw( IO_ERROR, PARSE_ERROR ); |
|||
SEGVIA* parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ); |
|||
ZONE_CONTAINER* parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ); |
|||
PCB_TARGET* parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ); |
|||
BOARD* parseBOARD() throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
|
|||
/** |
|||
* Function lookUpLayer |
|||
* parses the current token for the layer definition of a #BOARD_ITEM object. |
|||
* |
|||
* @throw IO_ERROR if the layer is not valid. |
|||
* @throw PARSE_ERROR if the layer syntax is incorrect. |
|||
* @return The index the parsed #BOARD_ITEM layer. |
|||
*/ |
|||
int lookUpLayer() throw( PARSE_ERROR, IO_ERROR ); |
|||
|
|||
/** |
|||
* Function parseBoardItemLayer |
|||
* parses the layer definition of a #BOARD_ITEM object. |
|||
* |
|||
* @throw IO_ERROR if the layer is not valid. |
|||
* @throw PARSE_ERROR if the layer syntax is incorrect. |
|||
* @return The index the parsed #BOARD_ITEM layer. |
|||
*/ |
|||
int parseBoardItemLayer() throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
/** |
|||
* Function parseBoardItemLayersAsMask |
|||
* parses the layers definition of a #BOARD_ITEM object. |
|||
* |
|||
* @throw IO_ERROR if any of the layers is not valid. |
|||
* @throw PARSE_ERROR if the layers syntax is incorrect. |
|||
* @return The mask of layers the parsed #BOARD_ITEM is on. |
|||
*/ |
|||
int parseBoardItemLayersAsMask() throw( PARSE_ERROR, IO_ERROR ); |
|||
|
|||
/** |
|||
* Function parseXY |
|||
* parses a coordinate pair (xy X Y) in board units (mm). |
|||
* |
|||
* The parser checks if the previous token was T_LEFT and parses the remainder of |
|||
* the token syntax. This is used when parsing a list of coorinate points. This |
|||
* way the parser can be used in either case. |
|||
* |
|||
* @throw PARSE_ERROR if the coordinate pair syntax is incorrect. |
|||
* @return A wxPoint object containing the coordinate pair. |
|||
*/ |
|||
wxPoint parseXY() throw( PARSE_ERROR ); |
|||
|
|||
void parseXY( int* aX, int* aY ) throw( PARSE_ERROR ); |
|||
|
|||
/** |
|||
* Function parseEDA_TEXT |
|||
* parses the common settings for any object derived from #EDA_TEXT. |
|||
* |
|||
* @throw PARSE_ERROR if the text syntax is not valid. |
|||
* @param aText A point to the #EDA_TEXT object to save the parsed settings into. |
|||
*/ |
|||
void parseEDA_TEXT( EDA_TEXT* aText ) throw( PARSE_ERROR ); |
|||
|
|||
S3D_MASTER* parse3DModel() throw( PARSE_ERROR ); |
|||
|
|||
/** |
|||
* Function parseDouble |
|||
* parses the current token as an ASCII numeric string with possible leading whitespace into |
|||
* a double precision floating point number. |
|||
* |
|||
* @throw IO_ERROR if an error occurs attempting to convert the current token. |
|||
* @return The result of the parsed token. |
|||
*/ |
|||
double parseDouble() throw( IO_ERROR ); |
|||
|
|||
inline double parseDouble( const char* aExpected ) throw( IO_ERROR ) |
|||
{ |
|||
NeedNUMBER( aExpected ); |
|||
return parseDouble(); |
|||
} |
|||
|
|||
inline double parseDouble( T aToken ) throw( IO_ERROR ) |
|||
{ |
|||
return parseDouble( GetTokenText( aToken ) ); |
|||
} |
|||
|
|||
inline int parseBoardUnits() throw( IO_ERROR ) |
|||
{ |
|||
// There should be no rounding issues here, since the values in the file are in mm |
|||
// and get converted to nano-meters. This product should be an integer, exactly. |
|||
return int( parseDouble() * 1e6 ); |
|||
} |
|||
|
|||
inline int parseBoardUnits( const char* aExpected ) throw( PARSE_ERROR ) |
|||
{ |
|||
return KIROUND( parseDouble( aExpected ) * 1e6 ); |
|||
} |
|||
|
|||
inline int parseBoardUnits( T aToken ) throw( PARSE_ERROR ) |
|||
{ |
|||
return parseBoardUnits( GetTokenText( aToken ) ); |
|||
} |
|||
|
|||
inline int parseInt() throw( PARSE_ERROR ) |
|||
{ |
|||
return (int)strtol( CurText(), NULL, 10 ); |
|||
} |
|||
|
|||
inline int parseInt( const char* aExpected ) throw( PARSE_ERROR ) |
|||
{ |
|||
NeedNUMBER( aExpected ); |
|||
return parseInt(); |
|||
} |
|||
|
|||
inline int parseHex() throw( PARSE_ERROR ) |
|||
{ |
|||
NeedSYMBOLorNUMBER(); |
|||
return (int)strtol( CurText(), NULL, 16 ); |
|||
} |
|||
|
|||
bool parseBool() throw( PARSE_ERROR ); |
|||
|
|||
public: |
|||
PCB_PARSER( LINE_READER* aReader, BOARD* aBoard = NULL ) : |
|||
PCB_LEXER( aReader ), |
|||
m_board( aBoard ) |
|||
{ |
|||
} |
|||
|
|||
BOARD_ITEM* Parse() throw( IO_ERROR, PARSE_ERROR ); |
|||
}; |
|||
|
|||
|
|||
#endif // _PCBNEW_PARSER_H_ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue