Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IWORKMUTABLEARRAYELEMENT_H_INCLUDED
00011 #define IWORKMUTABLEARRAYELEMENT_H_INCLUDED
00012
00013 #include "IWORKContainerContext.h"
00014
00015 namespace libetonyek
00016 {
00017
00018 template<typename Type, class NestedParser, template<typename T, class C> class Collector, unsigned Id, unsigned RefId = 0>
00019 class IWORKMutableArrayElement : public IWORKContainerContext<Type, NestedParser, Collector, Id, RefId>
00020 {
00021 typedef IWORKContainerContext<Type, NestedParser, Collector, Id, RefId> Super_t;
00022 typedef boost::unordered_map<ID_t, Type> ContextDict_t;
00023 typedef boost::unordered_map<ID_t, std::deque<Type> > ArrayDict_t;
00024
00025 public:
00026 IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, std::deque<Type> &elements)
00027 : Super_t(state, elements)
00028 , m_arrayDict(arrayDict)
00029 , m_elements(elements)
00030 {
00031 }
00032
00033 IWORKMutableArrayElement(IWORKXMLParserState &state, ArrayDict_t &arrayDict, ContextDict_t &dict, std::deque<Type> &elements)
00034 : Super_t(state, dict, elements)
00035 , m_arrayDict(arrayDict)
00036 , m_elements(elements)
00037 {
00038 }
00039
00040 private:
00041 virtual IWORKXMLContextPtr_t element(const int name)
00042 {
00043 return Super_t::element(name);
00044 }
00045
00046 virtual void endOfElement()
00047 {
00048 Super_t::endOfElement();
00049 if (this->getId())
00050 m_arrayDict[get(this->getId())] = m_elements;
00051 }
00052
00053 private:
00054 ArrayDict_t &m_arrayDict;
00055 std::deque<Type> &m_elements;
00056 };
00057
00058 }
00059
00060 #endif // IWORKMUTABLEARRAYELEMENT_H_INCLUDED
00061
00062