|
@@ -56,8 +56,6 @@ namespace Assimp {
|
|
template<class T>
|
|
template<class T>
|
|
class IOStreamBuffer {
|
|
class IOStreamBuffer {
|
|
public:
|
|
public:
|
|
- typedef typename std::vector<T>::iterator CacheIter;
|
|
|
|
-
|
|
|
|
/// @brief The class constructor.
|
|
/// @brief The class constructor.
|
|
IOStreamBuffer( size_t cache = 4096 * 4096 );
|
|
IOStreamBuffer( size_t cache = 4096 * 4096 );
|
|
|
|
|
|
@@ -100,7 +98,7 @@ public:
|
|
/// @brief Will read the next line.
|
|
/// @brief Will read the next line.
|
|
/// @param buffer The buffer for the next line.
|
|
/// @param buffer The buffer for the next line.
|
|
/// @return true if successful.
|
|
/// @return true if successful.
|
|
- bool getNextLine( CacheIter &begin, CacheIter &end );
|
|
|
|
|
|
+ bool getNextDataLine( std::vector<T> &buffer, T continuationToken );
|
|
|
|
|
|
private:
|
|
private:
|
|
IOStream *m_stream;
|
|
IOStream *m_stream;
|
|
@@ -110,7 +108,6 @@ private:
|
|
size_t m_blockIdx;
|
|
size_t m_blockIdx;
|
|
std::vector<T> m_cache;
|
|
std::vector<T> m_cache;
|
|
size_t m_cachePos;
|
|
size_t m_cachePos;
|
|
- CacheIter m_it;
|
|
|
|
size_t m_filePos;
|
|
size_t m_filePos;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -123,7 +120,6 @@ IOStreamBuffer<T>::IOStreamBuffer( size_t cache )
|
|
, m_numBlocks( 0 )
|
|
, m_numBlocks( 0 )
|
|
, m_blockIdx( 0 )
|
|
, m_blockIdx( 0 )
|
|
, m_cachePos( 0 )
|
|
, m_cachePos( 0 )
|
|
-, m_it()
|
|
|
|
, m_filePos( 0 ) {
|
|
, m_filePos( 0 ) {
|
|
m_cache.resize( cache );
|
|
m_cache.resize( cache );
|
|
std::fill( m_cache.begin(), m_cache.end(), '\n' );
|
|
std::fill( m_cache.begin(), m_cache.end(), '\n' );
|
|
@@ -209,7 +205,6 @@ bool IOStreamBuffer<T>::readNextBlock() {
|
|
m_filePos += m_cacheSize;
|
|
m_filePos += m_cacheSize;
|
|
m_cachePos = 0;
|
|
m_cachePos = 0;
|
|
m_blockIdx++;
|
|
m_blockIdx++;
|
|
- m_it = m_cache.begin();
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -234,32 +229,47 @@ size_t IOStreamBuffer<T>::getFilePos() const {
|
|
|
|
|
|
template<class T>
|
|
template<class T>
|
|
inline
|
|
inline
|
|
-bool IOStreamBuffer<T>::getNextLine( CacheIter &begin, CacheIter &end ) {
|
|
|
|
|
|
+bool IOStreamBuffer<T>::getNextDataLine( std::vector<T> &buffer, T continuationToken ) {
|
|
|
|
+ buffer.resize( m_cacheSize );
|
|
|
|
+ //std::fill( buffer.begin(), buffer.end(), ' ' );
|
|
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
|
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
|
if ( !readNextBlock() ) {
|
|
if ( !readNextBlock() ) {
|
|
- begin = m_it;
|
|
|
|
- end = m_it;
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- m_it = m_cache.begin();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- //size_t i = 0;
|
|
|
|
- begin = m_it;
|
|
|
|
- while ( !IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
|
|
|
|
|
+ bool continuationFound( false ), endOfDataLine( false );
|
|
|
|
+ size_t i = 0;
|
|
|
|
+ while ( !endOfDataLine ) {
|
|
|
|
+ if ( continuationToken == m_cache[ m_cachePos ] ) {
|
|
|
|
+ continuationFound = true;
|
|
|
|
+ ++m_cachePos;
|
|
|
|
+ }
|
|
|
|
+ if ( IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
|
|
|
+ if ( !continuationFound ) {
|
|
|
|
+ // the end of the data line
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ // skip line end
|
|
|
|
+ while ( m_cache[m_cachePos] != '\n') {
|
|
|
|
+ ++m_cachePos;
|
|
|
|
+ }
|
|
|
|
+ ++m_cachePos;
|
|
|
|
+ continuationFound = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ buffer[ i ] = m_cache[ m_cachePos ];
|
|
m_cachePos++;
|
|
m_cachePos++;
|
|
- ++m_it;
|
|
|
|
- //i++;
|
|
|
|
|
|
+ i++;
|
|
if ( m_cachePos >= m_cacheSize ) {
|
|
if ( m_cachePos >= m_cacheSize ) {
|
|
if ( !readNextBlock() ) {
|
|
if ( !readNextBlock() ) {
|
|
- begin = m_it;
|
|
|
|
- end = m_it;
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ++m_it;
|
|
|
|
- end = m_it;
|
|
|
|
|
|
+
|
|
|
|
+ buffer[ i ] = '\n';
|
|
m_cachePos++;
|
|
m_cachePos++;
|
|
|
|
|
|
return true;
|
|
return true;
|