KiCad PCB EDA Suite
Loading...
Searching...
No Matches
STRING_LINE_READER Class Reference

Is a LINE_READER that reads from a multiline 8 bit wide std::string. More...

#include <richio.h>

Inheritance diagram for STRING_LINE_READER:
LINE_READER

Public Member Functions

 STRING_LINE_READER (const std::string &aString, const wxString &aSource)
 Construct a string line reader.
 
 STRING_LINE_READER (const STRING_LINE_READER &aStartingPoint)
 Construct a string line reader.
 
char * ReadLine () override
 Read a line of text into the buffer and increments the line number counter.
 
virtual const wxString & GetSource () const
 Returns the name of the source of the lines in an abstract sense.
 
char * Line () const
 Return a pointer to the last line that was read in.
 
 operator char * () const
 A casting operator that returns a char* pointer to the start of the line buffer.
 
virtual unsigned LineNumber () const
 Return the line number of the last line read from this LINE_READER.
 
unsigned Length () const
 Return the number of bytes in the last line read from this LINE_READER.
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Is a LINE_READER that reads from a multiline 8 bit wide std::string.

Definition at line 252 of file richio.h.

Constructor & Destructor Documentation

◆ STRING_LINE_READER() [1/2]

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

Construct a string line reader.

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 meaningful, such as wxT( "clipboard" ).

Definition at line 283 of file richio.cpp.

References LINE_READER::LINE_READER(), LINE_READER_LINE_DEFAULT_MAX, m_lines, m_ndx, and LINE_READER::m_source.

Referenced by STRING_LINE_READER().

◆ STRING_LINE_READER() [2/2]

STRING_LINE_READER::STRING_LINE_READER ( const STRING_LINE_READER & aStartingPoint)

Construct a 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

Definition at line 293 of file richio.cpp.

References LINE_READER::LINE_READER(), LINE_READER_LINE_DEFAULT_MAX, LINE_READER::m_lineNum, m_lines, m_ndx, LINE_READER::m_source, and STRING_LINE_READER().

Member Function Documentation

◆ expandCapacity()

void LINE_READER::expandCapacity ( unsigned aNewsize)
protectedinherited

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

Definition at line 170 of file richio.cpp.

References m_capacity, m_length, m_line, and m_maxLineLength.

Referenced by FILE_LINE_READER::ReadLine(), INPUTSTREAM_LINE_READER::ReadLine(), and STRING_LINE_READER::ReadLine().

◆ GetSource()

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

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.

Reimplemented in FILTER_READER, and WHITESPACE_FILTER_READER.

Definition at line 121 of file richio.h.

References m_source.

Referenced by PCB_IO_KICAD_LEGACY::getVersion(), SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin(), SCH_IO_KICAD_LEGACY::loadSymbol(), and GPCB_FPL_CACHE::parseFOOTPRINT().

◆ Length()

unsigned LINE_READER::Length ( ) const
inlineinherited

Return the number of bytes in the last line read from this LINE_READER.

Definition at line 155 of file richio.h.

References m_length.

◆ Line()

char * LINE_READER::Line ( ) const
inlineinherited

Return a pointer to the last line that was read in.

Definition at line 129 of file richio.h.

References m_line.

Referenced by bench_string_lr(), bench_string_lr_reuse(), bench_wxbis(), bench_wxbis_reuse(), bench_wxis(), bench_wxis_reuse(), PCB_IO_KICAD_LEGACY::CanReadFootprint(), PCB_IO_KICAD_LEGACY::getVersion(), NETLIST_READER::GuessNetlistFileType(), PCB_IO_GEDA::ImportFootprint(), SCH_IO_KICAD_LEGACY_LIB_CACHE::Load(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadAliases(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier(), SCH_IO_KICAD_LEGACY::loadBitmap(), SCH_IO_KICAD_LEGACY::loadBusAlias(), SCH_IO_KICAD_LEGACY::loadBusEntry(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle(), SCH_IO_KICAD_LEGACY::LoadContent(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), EXCELLON_IMAGE::LoadFile(), SCH_IO_KICAD_LEGACY::loadFile(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadFootprintFilters(), SCH_IO_KICAD_LEGACY::loadHeader(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadHeader(), SCH_IO_KICAD_LEGACY::loadJunction(), BITMAP_BASE::LoadLegacyData(), LP_CACHE::LoadModules(), SCH_IO_KICAD_LEGACY::loadNoConnect(), SCH_IO_KICAD_LEGACY::loadPageSettings(), SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect(), SCH_IO_KICAD_LEGACY::loadSymbol(), SCH_IO_KICAD_LEGACY::loadText(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText(), SCH_IO_KICAD_LEGACY::loadWire(), operator char *(), GPCB_FPL_CACHE::parseParameters(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr(), LP_CACHE::SkipIndex(), EXCELLON_IMAGE::TestFileIsExcellon(), and GERBER_FILE_IMAGE::TestFileIsRS274().

◆ LineNumber()

virtual unsigned LINE_READER::LineNumber ( ) const
inlinevirtualinherited

Return the line number of the last line read from this LINE_READER.

Lines start from 1.

Reimplemented in FILTER_READER, and WHITESPACE_FILTER_READER.

Definition at line 147 of file richio.h.

References m_lineNum.

Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs(), SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin(), SCH_IO_KICAD_LEGACY::loadSymbol(), and GPCB_FPL_CACHE::parseFOOTPRINT().

◆ operator char *()

LINE_READER::operator char * ( ) const
inlineinherited

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

Definition at line 137 of file richio.h.

References Line().

◆ ReadLine()

char * STRING_LINE_READER::ReadLine ( )
overridevirtual

Read a line of text into the buffer and increments the line number counter.

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

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

Implements LINE_READER.

Definition at line 306 of file richio.cpp.

References _, LINE_READER::expandCapacity(), LINE_READER::m_capacity, LINE_READER::m_length, LINE_READER::m_line, LINE_READER::m_lineNum, m_lines, LINE_READER::m_maxLineLength, m_ndx, and THROW_IO_ERROR.

Referenced by bench_string_lr(), and bench_string_lr_reuse().

Member Data Documentation

◆ m_capacity

unsigned LINE_READER::m_capacity
protectedinherited

no. bytes allocated for line.

Definition at line 171 of file richio.h.

Referenced by expandCapacity(), LINE_READER(), FILE_LINE_READER::ReadLine(), INPUTSTREAM_LINE_READER::ReadLine(), and STRING_LINE_READER::ReadLine().

◆ m_length

◆ m_line

◆ m_lineNum

◆ m_lines

std::string STRING_LINE_READER::m_lines
protected

Definition at line 255 of file richio.h.

Referenced by ReadLine(), STRING_LINE_READER(), and STRING_LINE_READER().

◆ m_maxLineLength

unsigned LINE_READER::m_maxLineLength
protectedinherited

maximum allowed capacity using resizing.

Definition at line 173 of file richio.h.

Referenced by expandCapacity(), LINE_READER(), FILE_LINE_READER::ReadLine(), INPUTSTREAM_LINE_READER::ReadLine(), and STRING_LINE_READER::ReadLine().

◆ m_ndx

size_t STRING_LINE_READER::m_ndx
protected

Definition at line 256 of file richio.h.

Referenced by ReadLine(), STRING_LINE_READER(), and STRING_LINE_READER().

◆ m_source


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