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 The KiCad Developers, see AUTHORS.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, see <https://www.gnu.org/licenses/>.
19 */
20
21
22// unit test the specctra.cpp file. You can use the beautifiers below to output
23// exactly what you read in but beautified and without #comments. This can
24// then be used along with program 'diff' to test the parsing and formatting
25// of every element. You may have to run the first output back through to
26// get two files that should match, the 2nd and 3rd outputs.
27
28
29
30#include <cstdarg>
31#include <cstdio>
32
33#include "specctra.h"
34#include <common.h>
35
36
37using namespace DSN;
38
39
40int main( int argc, char** argv )
41{
42// wxString filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") );
43// wxString filename( wxT("/tmp/testdesigns/test.dsn") );
44// wxString filename( wxT("/tmp/testdesigns/test.ses") );
45 wxString filename( wxT("/tmp/specctra_big.dsn") );
46
47 SPECCTRA_DB db;
48 bool failed = false;
49
50 LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
51
52 if( argc == 2 )
53 {
54 filename = From_UTF8( argv[1] );
55 }
56
57 try
58 {
59// db.LoadPCB( filename );
60 db.LoadSESSION( filename );
61 }
62 catch( const IO_ERROR& ioe )
63 {
64 fprintf( stderr, "%s\n", TO_UTF8(ioe.What() ) );
65 failed = true;
66 }
67
68 if( !failed )
69 fprintf( stderr, "loaded OK\n" );
70
71 // export what we read in, making this test program basically a beautifier
72 // hose the beautified DSN file to stdout. If an exception occurred,
73 // we will be outputting only a portion of what we wanted to read in.
74 db.SetFILE( stdout );
75
76#if 0
77 // export a PCB
78 DSN::PCB* pcb = db.GetPCB();
79 pcb->Format( &db, 0 );
80
81#else
82 // export a SESSION file.
83 DSN::SESSION* ses = db.GetSESSION();
84 ses->Format( &db, 0 );
85#endif
86}
87
88//-----<dummy code>---------------------------------------------------
89
90// a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
92{
93 return 0;
94}
95
96// a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
97wxString BOARD::GetLayerName( int aLayer ) const
98{
99 return wxEmptyString;
100}
101
102//-----</dummy code>--------------------------------------------------
103
104//EOF
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
int GetCopperLayerCount() const
Definition board.cpp:985
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:3154
A <session_file_descriptor> in the specctra dsn spec.
Definition specctra.h:3517
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:3538
A DSN data tree, usually coming from a DSN file.
Definition specctra.h:3589
SESSION * GetSESSION()
Definition specctra.h:3646
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition specctra.cpp:265
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
The common library.
This source file implements export and import capabilities to the specctra dsn file format.
Definition specctra.cpp:60
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.