richio.h, class LINE_READER: prefix variable member names by "m_", like in other classes in Kicad.
This commit is contained in:
parent
7e7d3004fb
commit
2337b83ba6
|
@ -32,20 +32,20 @@ FILTER_READER::FILTER_READER( LINE_READER& aReader ) :
|
||||||
LINE_READER( 1 ),
|
LINE_READER( 1 ),
|
||||||
reader( aReader )
|
reader( aReader )
|
||||||
{
|
{
|
||||||
// Not using our own line buffer, will be using aReader's. This changes
|
// Not using our own m_line buffer, will be using aReader's. This changes
|
||||||
// the meaning of this->line to be merely a pointer to aReader's line, which of course
|
// the meaning of this->m_line to be merely a pointer to aReader's m_line, which of course
|
||||||
// is not owned here.
|
// is not owned here.
|
||||||
delete [] line;
|
delete [] m_line;
|
||||||
|
|
||||||
line = 0;
|
m_line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILTER_READER::~FILTER_READER()
|
FILTER_READER::~FILTER_READER()
|
||||||
{
|
{
|
||||||
// Our 'line' points to aReader's, and he will delete that buffer.
|
// Our 'm_line' points to aReader's, and he will delete that buffer.
|
||||||
// Prevent subsequent call to ~LINE_READER() from deleting a buffer we do not own.
|
// Prevent subsequent call to ~LINE_READER() from deleting a buffer we do not own.
|
||||||
line = 0;
|
m_line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ char* FILTER_READER::ReadLine()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = reader.Line();
|
m_line = reader.Line();
|
||||||
length = reader.Length();
|
m_length = reader.Length();
|
||||||
|
|
||||||
return length ? line : NULL;
|
return m_length ? m_line : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,20 +70,20 @@ WHITESPACE_FILTER_READER::WHITESPACE_FILTER_READER( LINE_READER& aReader ) :
|
||||||
LINE_READER( 1 ),
|
LINE_READER( 1 ),
|
||||||
reader( aReader )
|
reader( aReader )
|
||||||
{
|
{
|
||||||
// Not using our own line buffer, will be using aReader's. This changes
|
// Not using our own m_line buffer, will be using aReader's. This changes
|
||||||
// the meaning of this->line to be merely a pointer to aReader's line, which of course
|
// the meaning of this->m_line to be merely a pointer to aReader's m_line, which of course
|
||||||
// is not owned here.
|
// is not owned here.
|
||||||
delete [] line;
|
delete [] m_line;
|
||||||
|
|
||||||
line = 0;
|
m_line = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WHITESPACE_FILTER_READER::~WHITESPACE_FILTER_READER()
|
WHITESPACE_FILTER_READER::~WHITESPACE_FILTER_READER()
|
||||||
{
|
{
|
||||||
// Our 'line' points to aReader's, and he will delete that buffer.
|
// Our 'm_line' points to aReader's, and he will delete that buffer.
|
||||||
// Prevent subsequent call to ~LINE_READER() from deleting a buffer we do not own.
|
// Prevent subsequent call to ~LINE_READER() from deleting a buffer we do not own.
|
||||||
line = 0;
|
m_line = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ char* WHITESPACE_FILTER_READER::ReadLine()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = s;
|
m_line = s;
|
||||||
length = reader.Length();
|
m_length = reader.Length();
|
||||||
|
|
||||||
return length ? line : NULL;
|
return m_length ? m_line : NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -100,76 +100,76 @@ std::string StrPrintf( const char* format, ... )
|
||||||
//-----<LINE_READER>------------------------------------------------------
|
//-----<LINE_READER>------------------------------------------------------
|
||||||
|
|
||||||
LINE_READER::LINE_READER( unsigned aMaxLineLength ) :
|
LINE_READER::LINE_READER( unsigned aMaxLineLength ) :
|
||||||
length( 0 ), lineNum( 0 ), line( NULL ),
|
m_length( 0 ), m_lineNum( 0 ), m_line( NULL ),
|
||||||
capacity( 0 ), maxLineLength( aMaxLineLength )
|
m_capacity( 0 ), m_maxLineLength( aMaxLineLength )
|
||||||
{
|
{
|
||||||
if( aMaxLineLength != 0 )
|
if( aMaxLineLength != 0 )
|
||||||
{
|
{
|
||||||
// start at the INITIAL size, expand as needed up to the MAX size in maxLineLength
|
// start at the INITIAL size, expand as needed up to the MAX size in maxLineLength
|
||||||
capacity = LINE_READER_LINE_INITIAL_SIZE;
|
m_capacity = LINE_READER_LINE_INITIAL_SIZE;
|
||||||
|
|
||||||
// but never go above user's aMaxLineLength, and leave space for trailing nul
|
// but never go above user's aMaxLineLength, and leave space for trailing nul
|
||||||
if( capacity > aMaxLineLength+1 )
|
if( m_capacity > aMaxLineLength+1 )
|
||||||
capacity = aMaxLineLength+1;
|
m_capacity = aMaxLineLength+1;
|
||||||
|
|
||||||
// Be sure there is room for a null EOL char, so reserve at least capacity+1 bytes
|
// Be sure there is room for a null EOL char, so reserve at least capacity+1 bytes
|
||||||
// to ensure capacity line lenght and avoid corner cases
|
// to ensure capacity line lenght and avoid corner cases
|
||||||
// Use capacity+5 to cover and corner case
|
// Use capacity+5 to cover and corner case
|
||||||
line = new char[capacity+5];
|
m_line = new char[m_capacity+5];
|
||||||
|
|
||||||
line[0] = '\0';
|
m_line[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LINE_READER::~LINE_READER()
|
LINE_READER::~LINE_READER()
|
||||||
{
|
{
|
||||||
delete[] line;
|
delete[] m_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LINE_READER::expandCapacity( unsigned newsize )
|
void LINE_READER::expandCapacity( unsigned aNewsize )
|
||||||
{
|
{
|
||||||
// length can equal maxLineLength and nothing breaks, there's room for
|
// m_length can equal maxLineLength and nothing breaks, there's room for
|
||||||
// the terminating nul. cannot go over this.
|
// the terminating nul. cannot go over this.
|
||||||
if( newsize > maxLineLength+1 )
|
if( aNewsize > m_maxLineLength+1 )
|
||||||
newsize = maxLineLength+1;
|
aNewsize = m_maxLineLength+1;
|
||||||
|
|
||||||
if( newsize > capacity )
|
if( aNewsize > m_capacity )
|
||||||
{
|
{
|
||||||
capacity = newsize;
|
m_capacity = aNewsize;
|
||||||
|
|
||||||
// resize the buffer, and copy the original data
|
// resize the buffer, and copy the original data
|
||||||
// Be sure there is room for the null EOL char, so reserve capacity+1 bytes
|
// Be sure there is room for the null EOL char, so reserve capacity+1 bytes
|
||||||
// to ensure capacity line lenght. Use capacity+5 to cover and corner case
|
// to ensure capacity line lenght. Use capacity+5 to cover and corner case
|
||||||
char* bigger = new char[capacity+5];
|
char* bigger = new char[m_capacity+5];
|
||||||
|
|
||||||
wxASSERT( capacity >= length+1 );
|
wxASSERT( m_capacity >= m_length+1 );
|
||||||
|
|
||||||
memcpy( bigger, line, length );
|
memcpy( bigger, m_line, m_length );
|
||||||
bigger[length] = 0;
|
bigger[m_length] = 0;
|
||||||
|
|
||||||
delete[] line;
|
delete[] m_line;
|
||||||
line = bigger;
|
m_line = bigger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE_LINE_READER::FILE_LINE_READER( const wxString& aFileName,
|
FILE_LINE_READER::FILE_LINE_READER( const wxString& aFileName,
|
||||||
unsigned aStartingLineNumber, unsigned aMaxLineLength ):
|
unsigned aStartingLineNumber, unsigned aMaxLineLength ):
|
||||||
LINE_READER( aMaxLineLength ), iOwn( true )
|
LINE_READER( aMaxLineLength ), m_iOwn( true )
|
||||||
{
|
{
|
||||||
fp = wxFopen( aFileName, wxT( "rt" ) );
|
m_fp = wxFopen( aFileName, wxT( "rt" ) );
|
||||||
|
|
||||||
if( !fp )
|
if( !m_fp )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Unable to open filename '%s' for reading" ), aFileName.GetData() );
|
_( "Unable to open filename '%s' for reading" ), aFileName.GetData() );
|
||||||
THROW_IO_ERROR( msg );
|
THROW_IO_ERROR( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
source = aFileName;
|
m_source = aFileName;
|
||||||
lineNum = aStartingLineNumber;
|
m_lineNum = aStartingLineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,107 +177,104 @@ FILE_LINE_READER::FILE_LINE_READER( FILE* aFile, const wxString& aFileName,
|
||||||
bool doOwn,
|
bool doOwn,
|
||||||
unsigned aStartingLineNumber,
|
unsigned aStartingLineNumber,
|
||||||
unsigned aMaxLineLength ) :
|
unsigned aMaxLineLength ) :
|
||||||
LINE_READER( aMaxLineLength ),
|
LINE_READER( aMaxLineLength ), m_iOwn( doOwn ), m_fp( aFile )
|
||||||
iOwn( doOwn ),
|
|
||||||
fp( aFile )
|
|
||||||
{
|
{
|
||||||
source = aFileName;
|
m_source = aFileName;
|
||||||
lineNum = aStartingLineNumber;
|
m_lineNum = aStartingLineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE_LINE_READER::~FILE_LINE_READER()
|
FILE_LINE_READER::~FILE_LINE_READER()
|
||||||
{
|
{
|
||||||
if( iOwn && fp )
|
if( m_iOwn && m_fp )
|
||||||
fclose( fp );
|
fclose( m_fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* FILE_LINE_READER::ReadLine()
|
char* FILE_LINE_READER::ReadLine()
|
||||||
{
|
{
|
||||||
length = 0;
|
m_length = 0;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( length >= maxLineLength )
|
if( m_length >= m_maxLineLength )
|
||||||
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
|
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
|
||||||
|
|
||||||
if( length >= capacity )
|
if( m_length >= m_capacity )
|
||||||
expandCapacity( capacity * 2 );
|
expandCapacity( m_capacity * 2 );
|
||||||
|
|
||||||
// faster, POSIX compatible fgetc(), no locking.
|
// faster, POSIX compatible fgetc(), no locking.
|
||||||
int cc = getc_unlocked( fp );
|
int cc = getc_unlocked( m_fp );
|
||||||
|
|
||||||
if( cc == EOF )
|
if( cc == EOF )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
line[ length++ ] = (char) cc;
|
m_line[ m_length++ ] = (char) cc;
|
||||||
|
|
||||||
if( cc == '\n' )
|
if( cc == '\n' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line[ length ] = 0;
|
m_line[ m_length ] = 0;
|
||||||
|
|
||||||
// lineNum is incremented even if there was no line read, because this
|
// m_lineNum is incremented even if there was no line read, because this
|
||||||
// leads to better error reporting when we hit an end of file.
|
// leads to better error reporting when we hit an end of file.
|
||||||
++lineNum;
|
++m_lineNum;
|
||||||
|
|
||||||
return length ? line : NULL;
|
return m_length ? m_line : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STRING_LINE_READER::STRING_LINE_READER( const std::string& aString, const wxString& aSource ):
|
STRING_LINE_READER::STRING_LINE_READER( const std::string& aString, const wxString& aSource ):
|
||||||
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
||||||
lines( aString ),
|
m_lines( aString ), m_ndx( 0 )
|
||||||
ndx( 0 )
|
|
||||||
{
|
{
|
||||||
// Clipboard text should be nice and _use multiple lines_ so that
|
// Clipboard text should be nice and _use multiple lines_ so that
|
||||||
// we can report _line number_ oriented error messages when parsing.
|
// we can report _line number_ oriented error messages when parsing.
|
||||||
source = aSource;
|
m_source = aSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STRING_LINE_READER::STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint ):
|
STRING_LINE_READER::STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint ):
|
||||||
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
||||||
lines( aStartingPoint.lines ),
|
m_lines( aStartingPoint.m_lines ),
|
||||||
ndx( aStartingPoint.ndx )
|
m_ndx( aStartingPoint.m_ndx )
|
||||||
{
|
{
|
||||||
// since we are keeping the same "source" name, for error reporting purposes
|
// since we are keeping the same "source" name, for error reporting purposes
|
||||||
// we need to have the same notion of line number and offset.
|
// we need to have the same notion of line number and offset.
|
||||||
|
|
||||||
source = aStartingPoint.source;
|
m_source = aStartingPoint.m_source;
|
||||||
lineNum = aStartingPoint.lineNum;
|
m_lineNum = aStartingPoint.m_lineNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* STRING_LINE_READER::ReadLine()
|
char* STRING_LINE_READER::ReadLine()
|
||||||
{
|
{
|
||||||
size_t nlOffset = lines.find( '\n', ndx );
|
size_t nlOffset = m_lines.find( '\n', m_ndx );
|
||||||
|
|
||||||
if( nlOffset == std::string::npos )
|
if( nlOffset == std::string::npos )
|
||||||
length = lines.length() - ndx;
|
m_length = m_lines.length() - m_ndx;
|
||||||
else
|
else
|
||||||
length = nlOffset - ndx + 1; // include the newline, so +1
|
m_length = nlOffset - m_ndx + 1; // include the newline, so +1
|
||||||
|
|
||||||
if( length )
|
if( m_length )
|
||||||
{
|
{
|
||||||
if( length >= maxLineLength )
|
if( m_length >= m_maxLineLength )
|
||||||
THROW_IO_ERROR( _("Line length exceeded") );
|
THROW_IO_ERROR( _("Line length exceeded") );
|
||||||
|
|
||||||
if( length+1 > capacity ) // +1 for terminating nul
|
if( m_length+1 > m_capacity ) // +1 for terminating nul
|
||||||
expandCapacity( length+1 );
|
expandCapacity( m_length+1 );
|
||||||
|
|
||||||
wxASSERT( ndx + length <= lines.length() );
|
wxASSERT( m_ndx + m_length <= m_lines.length() );
|
||||||
|
|
||||||
memcpy( line, &lines[ndx], length );
|
memcpy( m_line, &m_lines[m_ndx], m_length );
|
||||||
ndx += length;
|
m_ndx += m_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
++lineNum; // this gets incremented even if no bytes were read
|
++m_lineNum; // this gets incremented even if no bytes were read
|
||||||
line[length] = 0;
|
m_line[m_length] = 0;
|
||||||
|
|
||||||
return length ? line : NULL;
|
return m_length ? m_line : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -285,21 +282,21 @@ INPUTSTREAM_LINE_READER::INPUTSTREAM_LINE_READER( wxInputStream* aStream, const
|
||||||
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
|
||||||
m_stream( aStream )
|
m_stream( aStream )
|
||||||
{
|
{
|
||||||
source = aSource;
|
m_source = aSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* INPUTSTREAM_LINE_READER::ReadLine()
|
char* INPUTSTREAM_LINE_READER::ReadLine()
|
||||||
{
|
{
|
||||||
length = 0;
|
m_length = 0;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( length >= maxLineLength )
|
if( m_length >= m_maxLineLength )
|
||||||
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
|
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
|
||||||
|
|
||||||
if( length + 1 > capacity )
|
if( m_length + 1 > m_capacity )
|
||||||
expandCapacity( capacity * 2 );
|
expandCapacity( m_capacity * 2 );
|
||||||
|
|
||||||
// this read may fail, docs say to test LastRead() before trusting cc.
|
// this read may fail, docs say to test LastRead() before trusting cc.
|
||||||
char cc = m_stream->GetC();
|
char cc = m_stream->GetC();
|
||||||
|
@ -307,19 +304,19 @@ char* INPUTSTREAM_LINE_READER::ReadLine()
|
||||||
if( !m_stream->LastRead() )
|
if( !m_stream->LastRead() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
line[ length++ ] = cc;
|
m_line[ m_length++ ] = cc;
|
||||||
|
|
||||||
if( cc == '\n' )
|
if( cc == '\n' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line[ length ] = 0;
|
m_line[ m_length ] = 0;
|
||||||
|
|
||||||
// lineNum is incremented even if there was no line read, because this
|
// m_lineNum is incremented even if there was no line read, because this
|
||||||
// leads to better error reporting when we hit an end of file.
|
// leads to better error reporting when we hit an end of file.
|
||||||
++lineNum;
|
++m_lineNum;
|
||||||
|
|
||||||
return length ? line : NULL;
|
return m_length ? m_line : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,18 +372,18 @@ int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap )
|
||||||
// we make a copy of va_list ap for the second call, if happens
|
// we make a copy of va_list ap for the second call, if happens
|
||||||
va_list tmp;
|
va_list tmp;
|
||||||
va_copy( tmp, ap );
|
va_copy( tmp, ap );
|
||||||
int ret = vsnprintf( &buffer[0], buffer.size(), fmt, ap );
|
int ret = vsnprintf( &m_buffer[0], m_buffer.size(), fmt, ap );
|
||||||
|
|
||||||
if( ret >= (int) buffer.size() )
|
if( ret >= (int) m_buffer.size() )
|
||||||
{
|
{
|
||||||
buffer.resize( ret + 1000 );
|
m_buffer.resize( ret + 1000 );
|
||||||
ret = vsnprintf( &buffer[0], buffer.size(), fmt, tmp );
|
ret = vsnprintf( &m_buffer[0], m_buffer.size(), fmt, tmp );
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end( tmp ); // Release the temporary va_list, initialised from ap
|
va_end( tmp ); // Release the temporary va_list, initialised from ap
|
||||||
|
|
||||||
if( ret > 0 )
|
if( ret > 0 )
|
||||||
write( &buffer[0], ret );
|
write( &m_buffer[0], ret );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -497,20 +494,20 @@ std::string OUTPUTFORMATTER::Quotew( const wxString& aWrapee )
|
||||||
|
|
||||||
void STRING_FORMATTER::write( const char* aOutBuf, int aCount )
|
void STRING_FORMATTER::write( const char* aOutBuf, int aCount )
|
||||||
{
|
{
|
||||||
mystring.append( aOutBuf, aCount );
|
m_mystring.append( aOutBuf, aCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
void STRING_FORMATTER::StripUseless()
|
void STRING_FORMATTER::StripUseless()
|
||||||
{
|
{
|
||||||
std::string copy = mystring;
|
std::string copy = m_mystring;
|
||||||
|
|
||||||
mystring.clear();
|
m_mystring.clear();
|
||||||
|
|
||||||
for( std::string::iterator i=copy.begin(); i!=copy.end(); ++i )
|
for( std::string::iterator i=copy.begin(); i!=copy.end(); ++i )
|
||||||
{
|
{
|
||||||
if( !isspace( *i ) && *i!=')' && *i!='(' && *i!='"' )
|
if( !isspace( *i ) && *i!=')' && *i!='(' && *i!='"' )
|
||||||
{
|
{
|
||||||
mystring += *i;
|
m_mystring += *i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,9 +560,9 @@ void STREAM_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount )
|
||||||
// a file it should only go through the loop once.
|
// a file it should only go through the loop once.
|
||||||
for( int total = 0; total<aCount; total += lastWrite )
|
for( int total = 0; total<aCount; total += lastWrite )
|
||||||
{
|
{
|
||||||
lastWrite = os.Write( aOutBuf, aCount ).LastWrite();
|
lastWrite = m_os.Write( aOutBuf, aCount ).LastWrite();
|
||||||
|
|
||||||
if( !os.IsOk() )
|
if( !m_os.IsOk() )
|
||||||
{
|
{
|
||||||
THROW_IO_ERROR( _( "OUTPUTSTREAM_OUTPUTFORMATTER write error" ) );
|
THROW_IO_ERROR( _( "OUTPUTSTREAM_OUTPUTFORMATTER write error" ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,22 +81,22 @@ std::string
|
||||||
class LINE_READER
|
class LINE_READER
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
unsigned length; ///< no. bytes in line before trailing nul.
|
unsigned m_length; ///< no. bytes in line before trailing nul.
|
||||||
unsigned lineNum;
|
unsigned m_lineNum;
|
||||||
|
|
||||||
char* line; ///< the read line of UTF8 text
|
char* m_line; ///< the read line of UTF8 text
|
||||||
unsigned capacity; ///< no. bytes allocated for line.
|
unsigned m_capacity; ///< no. bytes allocated for line.
|
||||||
|
|
||||||
unsigned maxLineLength; ///< maximum allowed capacity using resizing.
|
unsigned m_maxLineLength; ///< maximum allowed capacity using resizing.
|
||||||
|
|
||||||
wxString source; ///< origin of text lines, e.g. filename or "clipboard"
|
wxString m_source; ///< origin of text lines, e.g. filename or "clipboard"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function expandCapacity
|
* Function expandCapacity
|
||||||
* will expand the capacity of @a line up to maxLineLength but not greater, so
|
* will expand the capacity of @a line up to maxLineLength but not greater, so
|
||||||
* be careful about making assumptions of @a capacity after calling this.
|
* be careful about making assumptions of @a capacity after calling this.
|
||||||
*/
|
*/
|
||||||
void expandCapacity( unsigned newsize );
|
void expandCapacity( unsigned aNewsize );
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const wxString& GetSource() const
|
virtual const wxString& GetSource() const
|
||||||
{
|
{
|
||||||
return source;
|
return m_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +138,7 @@ public:
|
||||||
*/
|
*/
|
||||||
char* Line() const
|
char* Line() const
|
||||||
{
|
{
|
||||||
return line;
|
return m_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +158,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual unsigned LineNumber() const
|
virtual unsigned LineNumber() const
|
||||||
{
|
{
|
||||||
return lineNum;
|
return m_lineNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
*/
|
*/
|
||||||
unsigned Length() const
|
unsigned Length() const
|
||||||
{
|
{
|
||||||
return length;
|
return m_length;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ class FILE_LINE_READER : public LINE_READER
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool iOwn; ///< if I own the file, I'll promise to close it, else not.
|
bool m_iOwn; ///< if I own the file, I'll promise to close it, else not.
|
||||||
FILE* fp; ///< I may own this file, but might not.
|
FILE* m_fp; ///< I may own this file, but might not.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void Rewind()
|
void Rewind()
|
||||||
{
|
{
|
||||||
rewind( fp );
|
rewind( m_fp );
|
||||||
lineNum = 0;
|
m_lineNum = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,8 +254,8 @@ public:
|
||||||
class STRING_LINE_READER : public LINE_READER
|
class STRING_LINE_READER : public LINE_READER
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::string lines;
|
std::string m_lines;
|
||||||
size_t ndx;
|
size_t m_ndx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ public:
|
||||||
*/
|
*/
|
||||||
class OUTPUTFORMATTER
|
class OUTPUTFORMATTER
|
||||||
{
|
{
|
||||||
std::vector<char> buffer;
|
std::vector<char> m_buffer;
|
||||||
char quoteChar[2];
|
char quoteChar[2];
|
||||||
|
|
||||||
int sprint( const char* fmt, ... );
|
int sprint( const char* fmt, ... );
|
||||||
|
@ -335,7 +335,7 @@ class OUTPUTFORMATTER
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
|
OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
|
||||||
buffer( aReserve, '\0' )
|
m_buffer( aReserve, '\0' )
|
||||||
{
|
{
|
||||||
quoteChar[0] = aQuoteChar;
|
quoteChar[0] = aQuoteChar;
|
||||||
quoteChar[1] = '\0';
|
quoteChar[1] = '\0';
|
||||||
|
@ -444,7 +444,7 @@ public:
|
||||||
*/
|
*/
|
||||||
class STRING_FORMATTER : public OUTPUTFORMATTER
|
class STRING_FORMATTER : public OUTPUTFORMATTER
|
||||||
{
|
{
|
||||||
std::string mystring;
|
std::string m_mystring;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
mystring.clear();
|
m_mystring.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,7 +474,7 @@ public:
|
||||||
|
|
||||||
const std::string& GetString()
|
const std::string& GetString()
|
||||||
{
|
{
|
||||||
return mystring;
|
return m_mystring;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -525,7 +525,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||||
{
|
{
|
||||||
wxOutputStream& os;
|
wxOutputStream& m_os;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -535,7 +535,7 @@ public:
|
||||||
*/
|
*/
|
||||||
STREAM_OUTPUTFORMATTER( wxOutputStream& aStream, char aQuoteChar = '"' ) :
|
STREAM_OUTPUTFORMATTER( wxOutputStream& aStream, char aQuoteChar = '"' ) :
|
||||||
OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ),
|
OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ),
|
||||||
os( aStream )
|
m_os( aStream )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,15 @@ STDISTREAM_LINE_READER::STDISTREAM_LINE_READER() :
|
||||||
LINE_READER( 0 ),
|
LINE_READER( 0 ),
|
||||||
m_stream( nullptr )
|
m_stream( nullptr )
|
||||||
{
|
{
|
||||||
line = nullptr;
|
m_line = nullptr;
|
||||||
lineNum = 0;
|
m_lineNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDISTREAM_LINE_READER::~STDISTREAM_LINE_READER()
|
STDISTREAM_LINE_READER::~STDISTREAM_LINE_READER()
|
||||||
{
|
{
|
||||||
// this is only a view into a string, it cant be deleted by the base
|
// this is only a view into a string, it cant be deleted by the base
|
||||||
line = nullptr;
|
m_line = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,14 +47,14 @@ char* STDISTREAM_LINE_READER::ReadLine()
|
||||||
|
|
||||||
m_buffer.append( 1, '\n' );
|
m_buffer.append( 1, '\n' );
|
||||||
|
|
||||||
length = m_buffer.size();
|
m_length = m_buffer.size();
|
||||||
line = (char*) m_buffer.data(); //ew why no const??
|
m_line = (char*) m_buffer.data(); //ew why no const??
|
||||||
|
|
||||||
// lineNum is incremented even if there was no line read, because this
|
// lineNum is incremented even if there was no line read, because this
|
||||||
// leads to better error reporting when we hit an end of file.
|
// leads to better error reporting when we hit an end of file.
|
||||||
++lineNum;
|
++m_lineNum;
|
||||||
|
|
||||||
return m_stream->eof() ? nullptr : line;
|
return m_stream->eof() ? nullptr : m_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ IFSTREAM_LINE_READER::IFSTREAM_LINE_READER( const wxFileName& aFileName ) :
|
||||||
|
|
||||||
setStream( m_fStream );
|
setStream( m_fStream );
|
||||||
|
|
||||||
source = aFileName.GetFullName();
|
m_source = aFileName.GetFullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue