#pragma once /* * Copyright Onix Solutions Limited [OnixS]. All rights reserved. * * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law * and international copyright treaties. * * Access to and use of the software is governed by the terms of the applicable ONIXS Software * Services Agreement (the Agreement) and Customer end user license agreements granting * a non-assignable, non-transferable and non-exclusive license to use the software * for it's own data processing purposes under the terms defined in the Agreement. * * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part * of this source code or associated reference material to any other location for further reproduction * or redistribution, and any amendments to this copyright notice, are expressly prohibited. * * Any reproduction or redistribution for sale or hiring of the Software not in accordance with * the terms of the Agreement is a violation of copyright law. */ #include #include #include #include #include #include #include #include namespace OnixS { namespace FIX { ONIXS_FIXENGINE_API_DECL(class, Message); ONIXS_FIXENGINE_API_DECL(class, Dictionary); namespace SBE { ONIXS_FIXENGINE_API_DECL(class, IDecodeListener); /// Performs the SBE to FIX decoding. class ONIXS_FIXENGINE_API EventBasedDecoder { public: /// Creates the SBE to FIX Decoder. /// /// @param xmlTemplates XML-based SBE templates. /// @param customCoders The custom coders library. EventBasedDecoder(const std::string & xmlTemplates, ISbeCustomCoderLibrary* customCoders = ONIXS_FIXENGINE_NULLPTR); /// Destructor. ~EventBasedDecoder(); /// Tries to decode the given FAST stream buffer into the corresponding FIX Message. /// /// @param[in] templateId The identifier of the SBE template, used to decode the input data. /// @param[in] version The version of the SBE schema, used to decode the input data. /// @param[in] rootBlockLength The length of the root block. This value should be extracted from the message preamble, or from other source. /// @param[in] buffer The FAST stream chunk to be decoded. /// @param[in] offset The index in the buffer at which decoding begins. /// @param[in] count The number of bytes to analyze during the decoding. /// @param[in] listener The listener which receives decoding events. /// @param[out] numberOfDecodedBytes The number of bytes that contained the encoded FIX Message. /// /// @warning The message should point to an existing object. This object is not owned by the Decoder and should be managed by the user. /// /// @throw An exception if the decoding error is detected. /// /// @return 'true' if the given bytes could be decoded into a FIX message, otherwise - 'false'. bool decodeSingleMessage(int version, int templateId, size_t rootBlockLength, const unsigned char * buffer, size_t offset, size_t count, IDecodeListener * listener, size_t * numberOfDecodedBytes) const; /// The maximum known version of the SBE schema. unsigned schemaVersion() const; /// The schema identifier. unsigned schemaId() const; /// The semantic version of the SBE schema. std::string schemaSemanticVersion() const; /// The name of the encoding type of the message header, which is /// the same for all messages in a schema. std::string schemaHeaderType() const; private: friend ONIXS_FIXENGINE_API_DECL(class, OnixS::FIX::Dictionary); EventBasedDecoder(const EventBasedDecoder &); EventBasedDecoder & operator = (const EventBasedDecoder &); struct Impl; Impl * impl_; }; } } }