31#include <wx/cmdline.h>
49bool parse( std::istream& aStream,
bool aVerbose )
55 PCB_PARSER parser( &reader,
nullptr,
nullptr );
63 board = parser.
Parse();
73 std::cout <<
"Took: " << duration.count() <<
"us" << std::endl;
76 return board !=
nullptr;
81 { wxCMD_LINE_SWITCH,
"h",
"help",
_(
"displays help on the command line parameters" ).mb_str(),
82 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
83 { wxCMD_LINE_SWITCH,
"v",
"verbose",
_(
"print parsing information" ).mb_str() },
84 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
_(
"input file" ).mb_str(), wxCMD_LINE_VAL_STRING,
85 wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
102 wxMessageOutput::Set(
new wxMessageOutputStderr );
103 wxCmdLineParser cl_parser( argc, argv );
105 cl_parser.AddUsageText(
_(
"This program parses PCB files, either from the stdin stream or "
106 "from the given filenames. This can be used either for standalone "
107 "testing of the parser or for fuzz testing." ) );
109 int cmd_parsed_ok = cl_parser.Parse();
110 if( cmd_parsed_ok != 0 )
116 const bool verbose = cl_parser.Found(
"verbose" );
118 const size_t file_count = cl_parser.GetParamCount();
120 if( file_count == 0 )
126 ok =
parse( std::cin, verbose );
134 for(
unsigned i = 0; i < file_count; i++ )
136 const auto filename = cl_parser.GetParam( i ).ToStdString();
139 std::cout <<
"Parsing: " << filename << std::endl;
142 fin.open( filename );
144 ok = ok &&
parse( fin, verbose );
156 "Parse a KiCad PCB file",
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
A small class to help profiling.
DURATION SinceStart(bool aSinceLast=false)
LINE_READER that wraps a given std::istream instance.
void SetStream(std::istream &aStream)
Set the stream for this line reader.
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.
Pcbnew s-expression file format parser definition.