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
15namespace libetonyek
16{
17
18template<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
25public:
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
40private:
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
53private:
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: */
IWORKContainerContext.h
libetonyek::IWORKContainerContext
Definition IWORKContainerContext.h:28
libetonyek::IWORKContainerContext::element
IWORKXMLContextPtr_t element(const int name) override
Definition IWORKContainerContext.h:51
libetonyek::IWORKContainerContext::endOfElement
void endOfElement() override
Definition IWORKContainerContext.h:69
libetonyek::IWORKMutableArrayElement
Definition IWORKMutableArrayElement.h:20
libetonyek::IWORKMutableArrayElement::ContextDict_t
std::unordered_map< ID_t, Type > ContextDict_t
Definition IWORKMutableArrayElement.h:22
libetonyek::IWORKMutableArrayElement::element
IWORKXMLContextPtr_t element(const int name) override
Definition IWORKMutableArrayElement.h:41
libetonyek::IWORKMutableArrayElement::m_arrayDict
ArrayDict_t & m_arrayDict
Definition IWORKMutableArrayElement.h:54
libetonyek::IWORKMutableArrayElement::m_elements
std::deque< Type > & m_elements
Definition IWORKMutableArrayElement.h:55
libetonyek::IWORKMutableArrayElement::ArrayDict_t
std::unordered_map< ID_t, std::deque< Type > > ArrayDict_t
Definition IWORKMutableArrayElement.h:23
libetonyek::IWORKMutableArrayElement::endOfElement
void endOfElement() override
Definition IWORKMutableArrayElement.h:46
libetonyek::IWORKMutableArrayElement::IWORKMutableArrayElement
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque< Type > &elements)
Definition IWORKMutableArrayElement.h:26
libetonyek::IWORKMutableArrayElement::IWORKMutableArrayElement
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque< Type > &elements)
Definition IWORKMutableArrayElement.h:33
libetonyek::IWORKMutableArrayElement::Super_t
IWORKContainerContext< Type, NestedParser, Collector, Id, RefId > Super_t
Definition IWORKMutableArrayElement.h:21
libetonyek::IWORKXMLParserState
Definition IWORKXMLParserState.h:32
libetonyek::IWORKToken::name
@ name
Definition IWORKToken.h:585
libetonyek::KEY1Token::dict
@ dict
Definition KEY1Token.h:51
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::IWORKXMLContextPtr_t
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition IWORKXMLContext.h:20
libetonyek::get
const ValueT & get(const detail::IWAFieldImpl< TagV, ValueT, Reader > &field)
Definition IWAField.h:190