0
    class OByteStream
    {
    public:
        explicit OByteStream(std::string &s)
                   : _backInsertDevice(s)
                   , _stream(_backInsertDevice)
                   , _oArchive(_stream)
                   {
                   }

        void flush()
                   {
                       _stream.flush();
                   }

        template<class T>
        OByteStream &operator<<(const T &data)
                   {
                       _oArchive << data;
                       return *this;
                   }

    private:
        typedef boost::iostreams::back_insert_device<std::string> BackInsertDevice;
        typedef boost::iostreams::stream<BackInsertDevice> Stream;
        typedef boost::archive::binary_oarchive BinaryOArchive;

        BackInsertDevice _backInsertDevice;
        Stream _stream;
        BinaryOArchive _oArchive;
    };

    class IByteStream
    {
    public:
        explicit IByteStream(const std::string &s)
            : _basicArraySource(s.data(), s.size())
            , _stream(_basicArraySource)
            , _iArchive(_stream)
        {
        }

        template<class T>
        IByteStream &operator>>(T &data)
        {
            _iArchive >> data;
            return *this;
        }

    private:
        typedef boost::iostreams::basic_array_source<char> BasicArraySource;
        typedef boost::iostreams::stream<BasicArraySource> Stream;
        typedef boost::archive::binary_iarchive BinaryIArchive;

        BasicArraySource _basicArraySource;
        Stream _stream;
        BinaryIArchive _iArchive;
    };

2 次元のベクトルを含む構造体をシリアル化解除すると、input_stream_error が発生します。

if(scount != s)
    boost::serialization::throw_exception(
    archive_exception(archive_exception::input_stream_error)
    );

どうすれば修正できますか?

または、バイト ストリームが完全に実現されている場合は、それらについて知りたいと思います。


msvcを使用して、VSでコンパイルされたアプリケーションからQtでコンパイルされたアプリケーションにシリアル化されたデータを送信しました。これがまさにその理由だ。不適切なシリアル化解除を修正するにはどうすればよいですか?

VS ですべての Struct Member Alignments を使用しようとしました。役に立ちませんでした。QtCreator では、そのようなオプションは見つかりませんでした。

4

0 に答える 0