38#ifndef QA_PCBNEW_DATA_LOCATION
39 #define QA_PCBNEW_DATA_LOCATION "???"
44 const char* env = std::getenv(
"KICAD_TEST_PCBNEW_DATA_DIR" );
68 io.
Save( aFilename, &board );
78 PCB_PARSER parser( &reader,
nullptr,
nullptr );
79 std::unique_ptr<BOARD_ITEM> board;
83 board.reset( parser.
Parse() );
94 std::istream& aFallback )
96 std::istream* in_stream =
nullptr;
97 std::ifstream file_stream;
99 printf(
"RD from %s\n", aFilename.c_str() );
101 if( aFilename.empty() )
104 in_stream = &aFallback;
108 file_stream.open( aFilename );
109 in_stream = &file_stream;
112 return ReadItemFromStream<BOARD>( *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 Save(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=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.
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.