Skip to content
Snippets Groups Projects
Select Git revision
  • 04d6d48cf3e2ca4f95eb1d21c21396311cc446a3
  • master default protected
  • auto-deploy
  • feature/tray/logwindow
  • feature/cmdline-storage-status
  • update-docs
  • bug-cpuload
  • server2012
  • 3.0
  • 2.1
  • 2.0
  • 1.4
  • 1.3
  • 1.2
  • 1.1
  • autotransfer-v1
  • 1.0
17 results

ATXConfigTest.csproj

Blame
  • binary_data_source.hh 2.95 KiB
    //------------------------------------------------------------------------------
    // This file is part of the OpenStructure project <www.openstructure.org>
    //
    // Copyright (C) 2008-2020 by the OpenStructure authors
    //
    // This library is free software; you can redistribute it and/or modify it under
    // the terms of the GNU Lesser General Public License as published by the Free
    // Software Foundation; either version 3.0 of the License, or (at your option)
    // any later version.
    // This library is distributed in the hope that it will be useful, but WITHOUT
    // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    // FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    // details.
    //
    // You should have received a copy of the GNU Lesser General Public License
    // along with this library; if not, write to the Free Software Foundation, Inc.,
    // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    //------------------------------------------------------------------------------
    #ifndef OST_IO_BINARY_DATA_SOURCE_HH
    #define OST_IO_BINARY_DATA_SOURCE_HH
    /*
      Author: Marco Biasini
      
      minimalistic binary serialization interface
     */
    
    #include <iostream>
    #include <boost/type_traits/is_floating_point.hpp>
    #include <boost/type_traits/is_integral.hpp>
    
    #include <ost/io/module_config.hh>
    namespace ost { namespace io {
    
    class BinaryDataSource {
    public:
        BinaryDataSource(std::istream& stream) 
          : stream_(stream) {
        }
        template <typename SERIALIZABLE>
        BinaryDataSource& operator >> (SERIALIZABLE& object) {
          Serialize(*this, object);
          return *this;
        }
        template <typename SERIALIZABLE>
        BinaryDataSource& operator & (SERIALIZABLE& object) {
          return this->operator>>(object);
        }
        std::istream& Stream() {
          return stream_;
        }
        
        bool IsSource() { return true; }
    private:
      std::istream& stream_;
    };
    
    namespace detail {
    
    template <bool B, typename T>
    struct SerializeHelper;
    
    template <typename T>
    struct SerializeHelper<false, T> {
      SerializeHelper(BinaryDataSource& source, T& value)
      {
        value.Serialize(source);
      }
    };
    
    template <typename T>