Commit c48fe4be authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Rewritten TNL::File using std::fstream

This is much simpler than using the C functions. As a bonus, I/O errors
throw exceptions.
parent 680b9315
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -71,14 +71,14 @@ class ArrayIO< Value, Device, Index, false >
                     const Value* data,
                     const Index elements )
   {
      return file.write< Value, Device, Index >( data, elements );
      return file.write< Value, Device >( data, elements );
   }

   static bool load( File& file,
                     Value* data,
                     const Index elements )
   {
      return file.read< Value, Device, Index >( data, elements );
      return file.read< Value, Device >( data, elements );
   }

};
+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ inline void StaticArray< 1, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 1, Value >::save( File& file ) const
{
   if( ! file. write< Value, Devices::Host, int >( data, size ) )
   if( ! file. write< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to write " << getType() << "." << std::endl;
      return false;
+2 −2
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ inline void StaticArray< 2, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 2, Value >::save( File& file ) const
{
   if( ! file. write< Value, Devices::Host, int >( data, size ) )
   if( ! file. write< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to write " << getType() << "." << std::endl;
      return false;
@@ -203,7 +203,7 @@ bool StaticArray< 2, Value >::save( File& file ) const
template< typename Value >
bool StaticArray< 2, Value >::load( File& file)
{
   if( ! file.read< Value, Devices::Host, int >( data, size ) )
   if( ! file.read< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to read " << getType() << "." << std::endl;
      return false;
+2 −2
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ void StaticArray< 3, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 3, Value >::save( File& file ) const
{
   if( ! file. write< Value, Devices::Host, int >( data, size ) )
   if( ! file. write< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to write " << getType() << "." << std::endl;
      return false;
@@ -224,7 +224,7 @@ bool StaticArray< 3, Value >::save( File& file ) const
template< typename Value >
bool StaticArray< 3, Value >::load( File& file)
{
   if( ! file.read< Value, Devices::Host, int >( data, size ) )
   if( ! file.read< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to read " << getType() << "." << std::endl;
      return false;
+2 −2
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ inline void StaticArray< Size, Value >::setValue( const ValueType& val )
template< int Size, typename Value >
bool StaticArray< Size, Value >::save( File& file ) const
{
   if( ! file. write< Value, Devices::Host, int >( data, size ) )
   if( ! file. write< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to write " << getType() << "." << std::endl;
      return false;
@@ -171,7 +171,7 @@ bool StaticArray< Size, Value >::save( File& file ) const
template< int Size, typename Value >
bool StaticArray< Size, Value >::load( File& file)
{
   if( ! file.read< Value, Devices::Host, int >( data, size ) )
   if( ! file.read< Value, Devices::Host >( data, size ) )
   {
      std::cerr << "Unable to read " << getType() << "." << std::endl;
      return false;
Loading