ObjImporter: next try for multiple line stuff.
parent
c121cec68a
commit
82380084c5
|
@ -96,7 +96,7 @@ public:
|
|||
/// @brief Will read the next line.
|
||||
/// @param buffer The buffer for the next line.
|
||||
/// @return true if successful.
|
||||
bool getNextLine( std::vector<T> &buffer );
|
||||
bool getNextDataLine( std::vector<T> &buffer, T continuationToken );
|
||||
|
||||
private:
|
||||
IOStream *m_stream;
|
||||
|
@ -227,15 +227,35 @@ size_t IOStreamBuffer<T>::getFilePos() const {
|
|||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::getNextLine( std::vector<T> &buffer ) {
|
||||
bool IOStreamBuffer<T>::getNextDataLine( std::vector<T> &buffer, T continuationToken ) {
|
||||
buffer.resize( m_cacheSize );
|
||||
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
||||
if ( !readNextBlock() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool continuationFound( false ), endOfDataLine( false );
|
||||
size_t i = 0;
|
||||
while ( !IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
||||
while ( !endOfDataLine ) {
|
||||
if ( continuationToken == m_cache[ m_cachePos ] ) {
|
||||
continuationFound = true;
|
||||
}
|
||||
if ( IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
||||
if ( !continuationFound ) {
|
||||
// the end of the data line
|
||||
i++;
|
||||
break;
|
||||
} else {
|
||||
// skip line end
|
||||
while ( m_cache[m_cachePos] != '\n') {
|
||||
++m_cachePos;
|
||||
}
|
||||
++m_cachePos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
buffer[ i ] = m_cache[ m_cachePos ];
|
||||
m_cachePos++;
|
||||
i++;
|
||||
|
@ -245,6 +265,7 @@ bool IOStreamBuffer<T>::getNextLine( std::vector<T> &buffer ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
buffer[ i ] = '\n';
|
||||
m_cachePos++;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffe
|
|||
std::vector<char> tempBuf;
|
||||
do
|
||||
{
|
||||
streamBuffer.getNextLine(tempBuf);
|
||||
streamBuffer.getNextDataLine(tempBuf, '\\' );
|
||||
} while (tempBuf[0]=='\n');
|
||||
*curPosition = ' ';
|
||||
std::copy(tempBuf.cbegin(), tempBuf.cend(), ++curPosition);
|
||||
|
@ -142,7 +142,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|||
size_t lastFilePos( 0 );
|
||||
|
||||
std::vector<char> buffer;
|
||||
while ( streamBuffer.getNextLine( buffer ) ) {
|
||||
while ( streamBuffer.getNextDataLine( buffer, '\\' ) ) {
|
||||
m_DataIt = buffer.begin();
|
||||
m_DataItEnd = buffer.end();
|
||||
|
||||
|
|
Loading…
Reference in New Issue