KiCad PCB EDA Suite
numEval::OUTPUTFORMATTER Class Referenceabstract

Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient way. More...

Inheritance diagram for numEval::OUTPUTFORMATTER:
numEval::FILE_OUTPUTFORMATTER numEval::STREAM_OUTPUTFORMATTER numEval::STRING_FORMATTER

Public Member Functions

int PRINTF_FUNC Print (int nestLevel, const char *fmt,...)
 Function Print formats and writes text to the output stream. More...
 
virtual const char * GetQuoteChar (const char *wrapee)
 Function GetQuoteChar performs quote character need determination. More...
 
virtual std::string Quotes (const std::string &aWrapee)
 Function Quotes checks aWrapee input string for a need to be quoted (e.g. More...
 
std::string Quotew (const wxString &aWrapee)
 

Protected Member Functions

 OUTPUTFORMATTER (int aReserve=OUTPUTFMTBUFZ, char aQuoteChar= '"' )
 
virtual ~OUTPUTFORMATTER ()
 
virtual void write (const char *aOutBuf, int aCount)=0
 Function write should be coded in the interface implementation (derived) classes. More...
 

Static Protected Member Functions

static const char * GetQuoteChar (const char *wrapee, const char *quote_char)
 Function GetQuoteChar performs quote character need determination according to the Specctra DSN specification. More...
 

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]
 

Detailed Description

Class OUTPUTFORMATTER is an important interface (abstract class) 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 327 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

numEval::OUTPUTFORMATTER::OUTPUTFORMATTER ( int  aReserve = OUTPUTFMTBUFZ,
char  aQuoteChar = '"' 
)
inlineprotected

Definition at line 337 of file numeric_evaluator.cpp.

354  {
virtual numEval::OUTPUTFORMATTER::~OUTPUTFORMATTER ( )
inlineprotectedvirtual

Definition at line 344 of file numeric_evaluator.cpp.

354 {

Member Function Documentation

static const char* numEval::OUTPUTFORMATTER::GetQuoteChar ( const char *  wrapee,
const char *  quote_char 
)
staticprotected

Function GetQuoteChar performs quote character need determination according to the Specctra DSN specification.

Parameters
wrapeeA string that might need wrapping on each end.
quote_charA single character C string which provides the current quote character, should it be needed by the wrapee.
Returns
const char* - the quote_char as a single character string, or "" if the wrapee does not need to be wrapped.
virtual const char* numEval::OUTPUTFORMATTER::GetQuoteChar ( const char *  wrapee)
virtual

Function GetQuoteChar performs 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
wrapeeA string that might need wrapping on each end.
Returns
const char* - the quote_char as a single character string, or "" if the wrapee does not need to be wrapped.
int PRINTF_FUNC numEval::OUTPUTFORMATTER::Print ( int  nestLevel,
const char *  fmt,
  ... 
)

Function Print formats and writes text to the output stream.

Parameters
nestLevelThe multiple of spaces to precede the output with.
fmtA 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,ifthere is a problem outputting, such as a full disk.
virtual std::string numEval::OUTPUTFORMATTER::Quotes ( const std::string &  aWrapee)
virtual

Function Quotes checks 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
aWrapeeis a string that might need wraping in double quotes, and it might need to have its internal content escaped, or not.
Returns
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,ifthere is any kind of problem with the input string.
std::string numEval::OUTPUTFORMATTER::Quotew ( const wxString &  aWrapee)
int numEval::OUTPUTFORMATTER::sprint ( const char *  fmt,
  ... 
)
private
int numEval::OUTPUTFORMATTER::vprint ( const char *  fmt,
va_list  ap 
)
private
virtual void numEval::OUTPUTFORMATTER::write ( const char *  aOutBuf,
int  aCount 
)
protectedpure virtual

Function write should be coded in the interface implementation (derived) classes.

Parameters
aOutBufis the start of a byte buffer to write.
aCounttells how many bytes to write.
Exceptions
IO_ERROR,ifthere is a problem outputting, such as a full disk.

Implemented in numEval::STREAM_OUTPUTFORMATTER, numEval::FILE_OUTPUTFORMATTER, and numEval::STRING_FORMATTER.

Member Data Documentation

std::vector<char> numEval::OUTPUTFORMATTER::m_buffer
private

Definition at line 329 of file numeric_evaluator.cpp.

char numEval::OUTPUTFORMATTER::quoteChar[2]
private

Definition at line 330 of file numeric_evaluator.cpp.


The documentation for this class was generated from the following file: