KiCad PCB EDA Suite
numEval::STRING_LINE_READER Class Reference

Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string. More...

Inheritance diagram for numEval::STRING_LINE_READER:
numEval::LINE_READER

Public Member Functions

 STRING_LINE_READER (const std::string &aString, const wxString &aSource)
 Constructor STRING_LINE_READER( const std::string&, const wxString& ) More...
 
 STRING_LINE_READER (const STRING_LINE_READER &aStartingPoint)
 Constructor STRING_LINE_READER( const STRING_LINE_READER& ) allows for a continuation of the reading of a stream started by another STRING_LINE_READER. More...
 
char * ReadLine () override
 Function ReadLine reads a line of text into the buffer and increments the line number counter. More...
 
virtual const wxString & GetSource () const
 Function GetSource returns the name of the source of the lines in an abstract sense. More...
 
char * Line () const
 Function Line returns a pointer to the last line that was read in. More...
 
 operator char * () const
 Operator char* is a casting operator that returns a char* pointer to the start of the line buffer. More...
 
virtual unsigned LineNumber () const
 Function Line Number returns the line number of the last line read from this LINE_READER. More...
 
unsigned Length () const
 Function Length returns the number of bytes in the last line read from this LINE_READER. More...
 

Protected Member Functions

void expandCapacity (unsigned aNewsize)
 Function expandCapacity will expand the capacity of line up to maxLineLength but not greater, so be careful about making assumptions of capacity after calling this. More...
 

Protected Attributes

std::string m_lines
 
size_t m_ndx
 
unsigned m_length
 no. bytes in line before trailing nul. More...
 
unsigned m_lineNum
 
char * m_line
 the read line of UTF8 text More...
 
unsigned m_capacity
 no. bytes allocated for line. More...
 
unsigned m_maxLineLength
 maximum allowed capacity using resizing. More...
 
wxString m_source
 origin of text lines, e.g. filename or "clipboard" More...
 

Detailed Description

Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.

Definition at line 254 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

numEval::STRING_LINE_READER::STRING_LINE_READER ( const std::string &  aString,
const wxString &  aSource 
)

Constructor STRING_LINE_READER( const std::string&, const wxString& )

Parameters
aStringis a source string consisting of one or more lines of text, where multiple lines are separated with a '
' character. The last line does not necessarily need a trailing '
'.
aSourcedescribes the source of aString for error reporting purposes can be anything meaninful, such as wxT( "clipboard" ).
numEval::STRING_LINE_READER::STRING_LINE_READER ( const STRING_LINE_READER aStartingPoint)

Constructor STRING_LINE_READER( const STRING_LINE_READER& ) allows for a continuation of the reading of a stream started by another STRING_LINE_READER.

Any stream offset and source name are used from aStartingPoint.

Member Function Documentation

void numEval::LINE_READER::expandCapacity ( unsigned  aNewsize)
protectedinherited

Function expandCapacity will expand the capacity of line up to maxLineLength but not greater, so be careful about making assumptions of capacity after calling this.

virtual const wxString& numEval::LINE_READER::GetSource ( ) const
inlinevirtualinherited

Function GetSource returns the name of the source of the lines in an abstract sense.

This may be a file or it may be the clipboard or any other source of lines of text. The returned string is useful for reporting error messages.

Definition at line 130 of file numeric_evaluator.cpp.

131 {
132  // Feed parser token after token until end of input.
133 
unsigned numEval::LINE_READER::Length ( ) const
inlineinherited

Function Length returns the number of bytes in the last line read from this LINE_READER.

Definition at line 168 of file numeric_evaluator.cpp.

char* numEval::LINE_READER::Line ( ) const
inlineinherited

Function Line returns a pointer to the last line that was read in.

Definition at line 139 of file numeric_evaluator.cpp.

140  {
141  m_parseFinished = true;
142  return true;
virtual unsigned numEval::LINE_READER::LineNumber ( ) const
inlinevirtualinherited

Function Line Number returns the line number of the last line read from this LINE_READER.

Lines start from 1.

Definition at line 159 of file numeric_evaluator.cpp.

163 {
numEval::LINE_READER::operator char * ( ) const
inlineinherited

Operator char* is a casting operator that returns a char* pointer to the start of the line buffer.

Definition at line 149 of file numeric_evaluator.cpp.

151  {
152  // Reset parser by passing zero as token ID, value is ignored.
char* numEval::STRING_LINE_READER::ReadLine ( )
overridevirtual

Function ReadLine reads a line of text into the buffer and increments the line number counter.

If the line is larger than aMaxLineLength passed to the constructor, then an exception is thrown. The line is nul terminated.

Returns
char* - The beginning of the read line, or NULL if EOF.
Exceptions
IO_ERRORwhen a line is too long.

Implements numEval::LINE_READER.

Member Data Documentation

unsigned numEval::LINE_READER::m_capacity
protectedinherited

no. bytes allocated for line.

Definition at line 88 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_length
protectedinherited

no. bytes in line before trailing nul.

Definition at line 84 of file numeric_evaluator.cpp.

char* numEval::LINE_READER::m_line
protectedinherited

the read line of UTF8 text

Definition at line 87 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_lineNum
protectedinherited

Definition at line 85 of file numeric_evaluator.cpp.

std::string numEval::STRING_LINE_READER::m_lines
protected

Definition at line 257 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_maxLineLength
protectedinherited

maximum allowed capacity using resizing.

Definition at line 90 of file numeric_evaluator.cpp.

size_t numEval::STRING_LINE_READER::m_ndx
protected

Definition at line 258 of file numeric_evaluator.cpp.

wxString numEval::LINE_READER::m_source
protectedinherited

origin of text lines, e.g. filename or "clipboard"

Definition at line 92 of file numeric_evaluator.cpp.


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