|
| | FILE_OUTPUTFORMATTER (const wxString &aFileName, const wxChar *aMode=wxT("wt"), char aQuoteChar='"' ) |
| |
| | ~FILE_OUTPUTFORMATTER () |
| |
| bool | Finish () override |
| | Flushes the temp file to disk and atomically renames it over the final target path.
|
| |
| virtual const char * | GetQuoteChar (const char *wrapee) const |
| | Perform quote character need determination.
|
| |
| int PRINTF_FUNC_N | Print (int nestLevel, const char *fmt,...) |
| | Format and write text to the output stream.
|
| |
| int PRINTF_FUNC | Print (const char *fmt,...) |
| | Format and write text to the output stream.
|
| |
| int | Indent (int aNestLevel) |
| | Write the leading whitespace for a nesting level, with no other output.
|
| |
| virtual std::string | Quotes (const std::string &aWrapee) const |
| | Check aWrapee input string for a need to be quoted (e.g.
|
| |
| std::string | Quotew (const wxString &aWrapee) const |
| |
Used for text file output.
Writes through a sibling temp file and atomically renames onto the final target in Finish(). A crash, throw, or power loss between construction and Finish() leaves the final target byte-identical to its prior contents – never truncated. Finish() must be called to save; otherwise the destructor discards the temp file and leaves the target untouched.
It is about 8 times faster than STREAM_OUTPUTFORMATTER for file streams.
Definition at line 482 of file richio.h.
| bool FILE_OUTPUTFORMATTER::Finish |
( |
| ) |
|
|
overridevirtual |
Flushes the temp file to disk and atomically renames it over the final target path.
After a successful return the final target contains the bytes written. A failure before the rename leaves the original contents intact; a directory-flush failure after the rename throws even though the new contents are already visible, because only their durability is in doubt.
Finish() must be called at most once. Calling it again (whether the commit succeeded or failed) is a programming error.
- Returns
- true on successful commit.
- Exceptions
-
| IO_ERROR | if fsync, close, rename, or the directory flush fails. |
Reimplemented from OUTPUTFORMATTER.
Definition at line 682 of file richio.cpp.
References m_tempFile.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOARD_EDITOR_CONTROL::ExportNetlist(), DSN::SPECCTRA_DB::ExportPCB(), DSN::SPECCTRA_DB::ExportSESSION(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveDocFile(), SCH_IO_KICAD_LEGACY::SaveSchematicFile(), PANEL_REGULATOR::WriteDataFile(), NETLIST_EXPORTER_SPICE::writeNetlist(), and ~FILE_OUTPUTFORMATTER().
| const char * OUTPUTFORMATTER::GetQuoteChar |
( |
const char * | wrapee | ) |
const |
|
virtualinherited |
Perform quote character need determination.
It returns the quote character as a single character string for a given input wrapee string. If the wrappee does not need to be quoted, the return value is "" (the null string), such as when there are no delimiters in the input wrapee string. If you want the quote_char to be assuredly not "", then pass in "(" as the wrappee.
Implementations are free to override the default behavior, which is to call the static function of the same name.
- Parameters
-
| wrapee | A string that might need wrapping on each end. |
- Returns
- the quote_char as a single character string, or "" if the wrapee does not need to be wrapped.
Definition at line 372 of file richio.cpp.
References GetQuoteChar(), and quoteChar.
| const char * OUTPUTFORMATTER::GetQuoteChar |
( |
const char * | wrapee, |
|
|
const char * | quote_char ) |
|
staticprotectedinherited |
Perform quote character need determination according to the Specctra DSN specification.
- Parameters
-
| wrapee | A string that might need wrapping on each end. |
| quote_char | A single character C string which provides the current quote character, should it be needed by the wrapee. |
- Returns
- the quote_char as a single character string, or "" if the wrapee does not need to be wrapped.
Definition at line 338 of file richio.cpp.
Referenced by DSN::ANCESTOR::Format(), DSN::CIRCLE::Format(), DSN::CLASS::Format(), DSN::COMP_ORDER::Format(), DSN::COMPONENT::Format(), DSN::FROMTO::Format(), DSN::IMAGE::Format(), DSN::KEEPOUT::Format(), DSN::LAYER::Format(), DSN::LAYER_RULE::Format(), DSN::NET::Format(), DSN::NET_OUT::Format(), DSN::PADSTACK::Format(), DSN::PATH::Format(), DSN::PCB::Format(), DSN::PIN::Format(), DSN::PLACE::Format(), DSN::PROPERTY::Format(), DSN::QARC::Format(), DSN::RECTANGLE::Format(), DSN::SESSION::Format(), DSN::SPECCTRA_LAYER_PAIR::Format(), DSN::STRINGPROP::Format(), DSN::SUPPLY_PIN::Format(), DSN::VIA::Format(), DSN::WIRE::Format(), DSN::WIRE_VIA::Format(), DSN::CLASSES::FormatContents(), DSN::HISTORY::FormatContents(), DSN::PADSTACK::FormatContents(), DSN::PARSER::FormatContents(), DSN::REGION::FormatContents(), DSN::PIN_REF::FormatIt(), and GetQuoteChar().
| int OUTPUTFORMATTER::Print |
( |
int | nestLevel, |
|
|
const char * | fmt, |
|
|
| ... ) |
|
inherited |
Format and write text to the output stream.
- Parameters
-
| nestLevel | The multiple of spaces to precede the output with. |
| fmt | A printf() style format string. |
| ... | a variable list of parameters that will get blended into the output under control of the format string. |
- Returns
- int - the number of characters output.
- Exceptions
-
| IO_ERROR,if | there is a problem outputting, such as a full disk. |
Definition at line 432 of file richio.cpp.
References Indent(), and vprint().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CopySexprFile(), COMPONENT::Format(), COMPONENT_NET::Format(), DSN::ANCESTOR::Format(), DSN::BOUNDARY::Format(), DSN::CIRCLE::Format(), DSN::CLASS::Format(), DSN::COMP_ORDER::Format(), DSN::COMPONENT::Format(), DSN::CONTROL::Format(), DSN::ELEM::Format(), DSN::FROMTO::Format(), DSN::GRID::Format(), DSN::IMAGE::Format(), DSN::KEEPOUT::Format(), DSN::LAYER::Format(), DSN::LAYER_NOISE_WEIGHT::Format(), DSN::LAYER_RULE::Format(), DSN::NET::Format(), DSN::NET_OUT::Format(), DSN::PADSTACK::Format(), DSN::PATH::Format(), DSN::PCB::Format(), DSN::PIN::Format(), DSN::PLACE::Format(), DSN::POINT::Format(), DSN::PROPERTY::Format(), DSN::QARC::Format(), DSN::RECTANGLE::Format(), DSN::RULE::Format(), DSN::SESSION::Format(), DSN::SHAPE::Format(), DSN::SPECCTRA_LAYER_PAIR::Format(), DSN::STRINGPROP::Format(), DSN::SUPPLY_PIN::Format(), DSN::TOKPROP::Format(), DSN::UNIT_RES::Format(), DSN::VIA::Format(), DSN::WINDOW::Format(), DSN::WIRE::Format(), DSN::WIRE_VIA::Format(), EDA_TEXT::Format(), LINE_ENDING::Format(), NETLIST::Format(), PAGE_INFO::Format(), PCB_CALCULATOR_DATAFILE::Format(), PCB_PLOT_PARAMS::Format(), STROKE_PARAMS::Format(), TEMPLATE_FIELDNAME::Format(), TEMPLATES::Format(), TITLE_BLOCK::Format(), XNODE::Format(), formatArc(), formatBezier(), BOARD_STACKUP::FormatBoardStackup(), KICAD_FORMAT::FormatBool(), formatCircle(), DSN::CLASSES::FormatContents(), DSN::HISTORY::FormatContents(), DSN::IMAGE::FormatContents(), DSN::PADSTACK::FormatContents(), DSN::PARSER::FormatContents(), DSN::PLACEMENT::FormatContents(), DSN::REGION::FormatContents(), DSN::ROUTE::FormatContents(), DSN::WAS_IS::FormatContents(), XNODE::FormatContents(), KICAD_FORMAT::FormatCustomProperties(), formatDrillSpan(), formatEllipse(), formatEllipseArc(), formatFill(), DSN::PIN_REF::FormatIt(), SCH_IO_KICAD_SEXPR_LIB_CACHE::formatLibraryHeader(), formatNode(), KICAD_FORMAT::FormatOptBool(), formatPinMapOverride(), formatPoly(), formatRect(), KICAD_FORMAT::FormatStreamData(), KICAD_FORMAT::FormatUuid(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveDocFile(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePinMapData(), SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle(), SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox(), PANEL_REGULATOR::WriteDataFile(), NETLIST_EXPORTER_SPICE::WriteDirectives(), SPICE_CIRCUIT_MODEL::WriteDirectives(), EMBEDDED_FILES::WriteEmbeddedFiles(), NETLIST_EXPORTER_SPICE::WriteHead(), NETLIST_EXPORTER_SPICE_MODEL::WriteHead(), PCB_CALCULATOR_DATAFILE::WriteHeader(), NETLIST_EXPORTER_SPICE::writeInclude(), NETLIST_EXPORTER_SPICE::writeItems(), NETLIST_EXPORTER_SPICE::writeModels(), NETLIST_EXPORTER_SPICE::WriteTail(), and NETLIST_EXPORTER_SPICE_MODEL::WriteTail().
| std::string OUTPUTFORMATTER::Quotes |
( |
const std::string & | aWrapee | ) |
const |
|
virtualinherited |
Check aWrapee input string for a need to be quoted (e.g.
contains a ')' character or a space), and for " double quotes within the string that need to be escaped such that the DSNLEXER will correctly parse the string from a file later.
- Parameters
-
| aWrapee | is a string that might need wrapping in double quotes, and it might need to have its internal content escaped, or not. |
- Returns
- a std::string- whose c_str() function can be called for passing to printf() style functions that output UTF8 encoded s-expression streams.
- Exceptions
-
| IO_ERROR,if | there is any kind of problem with the input string. |
Definition at line 466 of file richio.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), formatNode(), Quotew(), and SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol().