IWAObjectIndex.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 IWAOBJECTINDEX_H_INCLUDED
11#define IWAOBJECTINDEX_H_INCLUDED
12
13#include <map>
14#include <string>
15#include <utility>
16
17#include <boost/optional.hpp>
18
19#include "libetonyek_utils.h"
20
21 namespace libetonyek
22{
23
24 class IWAMessage;
25
26 class IWAObjectIndex
27{
28 public:
29 struct ObjectRecord
30 {
31 ObjectRecord();
32 ObjectRecord(const RVNGInputStreamPtr_t &stream, unsigned type, long pos, unsigned long headerLen, unsigned long dataLen);
33
34 RVNGInputStreamPtr_t m_stream;
35 unsigned m_type;
36 std::pair<long, long> m_headerRange;
37 std::pair<long, long> m_dataRange;
38 };
39
40 public:
41 IWAObjectIndex(const RVNGInputStreamPtr_t &fragments, const RVNGInputStreamPtr_t &package);
42
43 void parse();
44
45 void queryObject(const unsigned id, unsigned &type, boost::optional<IWAMessage> &msg) const;
46 boost::optional<unsigned> getObjectType(const unsigned id) const;
47 const RVNGInputStreamPtr_t queryFile(unsigned id) const;
48 boost::optional<IWORKColor> queryFileColor(unsigned id) const;
49
50 private:
51 void scanFragment(unsigned id);
52 void scanFragment(unsigned id, const RVNGInputStreamPtr_t &stream);
53
54 void scanColorFileMap(unsigned id);
55 boost::optional<IWORKColor> scanColorFileCorrespondance(unsigned id);
56 private:
57 const RVNGInputStreamPtr_t m_fragments;
58 const RVNGInputStreamPtr_t m_package;
59
60 mutable std::map<unsigned, std::string> m_unparsedFragments;
61 mutable std::map<unsigned, std::pair<unsigned, ObjectRecord>> m_fragmentObjectMap;
62 mutable std::map<unsigned, std::pair<std::string, RVNGInputStreamPtr_t>> m_fileMap;
63 mutable std::map<unsigned, IWORKColor> m_fileColorMap;
64};
65
66}
67
68#endif
69
70/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWAMessage
Definition IWAMessage.h:22
libetonyek::IWAObjectIndex::scanFragment
void scanFragment(unsigned id)
Definition IWAObjectIndex.cpp:171
libetonyek::IWAObjectIndex::getObjectType
boost::optional< unsigned > getObjectType(const unsigned id) const
Definition IWAObjectIndex.cpp:141
libetonyek::IWAObjectIndex::queryFileColor
boost::optional< IWORKColor > queryFileColor(unsigned id) const
Definition IWAObjectIndex.cpp:228
libetonyek::IWAObjectIndex::m_unparsedFragments
std::map< unsigned, std::string > m_unparsedFragments
Definition IWAObjectIndex.h:60
libetonyek::IWAObjectIndex::m_fragments
const RVNGInputStreamPtr_t m_fragments
Definition IWAObjectIndex.h:57
libetonyek::IWAObjectIndex::queryObject
void queryObject(const unsigned id, unsigned &type, boost::optional< IWAMessage > &msg) const
Definition IWAObjectIndex.cpp:123
libetonyek::IWAObjectIndex::m_fragmentObjectMap
std::map< unsigned, std::pair< unsigned, ObjectRecord > > m_fragmentObjectMap
Definition IWAObjectIndex.h:61
libetonyek::IWAObjectIndex::queryFile
const RVNGInputStreamPtr_t queryFile(unsigned id) const
Definition IWAObjectIndex.cpp:152
libetonyek::IWAObjectIndex::m_fileColorMap
std::map< unsigned, IWORKColor > m_fileColorMap
Definition IWAObjectIndex.h:63
libetonyek::IWAObjectIndex::scanColorFileMap
void scanColorFileMap(unsigned id)
Definition IWAObjectIndex.cpp:239
libetonyek::IWAObjectIndex::IWAObjectIndex
IWAObjectIndex(const RVNGInputStreamPtr_t &fragments, const RVNGInputStreamPtr_t &package)
Definition IWAObjectIndex.cpp:47
libetonyek::IWAObjectIndex::m_fileMap
std::map< unsigned, std::pair< std::string, RVNGInputStreamPtr_t > > m_fileMap
Definition IWAObjectIndex.h:62
libetonyek::IWAObjectIndex::scanColorFileCorrespondance
boost::optional< IWORKColor > scanColorFileCorrespondance(unsigned id)
Definition IWAObjectIndex.cpp:267
libetonyek::IWAObjectIndex::parse
void parse()
Definition IWAObjectIndex.cpp:57
libetonyek::IWAObjectIndex::m_package
const RVNGInputStreamPtr_t m_package
Definition IWAObjectIndex.h:58
libetonyek_utils.h
libetonyek::IWORKToken::type
@ type
Definition IWORKToken.h:493
libetonyek::IWORKToken::pos
@ pos
Definition IWORKToken.h:599
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libetonyek_utils.h:82
libetonyek::IWAObjectIndex::ObjectRecord::m_type
unsigned m_type
Definition IWAObjectIndex.h:35
libetonyek::IWAObjectIndex::ObjectRecord::m_dataRange
std::pair< long, long > m_dataRange
Definition IWAObjectIndex.h:37
libetonyek::IWAObjectIndex::ObjectRecord::ObjectRecord
ObjectRecord()
Definition IWAObjectIndex.cpp:30
libetonyek::IWAObjectIndex::ObjectRecord::m_stream
RVNGInputStreamPtr_t m_stream
Definition IWAObjectIndex.h:34
libetonyek::IWAObjectIndex::ObjectRecord::m_headerRange
std::pair< long, long > m_headerRange
Definition IWAObjectIndex.h:36