- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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(const RVNGInputStreamPtr_t &input, unsigned long length);
25 IWAMessage(const RVNGInputStreamPtr_t &input, long start, long end);
26
27 const IWAUInt32Field &uint32(std::size_t field) const;
28 const IWAUInt64Field &uint64(std::size_t field) const;
29 const IWASInt32Field &sint32(std::size_t field) const;
30 const IWASInt64Field &sint64(std::size_t field) const;
31 const IWABoolField &bool_(std::size_t field) const;
32
33 const IWAFixed64Field &fixed64(std::size_t field) const;
34 const IWADoubleField &double_(std::size_t field) const;
35
36 const IWAStringField &string(std::size_t field) const;
37 const IWABytesField &bytes(std::size_t field) const;
38 const IWAMessageField &message(std::size_t field) const;
39
40 const IWAFixed32Field &fixed32(std::size_t field) const;
41 const IWAFloatField &float_(std::size_t field) const;
42
43 private:
44 enum WireType
45 {
46 WIRE_TYPE_VARINT,
47 WIRE_TYPE_64_BIT,
48 WIRE_TYPE_LENGTH_DELIMITED,
49 WIRE_TYPE_32_BIT = 5
50 };
51
52 typedef std::pair<long, long> InputRange_t;
53
54 struct Field
55 {
56 explicit Field(WireType wireType);
57
58 WireType m_wireType;
59 std::deque<InputRange_t> m_pieces;
60 IWAFieldPtr_t m_realField;
61 };
62
63 typedef std::map<unsigned, Field> FieldList_t;
64
65 private:
66 void parse(unsigned long length);
67
68 template<typename FieldT>
69 const FieldT &getField(std::size_t field, WireType wireType, IWAField::Tag tag) const;
70
71 private:
72 RVNGInputStreamPtr_t m_input;
73 mutable FieldList_t m_fields;
74 };
75
76 }
77
78 #endif
79
80 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek
Definition: IWORKBezierElement.cpp:18
libetonyek::IWAMessage::sint64
const IWASInt64Field & sint64(std::size_t field) const
Definition: IWAMessage.cpp:131
libetonyek::IWAMessage::getField
const FieldT & getField(std::size_t field, WireType wireType, IWAField::Tag tag) const
Definition: IWAMessage.cpp:177
libetonyek::IWAMessage::m_fields
FieldList_t m_fields
Definition: IWAMessage.h:73
libetonyek::IWAMessage::parse
void parse(unsigned long length)
Definition: IWAMessage.cpp:55
libetonyek::IWAMessage::Field::Field
Field(WireType wireType)
Definition: IWAMessage.cpp:29
libetonyek::IWAMessage::InputRange_t
std::pair< long, long > InputRange_t
Definition: IWAMessage.h:52
libetonyek::IWAMessage::fixed64
const IWAFixed64Field & fixed64(std::size_t field) const
Definition: IWAMessage.cpp:141
libetonyek::IWAMessage::WireType
WireType
Definition: IWAMessage.h:44
libetonyek::IWAMessage::WIRE_TYPE_64_BIT
Definition: IWAMessage.h:47
libetonyek::IWAMessage::IWAMessage
IWAMessage(const RVNGInputStreamPtr_t &input, unsigned long length)
Definition: IWAMessage.cpp:36
libetonyek::IWAMessage::Field::m_pieces
std::deque< InputRange_t > m_pieces
Definition: IWAMessage.h:59
libetonyek::IWAField::Tag
Tag
Definition: IWAField.h:28
libetonyek::IWAMessage::string
const IWAStringField & string(std::size_t field) const
Definition: IWAMessage.cpp:151
libetonyek::IWAMessage::WIRE_TYPE_32_BIT
Definition: IWAMessage.h:49
libetonyek::IWAMessage::bytes
const IWABytesField & bytes(std::size_t field) const
Definition: IWAMessage.cpp:156
libetonyek::IWAMessage::float_
const IWAFloatField & float_(std::size_t field) const
Definition: IWAMessage.cpp:171
libetonyek::IWAMessage::WIRE_TYPE_VARINT
Definition: IWAMessage.h:46
libetonyek::IWAMessage::bool_
const IWABoolField & bool_(std::size_t field) const
Definition: IWAMessage.cpp:136
libetonyek::IWAFieldPtr_t
boost::shared_ptr< IWAField > IWAFieldPtr_t
Definition: IWAField.h:66
libetonyek::IWAMessage::sint32
const IWASInt32Field & sint32(std::size_t field) const
Definition: IWAMessage.cpp:126
libetonyek::detail::IWAFieldImpl
Definition: IWAField.h:72
libetonyek::IWAMessage::uint64
const IWAUInt64Field & uint64(std::size_t field) const
Definition: IWAMessage.cpp:121
libetonyek::RVNGInputStreamPtr_t
boost::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libetonyek_utils.h:111
libetonyek::IWAMessageField
Definition: IWAField.h:207
libetonyek::IWAMessage::message
const IWAMessageField & message(std::size_t field) const
Definition: IWAMessage.cpp:161
libetonyek::IWAMessage::uint32
const IWAUInt32Field & uint32(std::size_t field) const
Definition: IWAMessage.cpp:116
libetonyek::IWAMessage
Definition: IWAMessage.h:21
IWAField.h
libetonyek::IWAMessage::WIRE_TYPE_LENGTH_DELIMITED
Definition: IWAMessage.h:48
libetonyek::IWAMessage::Field
Definition: IWAMessage.h:54
libetonyek::IWAMessage::Field::m_realField
IWAFieldPtr_t m_realField
Definition: IWAMessage.h:60
libetonyek::IWAMessage::FieldList_t
std::map< unsigned, Field > FieldList_t
Definition: IWAMessage.h:63
libetonyek::IWAMessage::Field::m_wireType
WireType m_wireType
Definition: IWAMessage.h:58
libetonyek::IWAMessage::fixed32
const IWAFixed32Field & fixed32(std::size_t field) const
Definition: IWAMessage.cpp:166
libetonyek::IWAMessage::double_
const IWADoubleField & double_(std::size_t field) const
Definition: IWAMessage.cpp:146
libetonyek::IWAMessage::m_input
RVNGInputStreamPtr_t m_input
Definition: IWAMessage.h:72