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 {
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  {
49  if (this->getId())
50  m_arrayDict[get(this->getId())] = m_elements;
51  }
52 
53 private:
55  std::deque<Type> &m_elements;
56 };
57 
58 }
59 
60 #endif // IWORKMUTABLEARRAYELEMENT_H_INCLUDED
61 
62 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition: IWORKXMLContext.h:18
Definition: KEY1Token.h:51
std::unordered_map< ID_t, std::deque< Type > > ArrayDict_t
Definition: IWORKMutableArrayElement.h:23
Definition: IWORKMutableArrayElement.h:19
IWORKContainerContext< Type, NestedParser, Collector, Id, RefId > Super_t
Definition: IWORKMutableArrayElement.h:21
IWORKXMLContextPtr_t element(const int name) override
Definition: IWORKContainerContext.h:51
void endOfElement() override
Definition: IWORKMutableArrayElement.h:46
IWORKXMLContextPtr_t element(const int name) override
Definition: IWORKMutableArrayElement.h:41
const char * name
Definition: IWORKToken.cpp:43
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque< Type > &elements)
Definition: IWORKMutableArrayElement.h:26
Definition: IWORKContainerContext.h:27
Definition: IWORKXMLParserState.h:31
std::unordered_map< ID_t, Type > ContextDict_t
Definition: IWORKMutableArrayElement.h:22
std::deque< Type > & m_elements
Definition: IWORKMutableArrayElement.h:55
ArrayDict_t & m_arrayDict
Definition: IWORKMutableArrayElement.h:54
void endOfElement() override
Definition: IWORKContainerContext.h:69
IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque< Type > &elements)
Definition: IWORKMutableArrayElement.h:33

Generated for libetonyek by doxygen 1.8.6