KiCad PCB EDA Suite
specctra_test.cpp File Reference
#include <cstdarg>
#include <cstdio>
#include <specctra.h>
#include <common.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 44 of file specctra_test.cpp.

References DSN::PCB::Format(), DSN::SESSION::Format(), FROM_UTF8(), DSN::SPECCTRA_DB::GetPCB(), DSN::SPECCTRA_DB::GetSESSION(), DSN::SPECCTRA_DB::LoadSESSION(), TO_UTF8, and IO_ERROR::What().

Referenced by EC_LINE::Apply().

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 }
void LoadSESSION(const wxString &aFilename)
Function LoadSESSION is a recursive descent parser for a SPECCTRA DSN "session" file.
Definition: specctra.cpp:262
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
SESSION * GetSESSION()
Definition: specctra.h:3897
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3569
Class SESSION corresponds to the in the specctra dsn spec.
Definition: specctra.h:3530
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
PCB * GetPCB()
Definition: specctra.h:3886
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3173
Class SPECCTRA_DB holds a DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3604
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47