Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef avro_Decoder_hh__
00020 #define avro_Decoder_hh__
00021
00022 #include "Config.hh"
00023 #include <stdint.h>
00024 #include <string>
00025 #include <vector>
00026
00027 #include "ValidSchema.hh"
00028 #include "Stream.hh"
00029
00030 #include <boost/shared_ptr.hpp>
00031
00042
00043 namespace avro {
00044
00049 class AVRO_DECL Decoder {
00050 public:
00051 virtual ~Decoder() { };
00055 virtual void init(InputStream& is) = 0;
00056
00058 virtual void decodeNull() = 0;
00059
00061 virtual bool decodeBool() = 0;
00062
00064 virtual int32_t decodeInt() = 0;
00065
00067 virtual int64_t decodeLong() = 0;
00068
00070 virtual float decodeFloat() = 0;
00071
00073 virtual double decodeDouble() = 0;
00074
00076 std::string decodeString() {
00077 std::string result;
00078 decodeString(result);
00079 return result;
00080 }
00081
00085 virtual void decodeString(std::string& value) = 0;
00086
00088 virtual void skipString() = 0;
00089
00091 std::vector<uint8_t> decodeBytes() {
00092 std::vector<uint8_t> result;
00093 decodeBytes(result);
00094 return result;
00095 }
00096
00099 virtual void decodeBytes(std::vector<uint8_t>& value) = 0;
00100
00102 virtual void skipBytes() = 0;
00103
00110 std::vector<uint8_t> decodeFixed(size_t n) {
00111 std::vector<uint8_t> result;
00112 decodeFixed(n, result);
00113 return result;
00114 }
00115
00122 virtual void decodeFixed(size_t n, std::vector<uint8_t>& value) = 0;
00123
00125 virtual void skipFixed(size_t n) = 0;
00126
00128 virtual size_t decodeEnum() = 0;
00129
00131 virtual size_t arrayStart() = 0;
00132
00134 virtual size_t arrayNext() = 0;
00135
00140 virtual size_t skipArray() = 0;
00141
00143 virtual size_t mapStart() = 0;
00144
00146 virtual size_t mapNext() = 0;
00147
00152 virtual size_t skipMap() = 0;
00153
00155 virtual size_t decodeUnionIndex() = 0;
00156 };
00157
00161 typedef boost::shared_ptr<Decoder> DecoderPtr;
00162
00167 class AVRO_DECL ResolvingDecoder : public Decoder {
00168 public:
00174 virtual const std::vector<size_t>& fieldOrder() = 0;
00175 };
00176
00180 typedef boost::shared_ptr<ResolvingDecoder> ResolvingDecoderPtr;
00184 AVRO_DECL DecoderPtr binaryDecoder();
00185
00190 AVRO_DECL DecoderPtr validatingDecoder(const ValidSchema& schema,
00191 const DecoderPtr& base);
00192
00196 AVRO_DECL DecoderPtr jsonDecoder(const ValidSchema& schema);
00197
00204 AVRO_DECL ResolvingDecoderPtr resolvingDecoder(const ValidSchema& writer,
00205 const ValidSchema& reader, const DecoderPtr& base);
00206
00207
00208 }
00209
00210 #endif