#include <qa_utils/utility_registry.h>
#include <cstdio>
#include <string>
#include <common.h>
#include <profile.h>
#include <wx/cmdline.h>
#include <board_item.h>
#include <plugins/kicad/pcb_plugin.h>
#include <plugins/kicad/pcb_parser.h>
#include <richio.h>
#include <qa_utils/stdstream_line_reader.h>
Go to the source code of this file.
◆ PARSE_DURATION
◆ PARSER_RET_CODES
Enumerator |
---|
PARSE_FAILED | |
PARSE_FAILED | |
Definition at line 98 of file pcb_parser_tool.cpp.
Tools can define their own statuses from here onwards.
◆ parse()
bool parse |
( |
std::istream & |
aStream, |
|
|
bool |
aVerbose |
|
) |
| |
Parse a PCB or footprint file from the given input stream.
- Parameters
-
aStream | the input stream to read from |
- Returns
- success, duration (in us)
Definition at line 54 of file pcb_parser_tool.cpp.
71 board = parser.
Parse();
81 std::cout <<
"Took: " << duration.count() <<
"us" << std::endl;
84 return board !=
nullptr;
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
void SetStream(std::istream &aStream)
Set the stream for this line reader.
LINE_READER that wraps a given std::istream instance.
A small class to help profiling.
LINE_READER * SetLineReader(LINE_READER *aReader)
Set aLineReader into the parser, and returns the previous one, if any.
DURATION SinceStart(bool aSinceLast=false)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
References PCB_PARSER::Parse(), PCB_PARSER::SetLineReader(), STDISTREAM_LINE_READER::SetStream(), and PROF_TIMER::SinceStart().
Referenced by PLUGIN_CONTENT_MANAGER::fetchPackages(), PCM_TASK_MANAGER::InstallFromFile(), JSON_SETTINGS::LoadFromFile(), pcb_parser_main_func(), and GERBER_JOBFILE_READER::ReadGerberJobFile().
◆ pcb_parser_main_func()
int pcb_parser_main_func |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 104 of file pcb_parser_tool.cpp.
106 #ifdef __AFL_COMPILER 110 wxMessageOutput::Set(
new wxMessageOutputStderr );
111 wxCmdLineParser cl_parser( argc, argv );
113 cl_parser.AddUsageText(
114 _(
"This program parses PCB files, either from the " 115 "stdin stream or from the given filenames. This can be used either for " 116 "standalone testing of the parser or for fuzz testing." ) );
118 int cmd_parsed_ok = cl_parser.Parse();
119 if( cmd_parsed_ok != 0 )
125 const bool verbose = cl_parser.Found(
"verbose" );
129 const auto file_count = cl_parser.GetParamCount();
131 if( file_count == 0 )
137 ok =
parse( std::cin, verbose );
145 for(
unsigned i = 0; i < file_count; i++ )
147 const auto filename = cl_parser.GetParam( i ).ToStdString();
150 std::cout <<
"Parsing: " << filename << std::endl;
153 fin.open( filename );
155 ok = ok &&
parse( fin, verbose );
The command line was not correct for the tool.
References _, KI_TEST::BAD_CMDLINE, g_cmdLineDesc, OK, parse(), and PARSE_FAILED.
◆ g_cmdLineDesc
const wxCmdLineEntryDesc g_cmdLineDesc[] |
|
static |
Initial value:= {
{ wxCMD_LINE_SWITCH,
"h",
"help",
_(
"displays help on the command line parameters" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_SWITCH,
"v",
"verbose",
_(
"print parsing information" ).mb_str() },
{ wxCMD_LINE_PARAM,
nullptr,
nullptr,
_(
"input file" ).mb_str(), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
{ wxCMD_LINE_NONE }
}
Definition at line 88 of file pcb_parser_tool.cpp.
Referenced by pcb_parser_main_func().
◆ registered
Initial value:static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
Definition at line 166 of file pcb_parser_tool.cpp.