KiCad PCB EDA Suite
numEval::STRING_FORMATTER Class Reference

Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer. More...

Inheritance diagram for numEval::STRING_FORMATTER:
numEval::OUTPUTFORMATTER

Public Member Functions

 STRING_FORMATTER (int aReserve=OUTPUTFMTBUFZ, char aQuoteChar= '"' )
 Constructor STRING_FORMATTER reserves space in the buffer. More...
 
void Clear ()
 Function Clear clears the buffer and empties the internal string. More...
 
void StripUseless ()
 Function StripUseless removes whitespace, '(', and ')' from the mystring. More...
 
const std::string & GetString ()
 
virtual const char * GetQuoteChar (const char *wrapee)
 Function GetQuoteChar performs quote character need determination. More...
 
int PRINTF_FUNC Print (int nestLevel, const char *fmt,...)
 Function Print formats and writes text to the output stream. 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

void write (const char *aOutBuf, int aCount) override
 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 Attributes

std::string m_mystring
 

Detailed Description

Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.

After Print()ing the string is available through GetString()

Definition at line 445 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

numEval::STRING_FORMATTER::STRING_FORMATTER ( int  aReserve = OUTPUTFMTBUFZ,
char  aQuoteChar = '"' 
)
inline

Constructor STRING_FORMATTER reserves space in the buffer.

Definition at line 455 of file numeric_evaluator.cpp.

Member Function Documentation

void numEval::STRING_FORMATTER::Clear ( )
inline

Function Clear clears the buffer and empties the internal string.

Definition at line 464 of file numeric_evaluator.cpp.

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

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)
virtualinherited

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.
const std::string& numEval::STRING_FORMATTER::GetString ( )
inline

Definition at line 475 of file numeric_evaluator.cpp.

int PRINTF_FUNC numEval::OUTPUTFORMATTER::Print ( int  nestLevel,
const char *  fmt,
  ... 
)
inherited

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)
virtualinherited

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)
inherited
void numEval::STRING_FORMATTER::StripUseless ( )

Function StripUseless removes whitespace, '(', and ')' from the mystring.

void numEval::STRING_FORMATTER::write ( const char *  aOutBuf,
int  aCount 
)
overrideprotectedvirtual

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.

Implements numEval::OUTPUTFORMATTER.

Member Data Documentation

std::string numEval::STRING_FORMATTER::m_mystring
private

Definition at line 447 of file numeric_evaluator.cpp.


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