implemented file system directoriy iterator / fixed raw packing / datastream exceptions
This commit is contained in:
parent
1a5e10ee26
commit
2e6bd7253f
7 changed files with 34 additions and 11 deletions
|
|
@ -40,7 +40,8 @@ struct datastream {
|
|||
m_pos += s;
|
||||
return true;
|
||||
}
|
||||
FC_THROW_MSG( "Attempt to read %s bytes beyond end of buffer of size %s", -((m_end-m_pos) - s),(m_end-m_start) );
|
||||
FC_THROW_MSG( "Attempt to read %s bytes beyond end of buffer of size %s",
|
||||
int64_t(-((m_end-m_pos) - s)), int64_t(m_end-m_start) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ struct datastream {
|
|||
m_pos += s;
|
||||
return true;
|
||||
}
|
||||
FC_THROW_MSG( "Attempt to write %s bytes beyond end of buffer of size %s", -((m_end-m_pos) - s),(m_end-m_start) );
|
||||
FC_THROW_MSG( "Attempt to write %s bytes beyond end of buffer of size %s", int64_t(-((m_end-m_pos) - s)),int64_t(m_end-m_start) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ struct datastream {
|
|||
++m_pos;
|
||||
return true;
|
||||
}
|
||||
FC_THROW_MSG( "Attempt to write %s byte beyond end of buffer of size %s", -((m_end-m_pos) - 1), (m_end-m_start) );
|
||||
FC_THROW_MSG( "Attempt to write %s byte beyond end of buffer of size %s", int64_t(-((m_end-m_pos) - 1)), int64_t(m_end-m_start) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ struct datastream {
|
|||
++m_pos;
|
||||
return true;
|
||||
}
|
||||
FC_THROW_MSG( "Attempt to read %s byte beyond end of buffer of size %s", -((m_end-m_pos) - 1), (m_end-m_start) );
|
||||
FC_THROW_MSG( "Attempt to read %s byte beyond end of buffer of size %s", int64_t(-((m_end-m_pos) - 1)), int64_t(m_end-m_start) );
|
||||
++m_pos;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ namespace fc {
|
|||
fc::string to_string( int64_t v );
|
||||
fc::string to_string( double v );
|
||||
fc::string to_string( float v );
|
||||
fc::string to_string( int8_t v );
|
||||
fc::string to_string( uint8_t v );
|
||||
fc::string to_string( int32_t v );
|
||||
fc::string to_string( uint32_t v );
|
||||
fc::string to_string( int16_t v );
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace fc {
|
|||
friend bool operator==( const directory_iterator&, const directory_iterator& );
|
||||
friend bool operator!=( const directory_iterator&, const directory_iterator& );
|
||||
private:
|
||||
fwd<boost::filesystem::directory_iterator,8> _p;
|
||||
fwd<boost::filesystem::directory_iterator,16> _p;
|
||||
};
|
||||
|
||||
bool exists( const path& p );
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace fc {
|
|||
~ifstream();
|
||||
|
||||
void open( const fc::path& file, int m );
|
||||
size_t readsome( char* buf, size_t len );
|
||||
ifstream& read( char* buf, size_t len );
|
||||
void close();
|
||||
bool eof()const;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace fc {
|
|||
uint8_t b = uint8_t(val) & 0x7f;
|
||||
val >>= 7;
|
||||
b |= ((val > 0) << 7);
|
||||
s.put(b);
|
||||
s.write((char*)&b,1);//.put(b);
|
||||
} while( val );
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ namespace fc {
|
|||
uint8_t b = uint8_t(val) & 0x7f;
|
||||
val >>= 7;
|
||||
b |= ((val > 0) << 7);
|
||||
s.put(b);
|
||||
s.write((char*)&b,1);//.put(b);
|
||||
}while( val );
|
||||
}
|
||||
|
||||
|
|
@ -198,11 +198,11 @@ namespace fc {
|
|||
struct if_reflected<fc::true_type> {
|
||||
template<typename Stream, typename T>
|
||||
static inline void pack( Stream& s, const T& v ) {
|
||||
fc::static_reflector<T>::visit( pack_object_visitor<Stream,T>( v, s ) );
|
||||
fc::reflector<T>::visit( pack_object_visitor<Stream,T>( v, s ) );
|
||||
}
|
||||
template<typename Stream, typename T>
|
||||
static inline void unpack( Stream& s, T& v ) {
|
||||
fc::static_reflector<T>::visit( unpack_object_visitor<Stream,T>( v, s ) );
|
||||
fc::reflector<T>::visit( unpack_object_visitor<Stream,T>( v, s ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -234,11 +234,11 @@ namespace fc {
|
|||
|
||||
template<typename Stream, typename T>
|
||||
inline void pack( Stream& s, const T& v ) {
|
||||
fc::raw::detail::if_reflected< typename fc::static_reflector<T>::is_defined >::pack(s,v);
|
||||
fc::raw::detail::if_reflected< typename fc::reflector<T>::is_defined >::pack(s,v);
|
||||
}
|
||||
template<typename Stream, typename T>
|
||||
inline void unpack( Stream& s, T& v ) {
|
||||
fc::raw::detail::if_reflected< typename fc::static_reflector<T>::is_defined >::unpack(s,v);
|
||||
fc::raw::detail::if_reflected< typename fc::reflector<T>::is_defined >::unpack(s,v);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,22 @@ namespace fc {
|
|||
return _p->parent_path();
|
||||
}
|
||||
|
||||
directory_iterator::directory_iterator( const fc::path& p )
|
||||
:_p(p){}
|
||||
|
||||
directory_iterator::directory_iterator(){}
|
||||
directory_iterator::~directory_iterator(){}
|
||||
|
||||
fc::path directory_iterator::operator*()const { return boost::filesystem::path(*(*_p)); }
|
||||
directory_iterator& directory_iterator::operator++(int) { (*_p)++; return *this; }
|
||||
directory_iterator& directory_iterator::operator++() { (*_p)++; return *this; }
|
||||
|
||||
bool operator==( const directory_iterator& r, const directory_iterator& l) {
|
||||
return *r._p == *l._p;
|
||||
}
|
||||
bool operator!=( const directory_iterator& r, const directory_iterator& l) {
|
||||
return *r._p != *l._p;
|
||||
}
|
||||
|
||||
bool exists( const path& p ) { return boost::filesystem::exists(p); }
|
||||
void create_directories( const path& p ) { boost::filesystem::create_directories(p); }
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ namespace fc {
|
|||
void ifstream::open( const fc::path& file, int m ) {
|
||||
my->ifs.open( file.string().c_str(), std::ios::binary );
|
||||
}
|
||||
size_t ifstream::readsome( char* buf, size_t len ) {
|
||||
return my->ifs.readsome( buf, len );
|
||||
}
|
||||
ifstream& ifstream::read( char* buf, size_t len ) {
|
||||
my->ifs.read(buf,len);
|
||||
return *this;
|
||||
|
|
|
|||
Loading…
Reference in a new issue