Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IWAMESSAGE_H_INCLUDED
00011 #define IWAMESSAGE_H_INCLUDED
00012
00013 #include <map>
00014 #include <utility>
00015
00016 #include "IWAField.h"
00017
00018 namespace libetonyek
00019 {
00020
00021 class IWAMessage
00022 {
00023 public:
00024 IWAMessage();
00025 IWAMessage(const RVNGInputStreamPtr_t &input, unsigned long length);
00026 IWAMessage(const RVNGInputStreamPtr_t &input, long start, long end);
00027
00028 const IWAUInt32Field &uint32(std::size_t field) const;
00029 const IWAUInt64Field &uint64(std::size_t field) const;
00030 const IWASInt32Field &sint32(std::size_t field) const;
00031 const IWASInt64Field &sint64(std::size_t field) const;
00032 const IWABoolField &bool_(std::size_t field) const;
00033
00034 const IWAFixed64Field &fixed64(std::size_t field) const;
00035 const IWADoubleField &double_(std::size_t field) const;
00036
00037 const IWAStringField &string(std::size_t field) const;
00038 const IWABytesField &bytes(std::size_t field) const;
00039 const IWAMessageField &message(std::size_t field) const;
00040
00041 const IWAFixed32Field &fixed32(std::size_t field) const;
00042 const IWAFloatField &float_(std::size_t field) const;
00043
00044 private:
00045 enum WireType
00046 {
00047 WIRE_TYPE_VARINT,
00048 WIRE_TYPE_64_BIT,
00049 WIRE_TYPE_LENGTH_DELIMITED,
00050 WIRE_TYPE_32_BIT = 5
00051 };
00052
00053 typedef std::pair<long, long> InputRange_t;
00054
00055 struct Field
00056 {
00057 explicit Field(WireType wireType);
00058
00059 WireType m_wireType;
00060 std::deque<InputRange_t> m_pieces;
00061 IWAFieldPtr_t m_realField;
00062 };
00063
00064 typedef std::map<unsigned, Field> FieldList_t;
00065
00066 private:
00067 void parse(unsigned long length);
00068
00069 template<typename FieldT>
00070 const FieldT &getField(std::size_t field, WireType wireType, IWAField::Tag tag) const;
00071
00072 private:
00073 RVNGInputStreamPtr_t m_input;
00074 mutable FieldList_t m_fields;
00075 };
00076
00077 }
00078
00079 #endif
00080
00081