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
18namespace libetonyek
19{
20
21 class IWAMessage
22{
23public:
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
44private:
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
66private:
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
72private:
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: */
IWAField.h
libetonyek::IWAField::Tag
Tag
Definition IWAField.h:30
libetonyek::IWAMessageField
Definition IWAField.h:223
libetonyek::IWAMessage::bytes
const IWABytesField & bytes(std::size_t field) const
Definition IWAMessage.cpp:164
libetonyek::IWAMessage::m_fields
FieldList_t m_fields
Definition IWAMessage.h:74
libetonyek::IWAMessage::sint64
const IWASInt64Field & sint64(std::size_t field) const
Definition IWAMessage.cpp:139
libetonyek::IWAMessage::IWAMessage
IWAMessage()
Definition IWAMessage.cpp:35
libetonyek::IWAMessage::uint32
const IWAUInt32Field & uint32(std::size_t field) const
Definition IWAMessage.cpp:124
libetonyek::IWAMessage::bool_
const IWABoolField & bool_(std::size_t field) const
Definition IWAMessage.cpp:144
libetonyek::IWAMessage::message
const IWAMessageField & message(std::size_t field) const
Definition IWAMessage.cpp:169
libetonyek::IWAMessage::InputRange_t
std::pair< long, long > InputRange_t
Definition IWAMessage.h:53
libetonyek::IWAMessage::sint32
const IWASInt32Field & sint32(std::size_t field) const
Definition IWAMessage.cpp:134
libetonyek::IWAMessage::parse
void parse(unsigned long length)
Definition IWAMessage.cpp:63
libetonyek::IWAMessage::m_input
RVNGInputStreamPtr_t m_input
Definition IWAMessage.h:73
libetonyek::IWAMessage::uint64
const IWAUInt64Field & uint64(std::size_t field) const
Definition IWAMessage.cpp:129
libetonyek::IWAMessage::fixed64
const IWAFixed64Field & fixed64(std::size_t field) const
Definition IWAMessage.cpp:149
libetonyek::IWAMessage::fixed32
const IWAFixed32Field & fixed32(std::size_t field) const
Definition IWAMessage.cpp:174
libetonyek::IWAMessage::float_
const IWAFloatField & float_(std::size_t field) const
Definition IWAMessage.cpp:179
libetonyek::IWAMessage::getField
const FieldT & getField(std::size_t field, WireType wireType, IWAField::Tag tag) const
Definition IWAMessage.cpp:185
libetonyek::IWAMessage::WireType
WireType
Definition IWAMessage.h:46
libetonyek::IWAMessage::WIRE_TYPE_VARINT
@ WIRE_TYPE_VARINT
Definition IWAMessage.h:47
libetonyek::IWAMessage::WIRE_TYPE_32_BIT
@ WIRE_TYPE_32_BIT
Definition IWAMessage.h:50
libetonyek::IWAMessage::WIRE_TYPE_64_BIT
@ WIRE_TYPE_64_BIT
Definition IWAMessage.h:48
libetonyek::IWAMessage::WIRE_TYPE_LENGTH_DELIMITED
@ WIRE_TYPE_LENGTH_DELIMITED
Definition IWAMessage.h:49
libetonyek::IWAMessage::FieldList_t
std::map< unsigned, Field > FieldList_t
Definition IWAMessage.h:64
libetonyek::IWORKToken::string
@ string
Definition IWORKToken.h:418
libetonyek::IWORKToken::double_
@ double_
Definition IWORKToken.h:663
libetonyek::IWORKToken::end
@ end
Definition IWORKToken.h:193
libetonyek::IWORKToken::start
@ start
Definition IWORKToken.h:412
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::IWAFieldPtr_t
std::shared_ptr< IWAField > IWAFieldPtr_t
Definition IWAField.h:67
libetonyek::IWASInt32Field
detail::IWAFieldImpl< IWAField::TAG_SINT32, int32_t, IWAReader::SInt32 > IWASInt32Field
Definition IWAField.h:209
libetonyek::IWAUInt32Field
detail::IWAFieldImpl< IWAField::TAG_UINT32, uint32_t, IWAReader::UInt32 > IWAUInt32Field
Definition IWAField.h:207
libetonyek::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libetonyek_utils.h:82
libetonyek::IWASInt64Field
detail::IWAFieldImpl< IWAField::TAG_SINT64, int64_t, IWAReader::SInt64 > IWASInt64Field
Definition IWAField.h:210
libetonyek::IWAUInt64Field
detail::IWAFieldImpl< IWAField::TAG_UINT64, uint64_t, IWAReader::UInt64 > IWAUInt64Field
Definition IWAField.h:208
libetonyek::IWADoubleField
detail::IWAFieldImpl< IWAField::TAG_DOUBLE, double, IWAReader::Double > IWADoubleField
Definition IWAField.h:214
libetonyek::IWABoolField
detail::IWAFieldImpl< IWAField::TAG_BOOL, bool, IWAReader::Bool > IWABoolField
Definition IWAField.h:211
libetonyek::IWAFixed64Field
detail::IWAFieldImpl< IWAField::TAG_FIXED64, uint64_t, IWAReader::Fixed64 > IWAFixed64Field
Definition IWAField.h:213
libetonyek::IWAStringField
detail::IWAFieldImpl< IWAField::TAG_STRING, std::string, IWAReader::String > IWAStringField
Definition IWAField.h:216
libetonyek::IWAFixed32Field
detail::IWAFieldImpl< IWAField::TAG_FIXED32, uint32_t, IWAReader::Fixed32 > IWAFixed32Field
Definition IWAField.h:219
libetonyek::IWAFloatField
detail::IWAFieldImpl< IWAField::TAG_FLOAT, float, IWAReader::Float > IWAFloatField
Definition IWAField.h:220
libetonyek::IWABytesField
detail::IWAFieldImpl< IWAField::TAG_BYTES, RVNGInputStreamPtr_t, IWAReader::Bytes > IWABytesField
Definition IWAField.h:217
libetonyek::IWAMessage::Field::m_pieces
std::deque< InputRange_t > m_pieces
Definition IWAMessage.h:60
libetonyek::IWAMessage::Field::m_wireType
WireType m_wireType
Definition IWAMessage.h:59
libetonyek::IWAMessage::Field::Field
Field(WireType wireType)
Definition IWAMessage.cpp:28
libetonyek::IWAMessage::Field::m_realField
IWAFieldPtr_t m_realField
Definition IWAMessage.h:61