Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IWORKPTRPROPERTYCONTEXT_H_INCLUDED
00011 #define IWORKPTRPROPERTYCONTEXT_H_INCLUDED
00012
00013 #include "IWORKPropertyContextBase.h"
00014 #include "IWORKPropertyInfo.h"
00015
00016 namespace libetonyek
00017 {
00018
00019 template<typename Property, typename Context, int TokenId>
00020 class IWORKPtrPropertyContext : public IWORKPropertyContextBase
00021 {
00022 public:
00023 IWORKPtrPropertyContext(IWORKXMLParserState &state, IWORKPropertyMap &propMap);
00024
00025 private:
00026 virtual IWORKXMLContextPtr_t element(int name);
00027 virtual void endOfElement();
00028
00029 private:
00030 typename IWORKPropertyInfo<Property>::ValueType m_value;
00031 };
00032
00033 template<typename Property, typename Context, int TokenId>
00034 IWORKPtrPropertyContext<Property, Context, TokenId>::IWORKPtrPropertyContext(IWORKXMLParserState &state, IWORKPropertyMap &propMap)
00035 : IWORKPropertyContextBase(state, propMap)
00036 , m_value()
00037 {
00038 }
00039
00040 template<typename Property, typename Context, int TokenId>
00041 IWORKXMLContextPtr_t IWORKPtrPropertyContext<Property, Context, TokenId>::element(const int name)
00042 {
00043 m_default = false;
00044 if (TokenId == name)
00045 return makeContext<Context>(getState(), m_value);
00046 return IWORKXMLContextPtr_t();
00047 }
00048
00049 template<typename Property, typename Context, int TokenId>
00050 void IWORKPtrPropertyContext<Property, Context, TokenId>::endOfElement()
00051 {
00052 if (bool(m_value))
00053 m_propMap.put<Property>(m_value);
00054 else if (m_default)
00055 m_propMap.clear<Property>();
00056 }
00057
00058 }
00059
00060 #endif // IWORKPTRPROPERTYCONTEXT_H_INCLUDED
00061
00062