39#ifndef QA_PCBNEW_DATA_LOCATION
40 #define QA_PCBNEW_DATA_LOCATION "???"
45 const char* env = std::getenv(
"KICAD_TEST_PCBNEW_DATA_DIR" );
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 );
110 if( !file_stream.is_open() )
115 in_stream = &file_stream;
118 return ReadItemFromStream<BOARD>( *in_stream );
123 std::istream& aFallback )
125 std::istream* in_stream =
nullptr;
126 std::ifstream file_stream;
128 if( aFilename.empty() )
131 in_stream = &aFallback;
135 file_stream.open( aFilename );
137 if( !file_stream.is_open() )
142 in_stream = &file_stream;
145 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 std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO 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.