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.
Definition at line 306 of file richio.h.
const char * OUTPUTFORMATTER::GetQuoteChar |
( |
const char * |
wrapee, |
|
|
const char * |
quote_char |
|
) |
| |
|
staticprotected |
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 331 of file richio.cpp.
340 if( strlen( wrapee ) == 0 )
345 for( ; *wrapee; ++wrapee, isFirst = false )
347 static const char quoteThese[] =
"\t ()" 354 if( strchr( quoteThese, *wrapee ) )
357 if( !isFirst &&
'-' == *wrapee )
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 GetQuoteChar().
const char * OUTPUTFORMATTER::GetQuoteChar |
( |
const char * |
wrapee | ) |
const |
|
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.
- 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 365 of file richio.cpp.
References GetQuoteChar(), and quoteChar.
int OUTPUTFORMATTER::Print |
( |
int |
nestLevel, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
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 408 of file richio.cpp.
414 va_start( args, fmt );
419 for(
int i = 0; i < nestLevel; ++i )
428 result =
vprint( fmt, args );
References NESTWIDTH, sprint(), and vprint().
Referenced by PANEL_SYM_LIB_TABLE::convertLibrary(), PCB_CALCULATOR_DATAFILE::Format(), COMPONENT_NET::Format(), TEMPLATE_FIELDNAME::Format(), XNODE::Format(), FP_LIB_TABLE::Format(), SCH_LEGACY_PLUGIN::Format(), SYMBOL_LIB_TABLE::Format(), TEMPLATES::Format(), TITLE_BLOCK::Format(), NETLIST_EXPORTER_PSPICE::Format(), DSN::POINT::Format(), DSN::PROPERTY::Format(), PAGE_INFO::Format(), LIB_TABLE_ROW::Format(), COMPONENT::Format(), PCB_PLOT_PARAMS::Format(), PCB_IO::format(), DSN::ELEM::Format(), NETLIST::Format(), EDA_TEXT::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(), PCB_IO::formatBoardLayers(), BOARD_STACKUP::FormatBoardStackup(), 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(), formatFill(), PCB_IO::formatGeneral(), DSN::PIN_REF::FormatIt(), PCB_IO::formatLayer(), PCB_IO::formatLayers(), PCB_IO::formatNetInformation(), formatNode(), PCB_IO::formatProperties(), PCB_IO::formatSetup(), formatStroke(), GENDRILL_WRITER_BASE::GenDrillReportFile(), GENDRILL_WRITER_BASE::printToolSummary(), CLIPBOARD_IO::Save(), PCB_IO::Save(), SCH_SEXPR_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_SEXPR_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN::saveBitmap(), SCH_LEGACY_PLUGIN::saveBusAlias(), SCH_LEGACY_PLUGIN::saveBusEntry(), SCH_SEXPR_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_LEGACY_PLUGIN_CACHE::saveDocFile(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveJunction(), SCH_LEGACY_PLUGIN::saveLine(), SCH_LEGACY_PLUGIN::saveNoConnect(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_SEXPR_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), CLIPBOARD_IO::SaveSelection(), SCH_LEGACY_PLUGIN::saveSheet(), SCH_SEXPR_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), PCB_CALCULATOR_FRAME::WriteDataFile(), NETLIST_EXPORTER_PSPICE_SIM::writeDirectives(), NETLIST_EXPORTER_PSPICE::writeDirectives(), and PCB_CALCULATOR_DATAFILE::WriteHeader().
std::string OUTPUTFORMATTER::Quotes |
( |
const std::string & |
aWrapee | ) |
const |
|
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.
- 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 437 of file richio.cpp.
441 ret.reserve( aWrapee.size() * 2 + 2 );
445 for( std::string::const_iterator it = aWrapee.begin(); it != aWrapee.end(); ++it )
Referenced by PCB_IO::format(), formatNode(), Quotew(), and SCH_SEXPR_PLUGIN_CACHE::SaveSymbol().