KiCad PCB EDA Suite
|
An interface used to output 8 bit text in a convenient way. More...
#include <richio.h>
Public Member Functions | |
virtual | ~OUTPUTFORMATTER () |
This is a polymorphic class that can validly be handled by a pointer to the base class. | |
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 const char * | GetQuoteChar (const char *wrapee) const |
Perform quote character need determination. | |
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 | |
OUTPUTFORMATTER (int aReserve=OUTPUTFMTBUFZ, char aQuoteChar='"' ) | |
virtual void | write (const char *aOutBuf, int aCount)=0 |
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. | |
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] |
An interface used to output 8 bit text in a convenient way.
The primary interface is "printf() - like" but with support for indentation control. The destination of the 8 bit wide text is up to the implementer.
The implementer only has to implement the write() function, but can also optionally re-implement GetQuoteChar().
If you want to output a wxString, then use TO_UTF8() on it before passing it as an argument to Print().
Since this is an abstract interface, only classes derived from this one may actually be used.
|
inlineprotected |
Definition at line 324 of file richio.h.
References m_buffer, OUTPUTFMTBUFZ, and quoteChar.
Referenced by FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER(), PRETTIFIED_FILE_OUTPUTFORMATTER::PRETTIFIED_FILE_OUTPUTFORMATTER(), and STRING_FORMATTER::STRING_FORMATTER().
|
inlinevirtual |
|
inlinevirtual |
Performs any cleanup needed at the end of a write.
Reimplemented in PRETTIFIED_FILE_OUTPUTFORMATTER.
|
virtual |
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 419 of file richio.cpp.
References GetQuoteChar(), and quoteChar.
|
staticprotected |
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 385 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 | ( | const char * | fmt, |
... ) |
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 492 of file richio.cpp.
int OUTPUTFORMATTER::Print | ( | int | nestLevel, |
const char * | fmt, | ||
... ) |
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 463 of file richio.cpp.
References NESTWIDTH, result, sprint(), and vprint().
Referenced by COMPONENT::Format(), COMPONENT_NET::Format(), DESIGN_BLOCK_LIB_TABLE::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(), FP_LIB_TABLE::Format(), LIB_TABLE_ROW::Format(), NETLIST::Format(), PAGE_INFO::Format(), PCB_CALCULATOR_DATAFILE::Format(), PCB_PLOT_PARAMS::Format(), STROKE_PARAMS::Format(), SYMBOL_LIB_TABLE::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(), formatFill(), DSN::PIN_REF::FormatIt(), formatNode(), KICAD_FORMAT::FormatOptBool(), formatPoly(), formatRect(), KICAD_FORMAT::FormatStreamData(), 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_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_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().
|
virtual |
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 509 of file richio.cpp.
Referenced by formatNode(), Quotew(), and SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol().
std::string OUTPUTFORMATTER::Quotew | ( | const wxString & | aWrapee | ) | const |
Definition at line 548 of file richio.cpp.
References Quotes().
Referenced by COMPONENT::Format(), COMPONENT_NET::Format(), EDA_TEXT::Format(), LIB_TABLE_ROW::Format(), PAGE_INFO::Format(), PCB_CALCULATOR_DATAFILE::Format(), PCB_PLOT_PARAMS::Format(), TEMPLATE_FIELDNAME::Format(), TITLE_BLOCK::Format(), formatArc(), formatBezier(), BOARD_STACKUP::FormatBoardStackup(), formatCircle(), XNODE::FormatContents(), formatPoly(), formatRect(), KICAD_FORMAT::FormatUuid(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox(), EMBEDDED_FILES::WriteEmbeddedFiles(), and PCB_CALCULATOR_DATAFILE::WriteHeader().
|
private |
|
private |
|
protectedpure virtual |
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. |
Implemented in FILE_OUTPUTFORMATTER, PRETTIFIED_FILE_OUTPUTFORMATTER, and STRING_FORMATTER.
Referenced by vprint().
|
private |
Definition at line 434 of file richio.h.
Referenced by OUTPUTFORMATTER(), and vprint().
|
private |
Definition at line 435 of file richio.h.
Referenced by GetQuoteChar(), and OUTPUTFORMATTER().