KiCad PCB EDA Suite
|
Used for text file output. More...
#include <richio.h>
Public Member Functions | |
FILE_OUTPUTFORMATTER (const wxString &aFileName, const wxChar *aMode=wxT("wt"), char aQuoteChar='"' ) | |
~FILE_OUTPUTFORMATTER () | |
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. | |
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 |
virtual bool | Finish () |
Performs any cleanup needed at the end of a write. | |
Protected Member Functions | |
void | write (const char *aOutBuf, int aCount) override |
Should be coded in the interface implementation (derived) classes. | |
Static Protected Member Functions | |
static const char * | GetQuoteChar (const char *wrapee, const char *quote_char) |
Perform quote character need determination according to the Specctra DSN specification. | |
Protected Attributes | |
FILE * | m_fp |
takes ownership | |
wxString | m_filename |
Private Member Functions | |
int | sprint (const char *fmt,...) |
int | vprint (const char *fmt, va_list ap) |
Private Attributes | |
std::vector< char > | m_buffer |
char | quoteChar [2] |
Used for text file output.
It is about 8 times faster than STREAM_OUTPUTFORMATTER for file streams.
FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER | ( | const wxString & | aFileName, |
const wxChar * | aMode = wxT( "wt" ) , |
||
char | aQuoteChar = '"' |
||
) |
aFileName | is the full filename to open and save to as a text file. |
aMode | is what you would pass to wxFopen()'s mode, defaults to wxT( "wt" ) for text files that are to be created here and now. |
aQuoteChar | is a char used for quoting problematic strings (with whitespace or special characters in them). |
IO_ERROR | if the file cannot be opened. |
Definition at line 577 of file richio.cpp.
References m_fp, and THROW_IO_ERROR.
FILE_OUTPUTFORMATTER::~FILE_OUTPUTFORMATTER | ( | ) |
Definition at line 589 of file richio.cpp.
References m_fp.
|
inlinevirtualinherited |
Performs any cleanup needed at the end of a write.
Reimplemented in PRETTIFIED_FILE_OUTPUTFORMATTER.
Definition at line 431 of file richio.h.
Referenced by PCB_IO_KICAD_SEXPR::SaveBoard().
|
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.
wrapee | A string that might need wrapping on each end. |
Definition at line 414 of file richio.cpp.
References OUTPUTFORMATTER::GetQuoteChar(), and OUTPUTFORMATTER::quoteChar.
|
staticprotectedinherited |
Perform quote character need determination according to the Specctra DSN specification.
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. |
Definition at line 380 of file richio.cpp.
Referenced by DSN::PROPERTY::Format(), DSN::RECTANGLE::Format(), DSN::LAYER_RULE::Format(), DSN::PATH::Format(), DSN::CIRCLE::Format(), DSN::QARC::Format(), DSN::KEEPOUT::Format(), DSN::VIA::Format(), DSN::LAYER::Format(), DSN::SPECCTRA_LAYER_PAIR::Format(), DSN::STRINGPROP::Format(), DSN::PLACE::Format(), DSN::COMPONENT::Format(), DSN::PIN::Format(), DSN::IMAGE::Format(), DSN::PADSTACK::Format(), DSN::FROMTO::Format(), DSN::COMP_ORDER::Format(), DSN::NET::Format(), DSN::CLASS::Format(), DSN::WIRE::Format(), DSN::WIRE_VIA::Format(), DSN::PCB::Format(), DSN::ANCESTOR::Format(), DSN::SUPPLY_PIN::Format(), DSN::NET_OUT::Format(), DSN::SESSION::Format(), DSN::PARSER::FormatContents(), DSN::CLASSES::FormatContents(), DSN::REGION::FormatContents(), DSN::PADSTACK::FormatContents(), DSN::HISTORY::FormatContents(), DSN::PIN_REF::FormatIt(), and OUTPUTFORMATTER::GetQuoteChar().
|
inherited |
Format and write text to the output stream.
fmt | A printf() style format string. |
... | a variable list of parameters that will get blended into the output under control of the format string. |
IO_ERROR,if | there is a problem outputting, such as a full disk. |
Definition at line 487 of file richio.cpp.
References OUTPUTFORMATTER::vprint().
|
inherited |
Format and write text to the output stream.
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. |
IO_ERROR,if | there is a problem outputting, such as a full disk. |
Definition at line 458 of file richio.cpp.
References NESTWIDTH, OUTPUTFORMATTER::sprint(), and OUTPUTFORMATTER::vprint().
Referenced by PCB_IO_KICAD_SEXPR::format(), NETLIST::Format(), DS_DATA_MODEL_IO::format(), DS_DATA_MODEL_IO::Format(), PAGE_INFO::Format(), TITLE_BLOCK::Format(), PCB_PLOT_PARAMS::Format(), EDA_TEXT::Format(), PCB_CALCULATOR_DATAFILE::Format(), COMPONENT_NET::Format(), COMPONENT::Format(), SYMBOL_LIB_TABLE::Format(), DESIGN_BLOCK_LIB_TABLE::Format(), FP_LIB_TABLE::Format(), TEMPLATE_FIELDNAME::Format(), TEMPLATES::Format(), STROKE_PARAMS::Format(), XNODE::Format(), DSN::ELEM::Format(), LIB_TABLE_ROW::Format(), DSN::POINT::Format(), DSN::PROPERTY::Format(), DSN::UNIT_RES::Format(), DSN::RECTANGLE::Format(), DSN::RULE::Format(), DSN::LAYER_RULE::Format(), DSN::PATH::Format(), DSN::BOUNDARY::Format(), DSN::CIRCLE::Format(), DSN::QARC::Format(), DSN::WINDOW::Format(), DSN::KEEPOUT::Format(), DSN::VIA::Format(), DSN::CONTROL::Format(), DSN::LAYER::Format(), DSN::SPECCTRA_LAYER_PAIR::Format(), DSN::LAYER_NOISE_WEIGHT::Format(), DSN::TOKPROP::Format(), DSN::STRINGPROP::Format(), DSN::GRID::Format(), DSN::PLACE::Format(), DSN::COMPONENT::Format(), DSN::SHAPE::Format(), DSN::PIN::Format(), DSN::IMAGE::Format(), DSN::PADSTACK::Format(), DSN::FROMTO::Format(), DSN::COMP_ORDER::Format(), DSN::NET::Format(), DSN::CLASS::Format(), DSN::WIRE::Format(), DSN::WIRE_VIA::Format(), DSN::PCB::Format(), DSN::ANCESTOR::Format(), DSN::SUPPLY_PIN::Format(), DSN::NET_OUT::Format(), DSN::SESSION::Format(), SCH_IO_KICAD_LEGACY::Format(), SCH_IO_KICAD_SEXPR::Format(), formatArc(), formatBezier(), PCB_IO_KICAD_SEXPR::formatBoardLayers(), BOARD_STACKUP::FormatBoardStackup(), KICAD_FORMAT::FormatBool(), formatCircle(), XNODE::FormatContents(), DSN::PARSER::FormatContents(), DSN::CLASSES::FormatContents(), DSN::REGION::FormatContents(), DSN::PLACEMENT::FormatContents(), DSN::IMAGE::FormatContents(), DSN::PADSTACK::FormatContents(), DSN::HISTORY::FormatContents(), DSN::ROUTE::FormatContents(), DSN::WAS_IS::FormatContents(), DS_DATA_MODEL_IO::formatCoordinate(), formatFill(), PCB_IO_KICAD_SEXPR::formatGeneral(), DSN::PIN_REF::FormatIt(), PCB_IO_KICAD_SEXPR::formatLayer(), PCB_IO_KICAD_SEXPR::formatLayers(), PCB_IO_KICAD_SEXPR::formatNetInformation(), formatNode(), DS_DATA_MODEL_IO::formatOptions(), formatPoly(), PCB_IO_KICAD_SEXPR::formatPolyPts(), PCB_IO_KICAD_SEXPR::formatProperties(), formatRect(), PCB_IO_KICAD_SEXPR::formatRenderCache(), DS_DATA_MODEL_IO::formatRepeatParameters(), PCB_IO_KICAD_SEXPR::formatSetup(), PCB_IO_KICAD_SEXPR::formatTeardropParameters(), PCB_IO_KICAD_SEXPR::formatTenting(), KICAD_FORMAT::FormatUuid(), GENDRILL_WRITER_BASE::GenDrillReportFile(), GENDRILL_WRITER_BASE::printToolSummary(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier(), SCH_IO_KICAD_LEGACY::saveBitmap(), SCH_IO_KICAD_SEXPR::saveBitmap(), CLIPBOARD_IO::SaveBoard(), PCB_IO_KICAD_SEXPR::SaveBoard(), SCH_IO_KICAD_LEGACY::saveBusAlias(), SCH_IO_KICAD_SEXPR::saveBusAlias(), SCH_IO_KICAD_LEGACY::saveBusEntry(), SCH_IO_KICAD_SEXPR::saveBusEntry(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveDocFile(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField(), SCH_IO_KICAD_LEGACY::saveField(), SCH_IO_KICAD_SEXPR::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR::saveInstances(), SCH_IO_KICAD_LEGACY::saveJunction(), SCH_IO_KICAD_SEXPR::saveJunction(), SCH_IO_KICAD_LEGACY::saveLine(), SCH_IO_KICAD_SEXPR::saveLine(), SCH_IO_KICAD_LEGACY::saveNoConnect(), SCH_IO_KICAD_SEXPR::saveNoConnect(), SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle(), SCH_IO_KICAD_SEXPR::saveRuleArea(), CLIPBOARD_IO::SaveSelection(), SCH_IO_KICAD_LEGACY::saveSheet(), SCH_IO_KICAD_SEXPR::saveSheet(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_LEGACY::saveSymbol(), SCH_IO_KICAD_SEXPR::saveSymbol(), SCH_IO_KICAD_SEXPR::saveTable(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveText(), SCH_IO_KICAD_LEGACY::saveText(), SCH_IO_KICAD_SEXPR::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR::saveTextBox(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox(), PANEL_REGULATOR::WriteDataFile(), SPICE_CIRCUIT_MODEL::WriteDirectives(), NETLIST_EXPORTER_SPICE::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().
|
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.
aWrapee | is a string that might need wrapping in double quotes, and it might need to have its internal content escaped, or not. |
IO_ERROR,if | there is any kind of problem with the input string. |
Definition at line 504 of file richio.cpp.
Referenced by PCB_IO_KICAD_SEXPR::format(), formatNode(), OUTPUTFORMATTER::Quotew(), and SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol().
|
inherited |
Definition at line 543 of file richio.cpp.
References OUTPUTFORMATTER::Quotes().
Referenced by PCB_IO_KICAD_SEXPR::format(), DS_DATA_MODEL_IO::format(), DS_DATA_MODEL_IO::Format(), PAGE_INFO::Format(), TITLE_BLOCK::Format(), PCB_PLOT_PARAMS::Format(), EDA_TEXT::Format(), PCB_CALCULATOR_DATAFILE::Format(), COMPONENT_NET::Format(), COMPONENT::Format(), TEMPLATE_FIELDNAME::Format(), LIB_TABLE_ROW::Format(), SCH_IO_KICAD_SEXPR::Format(), PCB_IO_KICAD_SEXPR::formatBoardLayers(), BOARD_STACKUP::FormatBoardStackup(), XNODE::FormatContents(), PCB_IO_KICAD_SEXPR::formatLayer(), PCB_IO_KICAD_SEXPR::formatLayers(), PCB_IO_KICAD_SEXPR::formatNetInformation(), PCB_IO_KICAD_SEXPR::formatProperties(), PCB_IO_KICAD_SEXPR::formatRenderCache(), KICAD_FORMAT::FormatUuid(), CLIPBOARD_IO::SaveBoard(), PCB_IO_KICAD_SEXPR::SaveBoard(), SCH_IO_KICAD_SEXPR::saveBusAlias(), SCH_IO_KICAD_SEXPR::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR::saveInstances(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), CLIPBOARD_IO::SaveSelection(), SCH_IO_KICAD_SEXPR::saveSheet(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR::saveSymbol(), SCH_IO_KICAD_SEXPR::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR::saveTextBox(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox(), EMBEDDED_FILES::WriteEmbeddedFiles(), and PCB_CALCULATOR_DATAFILE::WriteHeader().
|
privateinherited |
Definition at line 446 of file richio.cpp.
References OUTPUTFORMATTER::vprint().
Referenced by OUTPUTFORMATTER::Print().
|
privateinherited |
Definition at line 420 of file richio.cpp.
References OUTPUTFORMATTER::m_buffer, and OUTPUTFORMATTER::write().
Referenced by OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::sprint().
|
overrideprotectedvirtual |
Should be coded in the interface implementation (derived) classes.
aOutBuf | is the start of a byte buffer to write. |
aCount | tells how many bytes to write. |
IO_ERROR,if | there is a problem outputting, such as a full disk. |
Implements OUTPUTFORMATTER.
Definition at line 596 of file richio.cpp.
References m_fp, and THROW_IO_ERROR.
|
privateinherited |
Definition at line 434 of file richio.h.
Referenced by OUTPUTFORMATTER::vprint().
|
protected |
takes ownership
Definition at line 510 of file richio.h.
Referenced by FILE_OUTPUTFORMATTER(), write(), and ~FILE_OUTPUTFORMATTER().
|
privateinherited |
Definition at line 435 of file richio.h.
Referenced by OUTPUTFORMATTER::GetQuoteChar().