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
14
15namespace libetonyek
16{
17
18template<typename Type, class NestedParser, template<typename T, class C> class Collector, unsigned Id, unsigned RefId = 0>
19class IWORKMutableArrayElement : public IWORKContainerContext<Type, NestedParser, Collector, Id, RefId>
20{
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 {
49 if (this->getId())
50 m_arrayDict[get(this->getId())] = m_elements;
51 }
52
53private:
55 std::deque<Type> &m_elements;
56};
57
58}
59
60#endif // IWORKMUTABLEARRAYELEMENT_H_INCLUDED
61
62/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition IWORKContainerContext.h:28
IWORKXMLContextPtr_t element(const int name) override
Definition IWORKContainerContext.h:51
void endOfElement() override
Definition IWORKContainerContext.h:69
Definition IWORKMutableArrayElement.h:20
std::unordered_map< ID_t, Type > ContextDict_t
Definition IWORKMutableArrayElement.h:22
IWORKXMLContextPtr_t element(const int name) override
Definition IWORKMutableArrayElement.h:41
ArrayDict_t & m_arrayDict
Definition IWORKMutableArrayElement.h:54
std::deque< Type > & m_elements
Definition IWORKMutableArrayElement.h:55
std::unordered_map< ID_t, std::deque< Type > > ArrayDict_t
Definition IWORKMutableArrayElement.h:23
void endOfElement() override
Definition IWORKMutableArrayElement.h:46
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque< Type > &elements)
Definition IWORKMutableArrayElement.h:26
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque< Type > &elements)
Definition IWORKMutableArrayElement.h:33
IWORKContainerContext< Type, NestedParser, Collector, Id, RefId > Super_t
Definition IWORKMutableArrayElement.h:21
Definition IWORKXMLParserState.h:32
@ name
Definition IWORKToken.h:585
@ dict
Definition KEY1Token.h:51
Definition IWORKBezierElement.cpp:21
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition IWORKXMLContext.h:20
const ValueT & get(const detail::IWAFieldImpl< TagV, ValueT, Reader > &field)
Definition IWAField.h:190

Generated for libetonyek by doxygen 1.12.0