IWAMessage.h Source File documentation

IWAMessage.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libetonyek project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef IWAMESSAGE_H_INCLUDED
11 #define IWAMESSAGE_H_INCLUDED
12
13 #include <map>
14 #include <utility>
15
16 #include "IWAField.h"
17
18 namespace libetonyek
19 {
20
21 class IWAMessage
22 {
23 public:
24 IWAMessage();
25 IWAMessage(const RVNGInputStreamPtr_t &input, unsigned long length);
26 IWAMessage(const RVNGInputStreamPtr_t &input, long start, long end);
27
28 const IWAUInt32Field &uint32(std::size_t field) const;
29 const IWAUInt64Field &uint64(std::size_t field) const;
30 const IWASInt32Field &sint32(std::size_t field) const;
31 const IWASInt64Field &sint64(std::size_t field) const;
32 const IWABoolField &bool_(std::size_t field) const;
33
34 const IWAFixed64Field &fixed64(std::size_t field) const;
35 const IWADoubleField &double_(std::size_t field) const;
36
37 const IWAStringField &string(std::size_t field) const;
38 const IWABytesField &bytes(std::size_t field) const;
39 const IWAMessageField &message(std::size_t field) const;
40
41 const IWAFixed32Field &fixed32(std::size_t field) const;
42 const IWAFloatField &float_(std::size_t field) const;
43
44 private:
45 enum WireType
46 {
47 WIRE_TYPE_VARINT,
48 WIRE_TYPE_64_BIT,
49 WIRE_TYPE_LENGTH_DELIMITED,
50 WIRE_TYPE_32_BIT = 5
51 };
52
53 typedef std::pair<long, long> InputRange_t;
54
55 struct Field
56 {
57 explicit Field(WireType wireType);
58
59 WireType m_wireType;
60 std::deque<InputRange_t> m_pieces;
61 IWAFieldPtr_t m_realField;
62 };
63
64 typedef std::map<unsigned, Field> FieldList_t;
65
66 private:
67 void parse(unsigned long length);
68
69 template<typename FieldT>
70 const FieldT &getField(std::size_t field, WireType wireType, IWAField::Tag tag) const;
71
72 private:
73 RVNGInputStreamPtr_t m_input;
74 mutable FieldList_t m_fields;
75 };
76
77 }
78
79 #endif
80
81 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWAField::TAG_SINT32
@ TAG_SINT32
Definition: IWAField.h:35
libetonyek::IWAMessage::Field::m_realField
IWAFieldPtr_t m_realField
Definition: IWAMessage.h:61
libetonyek
Definition: IWORKBezierElement.cpp:20
libetonyek::IWAMessage::Field::m_wireType
WireType m_wireType
Definition: IWAMessage.h:59
libetonyek::IWAFieldPtr_t
std::shared_ptr< IWAField > IWAFieldPtr_t
Definition: IWAField.h:67
libetonyek::IWAMessage::bytes
const IWABytesField & bytes(std::size_t field) const
Definition: IWAMessage.cpp:162
libetonyek::IWAMessage::Field::Field
Field(WireType wireType)
Definition: IWAMessage.cpp:28
libetonyek::IWAField::Tag
Tag
Definition: IWAField.h:29
libetonyek::IWAMessage::bool_
const IWABoolField & bool_(std::size_t field) const
Definition: IWAMessage.cpp:142
ETONYEK_DEBUG_MSG
#define ETONYEK_DEBUG_MSG(M)
Definition: libetonyek_utils.h:54
m_input
RVNGInputStreamPtr_t m_input
Definition: EtonyekDocument.cpp:74
libetonyek::IWAMessage::fixed32
const IWAFixed32Field & fixed32(std::size_t field) const
Definition: IWAMessage.cpp:172
libetonyek::IWAMessage::getField
const FieldT & getField(std::size_t field, WireType wireType, IWAField::Tag tag) const
Definition: IWAMessage.cpp:183
libetonyek::IWAMessage::uint32
const IWAUInt32Field & uint32(std::size_t field) const
Definition: IWAMessage.cpp:122
libetonyek::IWAMessage::Field
Definition: IWAMessage.h:55
libetonyek::IWAMessageField
Definition: IWAField.h:222
libetonyek::IWAMessage::FieldList_t
std::map< unsigned, Field > FieldList_t
Definition: IWAMessage.h:64
libetonyek::IWAField::TAG_DOUBLE
@ TAG_DOUBLE
Definition: IWAField.h:41
libetonyek::IWAMessage::string
const IWAStringField & string(std::size_t field) const
Definition: IWAMessage.cpp:157
libetonyek::IWAField::TAG_FIXED64
@ TAG_FIXED64
Definition: IWAField.h:39
libetonyek::IWAMessage::m_input
RVNGInputStreamPtr_t m_input
Definition: IWAMessage.h:73
libetonyek::IWAField::TAG_FIXED32
@ TAG_FIXED32
Definition: IWAField.h:45
libetonyek::IWAMessage::m_fields
FieldList_t m_fields
Definition: IWAMessage.h:74
libetonyek::IWAMessage::message
const IWAMessageField & message(std::size_t field) const
Definition: IWAMessage.cpp:167
libetonyek::IWAMessage::Field::m_pieces
std::deque< InputRange_t > m_pieces
Definition: IWAMessage.h:60
libetonyek::IWAMessage::IWAMessage
IWAMessage()
Definition: IWAMessage.cpp:35
libetonyek::IWAMessage::float_
const IWAFloatField & float_(std::size_t field) const
Definition: IWAMessage.cpp:177
libetonyek::IWAField::TAG_UINT64
@ TAG_UINT64
Definition: IWAField.h:34
libetonyek::IWAMessage::fixed64
const IWAFixed64Field & fixed64(std::size_t field) const
Definition: IWAMessage.cpp:147
libetonyek::IWAMessage::parse
void parse(unsigned long length)
Definition: IWAMessage.cpp:61
libetonyek::IWAMessage
Definition: IWAMessage.h:21
libetonyek::detail::IWAFieldImpl
Definition: IWAField.h:73
libetonyek::IWAMessage::uint64
const IWAUInt64Field & uint64(std::size_t field) const
Definition: IWAMessage.cpp:127
libetonyek::IWAMessage::double_
const IWADoubleField & double_(std::size_t field) const
Definition: IWAMessage.cpp:152
libetonyek::IWAMessage::WIRE_TYPE_VARINT
@ WIRE_TYPE_VARINT
Definition: IWAMessage.h:47
libetonyek::IWAMessage::InputRange_t
std::pair< long, long > InputRange_t
Definition: IWAMessage.h:53
libetonyek::IWAField::TAG_STRING
@ TAG_STRING
Definition: IWAField.h:42
libetonyek::IWORKToken::start
@ start
Definition: IWORKToken.h:405
libetonyek::IWAMessage::WireType
WireType
Definition: IWAMessage.h:45
libetonyek::IWAField::TAG_UINT32
@ TAG_UINT32
Definition: IWAField.h:33
libetonyek::IWAField::TAG_MESSAGE
@ TAG_MESSAGE
Definition: IWAField.h:44
libetonyek::IWAMessage::sint32
const IWASInt32Field & sint32(std::size_t field) const
Definition: IWAMessage.cpp:132
libetonyek::IWAMessage::WIRE_TYPE_32_BIT
@ WIRE_TYPE_32_BIT
Definition: IWAMessage.h:50
IWAMessage.h
libetonyek::IWAMessage::WIRE_TYPE_64_BIT
@ WIRE_TYPE_64_BIT
Definition: IWAMessage.h:48
libetonyek::IWORKToken::end
@ end
Definition: IWORKToken.h:189
libetonyek::IWAMessage::WIRE_TYPE_LENGTH_DELIMITED
@ WIRE_TYPE_LENGTH_DELIMITED
Definition: IWAMessage.h:49
libetonyek::IWAField::TAG_SINT64
@ TAG_SINT64
Definition: IWAField.h:36
libetonyek::readU32
uint32_t readU32(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:76
libetonyek::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libetonyek_utils.h:82
libetonyek::readU64
uint64_t readU64(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:92
libetonyek::IWAField::TAG_BYTES
@ TAG_BYTES
Definition: IWAField.h:43
libetonyek::IWAMessage::sint64
const IWASInt64Field & sint64(std::size_t field) const
Definition: IWAMessage.cpp:137
libetonyek::IWAField::TAG_FLOAT
@ TAG_FLOAT
Definition: IWAField.h:47
libetonyek::IWAField::TAG_BOOL
@ TAG_BOOL
Definition: IWAField.h:37
libetonyek::readUVar
uint64_t readUVar(const RVNGInputStreamPtr_t &input)
Definition: libetonyek_utils.cpp:108
IWAField.h