39#ifndef QA_PCBNEW_DATA_LOCATION
40 #define QA_PCBNEW_DATA_LOCATION "???"
45 const char* env = std::getenv(
"KICAD_TEST_PCBNEW_DATA_DIR" );
79 PCB_PARSER parser( &reader,
nullptr,
nullptr );
80 std::unique_ptr<BOARD_ITEM> board;
84 board.reset( parser.
Parse() );
96 std::istream& aFallback )
98 std::istream* in_stream =
nullptr;
99 std::ifstream file_stream;
101 if( aFilename.empty() )
104 in_stream = &aFallback;
108 file_stream.open( aFilename );
109 in_stream = &file_stream;
112 return ReadItemFromStream<BOARD>( *in_stream );
117 std::istream& aFallback )
119 std::istream* in_stream =
nullptr;
120 std::ifstream file_stream;
122 if( aFilename.empty() )
125 in_stream = &aFallback;
129 file_stream.open( aFilename );
130 in_stream = &file_stream;
133 return ReadItemFromStream<FOOTPRINT>( *in_stream );
#define QA_PCBNEW_DATA_LOCATION
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
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 PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
LINE_READER that wraps a given std::istream instance.
void SetStream(std::istream &aStream)
Set the stream for this line reader.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
std::unique_ptr< FOOTPRINT > ReadFootprintFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
std::unique_ptr< BOARD_ITEM > ReadBoardItemFromStream(std::istream &aStream)
Utility function to read a BOARD_ITEM (probably a FOOTPRINT or a BOARD) from a file.
Pcbnew s-expression file format parser definition.