KiCad PCB EDA Suite
drawing_sheet_parser.cpp File Reference
#include <wx/ffile.h>
#include <wx/log.h>
#include <eda_item.h>
#include <locale_io.h>
#include <string_utils.h>
#include <drawing_sheet/ds_data_item.h>
#include <drawing_sheet/ds_data_model.h>
#include <drawing_sheet/ds_painter.h>
#include <drawing_sheet/drawing_sheet_lexer.h>
#include <drawing_sheet/ds_file_versions.h>

Go to the source code of this file.

Classes

class  DRAWING_SHEET_PARSER
 DRAWING_SHEET_PARSER holds data and functions pertinent to parsing a S-expression file for a DS_DATA_MODEL. More...
 

Functions

wxString convertLegacyVariableRefs (const wxString &aTextbase)
 

Variables

const char defaultDrawingSheet []
 
const char emptyDrawingSheet []
 

Function Documentation

◆ convertLegacyVariableRefs()

wxString convertLegacyVariableRefs ( const wxString &  aTextbase)

Definition at line 124 of file drawing_sheet_parser.cpp.

125 {
126  wxString msg;
127 
128  /*
129  * Legacy formats
130  * %% = replaced by %
131  * %K = Kicad version
132  * %Z = paper format name (A4, USLetter)
133  * %Y = company name
134  * %D = date
135  * %R = revision
136  * %S = sheet number
137  * %N = number of sheets
138  * %L = layer name
139  * %Cx = comment (x = 0 to 9 to identify the comment)
140  * %F = filename
141  * %P = sheet path (sheet full name)
142  * %T = title
143  */
144 
145  for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
146  {
147  if( aTextbase[ii] != '%' )
148  {
149  msg << aTextbase[ii];
150  continue;
151  }
152 
153  if( ++ii >= aTextbase.Len() )
154  break;
155 
156  wxChar format = aTextbase[ii];
157 
158  switch( format )
159  {
160  case '%': msg += '%'; break;
161  case 'D': msg += wxT( "${ISSUE_DATE}" ); break;
162  case 'R': msg += wxT( "${REVISION}" ); break;
163  case 'K': msg += wxT( "${KICAD_VERSION}" ); break;
164  case 'Z': msg += wxT( "${PAPER}" ); break;
165  case 'S': msg += wxT( "${#}" ); break;
166  case 'N': msg += wxT( "${##}" ); break;
167  case 'F': msg += wxT( "${FILENAME}" ); break;
168  case 'L': msg += wxT( "${LAYER}" ); break;
169  case 'P': msg += wxT( "${SHEETNAME}" ); break;
170  case 'Y': msg += wxT( "${COMPANY}" ); break;
171  case 'T': msg += wxT( "${TITLE}" ); break;
172  case 'C':
173  format = aTextbase[++ii];
174 
175  switch( format )
176  {
177  case '0': msg += wxT( "${COMMENT1}" ); break;
178  case '1': msg += wxT( "${COMMENT2}" ); break;
179  case '2': msg += wxT( "${COMMENT3}" ); break;
180  case '3': msg += wxT( "${COMMENT4}" ); break;
181  case '4': msg += wxT( "${COMMENT5}" ); break;
182  case '5': msg += wxT( "${COMMENT6}" ); break;
183  case '6': msg += wxT( "${COMMENT7}" ); break;
184  case '7': msg += wxT( "${COMMENT8}" ); break;
185  case '8': msg += wxT( "${COMMENT9}" ); break;
186  }
187  break;
188 
189  default:
190  break;
191  }
192  }
193 
194  return msg;
195 }

Referenced by DRAWING_SHEET_PARSER::Parse().

Variable Documentation

◆ defaultDrawingSheet

const char defaultDrawingSheet[]

◆ emptyDrawingSheet

const char emptyDrawingSheet[]