KiCad PCB EDA Suite
Loading...
Searching...
No Matches
autotrax_parser.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Format interpretation derived from pcb-rnd src_plugins/io_autotrax:
5 * Copyright (C) 2016, 2017, 2018, 2020 Tibor 'Igor2' Palinkas
6 * Copyright (C) 2016, 2017 Erich S. Heinzle
7 * Used under GPL v2-or-later.
8 *
9 * Copyright (C) 2026 KiCad Developers, see AUTHORS.txt for contributors.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, you may find one here:
23 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24 * or you may search the http://www.gnu.org website for the version 2 license,
25 * or you may write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27 */
28
29#ifndef AUTOTRAX_PARSER_H_
30#define AUTOTRAX_PARSER_H_
31
32#include <wx/arrstr.h>
33#include <wx/string.h>
34
35#include "autotrax_model.h"
36
37class REPORTER;
38
39
53{
54public:
55 explicit AUTOTRAX_PARSER( REPORTER* aReporter ) :
56 m_reporter( aReporter )
57 {
58 }
59
65 bool Parse( const wxString& aContents, AUTOTRAX::BOARD_DATA& aBoard );
66
69 static bool Sniff( const wxString& aContents );
70
71private:
74 bool nextLine( wxString& aLine );
75
77 static wxArrayString tokenize( const wxString& aLine );
78
79 void warn( const wxString& aMsg ) const;
80
81 // Record parsers. Each consumes the data line(s) following its keyword and
82 // appends to the supplied container (a component's or the board's).
83 bool parseTrack( AUTOTRAX::TRACK& aOut );
84 bool parseArc( AUTOTRAX::ARC& aOut );
85 bool parseVia( AUTOTRAX::VIA& aOut );
86 bool parsePad( AUTOTRAX::PAD& aOut );
87 bool parseFill( AUTOTRAX::FILL& aOut );
88 bool parseText( AUTOTRAX::TEXT& aOut );
90 void parseNetDef();
91
92 REPORTER* m_reporter = nullptr;
94
95 wxArrayString m_lines;
96 size_t m_index = 0;
97 int m_lineNo = 0;
98};
99
100#endif // AUTOTRAX_PARSER_H_
bool parseVia(AUTOTRAX::VIA &aOut)
AUTOTRAX_PARSER(REPORTER *aReporter)
wxArrayString m_lines
AUTOTRAX::BOARD_DATA * m_board
static bool Sniff(const wxString &aContents)
Cheap content sniff: the first non-blank, non-comment line is the magic header "PCB FILE 4" (Autotrax...
bool Parse(const wxString &aContents, AUTOTRAX::BOARD_DATA &aBoard)
Parse aContents into aBoard.
void parseComponent(AUTOTRAX::COMPONENT &aOut)
bool parseArc(AUTOTRAX::ARC &aOut)
bool parseTrack(AUTOTRAX::TRACK &aOut)
void warn(const wxString &aMsg) const
bool parseText(AUTOTRAX::TEXT &aOut)
REPORTER * m_reporter
bool parseFill(AUTOTRAX::FILL &aOut)
bool nextLine(wxString &aLine)
Return the next line trimmed of surrounding whitespace, or false at end of input.
static wxArrayString tokenize(const wxString &aLine)
Tokenize a whitespace-separated data line into C-locale-parseable tokens.
bool parsePad(AUTOTRAX::PAD &aOut)
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
Free or component arc (FA / CA).
Everything parsed out of an Autotrax/Easytrax file, before any KiCad object is created.
A placed component (COMP .. ENDCOMP) holding its own primitives.
Free or component rectangular fill (FF / CF), Autotrax's only pour.
Free or component pad/pin (FP / CP).
Free or component string (FS / CS).
Free or component track segment (FT / CT). All coordinates are in mils.
Free or component via (FV / CV).