/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef BaseDataStreamMarshaller_hpp_ #define BaseDataStreamMarshaller_hpp_ #include "command/IDataStructure.h" #include "command/BrokerError.h" #include "command/AbstractCommand.h" #include "marshal/BinaryReader.h" #include "marshal/BinaryWriter.h" #include "marshal/BooleanStream.h" #include #include #include #include #include using namespace std; namespace ActiveMQ { namespace Marshalling { class ProtocolFormat; class BaseDataStreamMarshaller { public: BaseDataStreamMarshaller() {}; virtual ~BaseDataStreamMarshaller() {}; virtual std::auto_ptr createCommand() = 0; virtual char getDataStructureType() = 0; virtual void unmarshal(ProtocolFormat& wireFormat, ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs) = 0; virtual size_t marshal1(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BooleanStream& bs) = 0; virtual void marshal2(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs) = 0; static std::string unmarshalString(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); static size_t writeString1(const std::string& str, ActiveMQ::IO::BooleanStream& bs); static void writeString2(const std::string& str, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static int64_t unmarshalLong(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); static size_t writeLong1(int64_t i, ActiveMQ::IO::BooleanStream& bs); static void writeLong2(int64_t i, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static std::auto_ptr unmarshalCachedObject(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); static std::auto_ptr unmarshalNestedObject(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1BrokerError(ProtocolFormat& wireFormat, const boost::shared_ptr& be, ActiveMQ::IO::BooleanStream& bs); static void marshal2BrokerError(ProtocolFormat& wireFormat, const boost::shared_ptr& be, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static boost::shared_ptr unmarshalBrokerError(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1CachedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::AbstractCommand& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2CachedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::AbstractCommand& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1NestedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::AbstractCommand& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2NestedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::AbstractCommand& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1CachedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2CachedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1NestedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2NestedObject(ProtocolFormat& wireFormat, const ActiveMQ::Command::IDataStructure& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1CachedObject(ProtocolFormat& wireFormat, const boost::shared_ptr& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2CachedObject(ProtocolFormat& wireFormat, const boost::shared_ptr& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static size_t marshal1NestedObject(ProtocolFormat& wireFormat, const boost::shared_ptr& o, ActiveMQ::IO::BooleanStream& bs); static void marshal2NestedObject(ProtocolFormat& wireFormat, const boost::shared_ptr& o, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); template size_t marshal1ObjectArray(ProtocolFormat& wireFormat, const std::vector >& arr, ActiveMQ::IO::BooleanStream& bs); template void marshal2ObjectArray(ProtocolFormat& wireFormat, const std::vector >& arr, ActiveMQ::IO::BinaryWriter& dataOut, ActiveMQ::IO::BooleanStream& bs); static std::vector unmarshalConstByteSequence(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs, size_t num); static std::vector unmarshalByteSequence(ProtocolFormat& wireFormat, ActiveMQ::IO::BinaryReader& dataIn, ActiveMQ::IO::BooleanStream& bs); }; } } #endif /*BaseDataStreamMarshaller_hpp_*/