IWORKMutableArrayElement.h Source File documentation

IWORKMutableArrayElement.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 IWORKMUTABLEARRAYELEMENT_H_INCLUDED
11 #define IWORKMUTABLEARRAYELEMENT_H_INCLUDED
12
13 #include "IWORKContainerContext.h"
14
15 namespace libetonyek
16 {
17
18 template<typename Type, class NestedParser, template<typename T, class C> class Collector, unsigned Id, unsigned RefId = 0>
19 class IWORKMutableArrayElement : public IWORKContainerContext<Type, NestedParser, Collector, Id, RefId>
20 {
21 typedef IWORKContainerContext<Type, NestedParser, Collector, Id, RefId> Super_t;
22 typedef std::unordered_map<ID_t, Type> ContextDict_t;
23 typedef std::unordered_map<ID_t, std::deque<Type> > ArrayDict_t;
24
25 public:
26 IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque<Type> &elements)
27 : Super_t(state, elements)
28 , m_arrayDict(arrayDict)
29 , m_elements(elements)
30 {
31 }
32
33 IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque<Type> &elements)
34 : Super_t(state, dict, elements)
35 , m_arrayDict(arrayDict)
36 , m_elements(elements)
37 {
38 }
39
40 private:
41 IWORKXMLContextPtr_t element(const int name) override
42 {
43 return Super_t::element(name);
44 }
45
46 void endOfElement() override
47 {
48 Super_t::endOfElement();
49 if (this->getId())
50 m_arrayDict[get(this->getId())] = m_elements;
51 }
52
53 private:
54 ArrayDict_t &m_arrayDict;
55 std::deque<Type> &m_elements;
56 };
57
58 }
59
60 #endif // IWORKMUTABLEARRAYELEMENT_H_INCLUDED
61
62 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek
Definition: IWORKBezierElement.cpp:20
libetonyek::IWORKXMLContextPtr_t
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition: IWORKXMLContext.h:18
libetonyek::KEY1Token::dict
Definition: KEY1Token.h:51
libetonyek::IWORKMutableArrayElement::ArrayDict_t
std::unordered_map< ID_t, std::deque< Type > > ArrayDict_t
Definition: IWORKMutableArrayElement.h:23
libetonyek::IWORKMutableArrayElement
Definition: IWORKMutableArrayElement.h:19
libetonyek::IWORKMutableArrayElement::Super_t
IWORKContainerContext< Type, NestedParser, Collector, Id, RefId > Super_t
Definition: IWORKMutableArrayElement.h:21
libetonyek::IWORKContainerContext::element
IWORKXMLContextPtr_t element(const int name) override
Definition: IWORKContainerContext.h:51
libetonyek::IWORKMutableArrayElement::endOfElement
void endOfElement() override
Definition: IWORKMutableArrayElement.h:46
libetonyek::IWORKMutableArrayElement::element
IWORKXMLContextPtr_t element(const int name) override
Definition: IWORKMutableArrayElement.h:41
name
const char * name
Definition: IWORKToken.cpp:43
libetonyek::IWORKMutableArrayElement::IWORKMutableArrayElement
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque< Type > &elements)
Definition: IWORKMutableArrayElement.h:26
libetonyek::IWORKContainerContext
Definition: IWORKContainerContext.h:27
libetonyek::IWORKXMLParserState
Definition: IWORKXMLParserState.h:31
libetonyek::IWORKMutableArrayElement::ContextDict_t
std::unordered_map< ID_t, Type > ContextDict_t
Definition: IWORKMutableArrayElement.h:22
libetonyek::IWORKMutableArrayElement::m_elements
std::deque< Type > & m_elements
Definition: IWORKMutableArrayElement.h:55
IWORKContainerContext.h
libetonyek::IWORKMutableArrayElement::m_arrayDict
ArrayDict_t & m_arrayDict
Definition: IWORKMutableArrayElement.h:54
libetonyek::IWORKContainerContext::endOfElement
void endOfElement() override
Definition: IWORKContainerContext.h:69
libetonyek::IWORKMutableArrayElement::IWORKMutableArrayElement
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque< Type > &elements)
Definition: IWORKMutableArrayElement.h:33