KiCad PCB EDA Suite
Loading...
Searching...
No Matches
specctra_test.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26// unit test the specctra.cpp file. You can use the beautifiers below to output
27// exactly what you read in but beautified and without #comments. This can
28// then be used along with program 'diff' to test the parsing and formatting
29// of every element. You may have to run the first output back through to
30// get two files that should match, the 2nd and 3rd outputs.
31
32
33
34#include <cstdarg>
35#include <cstdio>
36
37#include "specctra.h"
38#include <common.h>
39
40
41using namespace DSN;
42
43
44int main( int argc, char** argv )
45{
46// wxString filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") );
47// wxString filename( wxT("/tmp/testdesigns/test.dsn") );
48// wxString filename( wxT("/tmp/testdesigns/test.ses") );
49 wxString filename( wxT("/tmp/specctra_big.dsn") );
50
51 SPECCTRA_DB db;
52 bool failed = false;
53
54 LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
55
56 if( argc == 2 )
57 {
58 filename = From_UTF8( argv[1] );
59 }
60
61 try
62 {
63// db.LoadPCB( filename );
64 db.LoadSESSION( filename );
65 }
66 catch( const IO_ERROR& ioe )
67 {
68 fprintf( stderr, "%s\n", TO_UTF8(ioe.What() ) );
69 failed = true;
70 }
71
72 if( !failed )
73 fprintf( stderr, "loaded OK\n" );
74
75 // export what we read in, making this test program basically a beautifier
76 // hose the beautified DSN file to stdout. If an exception occurred,
77 // we will be outputting only a portion of what we wanted to read in.
78 db.SetFILE( stdout );
79
80#if 0
81 // export a PCB
82 DSN::PCB* pcb = db.GetPCB();
83 pcb->Format( &db, 0 );
84
85#else
86 // export a SESSION file.
87 DSN::SESSION* ses = db.GetSESSION();
88 ses->Format( &db, 0 );
89#endif
90}
91
92//-----<dummy code>---------------------------------------------------
93
94// a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
96{
97 return 0;
98}
99
100// a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
101wxString BOARD::GetLayerName( int aLayer ) const
102{
103 return wxEmptyString;
104}
105
106//-----</dummy code>--------------------------------------------------
107
108//EOF
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:139
int GetCopperLayerCount() const
Definition: board.cpp:741
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3200
A <session_file_descriptor> in the specctra dsn spec.
Definition: specctra.h:3569
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3590
A DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3641
SESSION * GetSESSION()
Definition: specctra.h:3698
PCB * GetPCB()
Definition: specctra.h:3687
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition: specctra.cpp:278
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
The common library.
main()
This source file implements export and import capabilities to the specctra dsn file format.
Definition: specctra.cpp:63
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:398