31#include <wx/cmdline.h>
50bool parse( std::istream& aStream,
bool aVerbose )
64 board = parser.
Parse();
74 std::cout <<
"Took: " << duration.count() <<
"us" << std::endl;
77 return board !=
nullptr;
82 { wxCMD_LINE_SWITCH,
"h",
"help",
_(
"displays help on the command line parameters" ).mb_str(),
83 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
84 { wxCMD_LINE_SWITCH,
"v",
"verbose",
_(
"print parsing information" ).mb_str() },
85 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
_(
"input file" ).mb_str(), wxCMD_LINE_VAL_STRING,
86 wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
103 wxMessageOutput::Set(
new wxMessageOutputStderr );
104 wxCmdLineParser cl_parser( argc, argv );
106 cl_parser.AddUsageText(
_(
"This program parses PCB files, either from the stdin stream or "
107 "from the given filenames. This can be used either for standalone "
108 "testing of the parser or for fuzz testing." ) );
110 int cmd_parsed_ok = cl_parser.Parse();
111 if( cmd_parsed_ok != 0 )
117 const bool verbose = cl_parser.Found(
"verbose" );
119 const size_t file_count = cl_parser.GetParamCount();
121 if( file_count == 0 )
127 ok =
parse( std::cin, verbose );
135 for(
unsigned i = 0; i < file_count; i++ )
137 const auto filename = cl_parser.GetParam( i ).ToStdString();
140 std::cout <<
"Parsing: " << filename << std::endl;
143 fin.open( filename );
145 ok = ok &&
parse( fin, verbose );
150 return PARSER_RET_CODES::PARSE_FAILED;
157 "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.