KiCad PCB EDA Suite
numEval::LINE_READER Class Referenceabstract

Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to read single lines of text and manage a line number counter. More...

Inheritance diagram for numEval::LINE_READER:
numEval::FILE_LINE_READER numEval::INPUTSTREAM_LINE_READER numEval::STRING_LINE_READER

Public Member Functions

 LINE_READER (unsigned aMaxLineLength=LINE_READER_LINE_DEFAULT_MAX)
 Constructor LINE_READER builds a line reader and fixes the length of the maximum supported line length to aMaxLineLength. More...
 
virtual ~LINE_READER ()
 
virtual char * ReadLine ()=0
 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

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 LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to read single lines of text and manage a line number counter.

Definition at line 81 of file numeric_evaluator.cpp.

Constructor & Destructor Documentation

numEval::LINE_READER::LINE_READER ( unsigned  aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX)

Constructor LINE_READER builds a line reader and fixes the length of the maximum supported line length to aMaxLineLength.

virtual numEval::LINE_READER::~LINE_READER ( )
virtual

Member Function Documentation

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

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
inlinevirtual

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
inline

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
inline

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
inlinevirtual

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
inline

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.
virtual char* numEval::LINE_READER::ReadLine ( )
pure virtual

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.

Implemented in numEval::INPUTSTREAM_LINE_READER, numEval::STRING_LINE_READER, and numEval::FILE_LINE_READER.

Member Data Documentation

unsigned numEval::LINE_READER::m_capacity
protected

no. bytes allocated for line.

Definition at line 88 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_length
protected

no. bytes in line before trailing nul.

Definition at line 84 of file numeric_evaluator.cpp.

char* numEval::LINE_READER::m_line
protected

the read line of UTF8 text

Definition at line 87 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_lineNum
protected

Definition at line 85 of file numeric_evaluator.cpp.

unsigned numEval::LINE_READER::m_maxLineLength
protected

maximum allowed capacity using resizing.

Definition at line 90 of file numeric_evaluator.cpp.

wxString numEval::LINE_READER::m_source
protected

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: