IWORKPropertyContext.h
Go to the documentation of this file.
1 /* -*- Mode: Context++; 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 IWORKPROPERTYCONTEXT_H_INCLUDED
11 #define IWORKPROPERTYCONTEXT_H_INCLUDED
12 
13 #include <boost/optional.hpp>
14 
16 #include "IWORKPropertyInfo.h"
17 
18 namespace libetonyek
19 {
20 
21 template<typename Property, typename Context, int TokenId>
23 {
24 public:
26 
27 private:
28  IWORKXMLContextPtr_t element(int name) override;
29  void endOfElement() override;
30 
31 private:
32  boost::optional<typename IWORKPropertyInfo<Property>::ValueType> m_value;
33 };
34 
35 template<typename Property, typename Context, int TokenId>
37  : IWORKPropertyContextBase(state, propMap)
38  , m_value()
39 {
40 }
41 
42 template<typename Property, typename Context, int TokenId>
44 {
45  m_default = false;
46  if (TokenId == name)
47  return makeContext<Context>(getState(), m_value);
48  return IWORKXMLContextPtr_t();
49 }
50 
51 template<typename Property, typename Context, int TokenId>
53 {
54  if (bool(m_value))
55  m_propMap.put<Property>(get(m_value));
56  else if (m_default)
57  m_propMap.clear<Property>();
58 }
59 
60 }
61 
62 #endif // IWORKPROPERTYCONTEXT_H_INCLUDED
63 
64 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition: IWORKBezierElement.cpp:18
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition: IWORKXMLContext.h:18
Represents a (hierarchical) property map.
Definition: IWORKPropertyMap.h:24
IWORKXMLContextPtr_t element(int name) override
Definition: IWORKPropertyContext.h:43
IWORKPropertyMap & m_propMap
Definition: IWORKPropertyMapElement.cpp:763
boost::optional< typename IWORKPropertyInfo< Property >::ValueType > m_value
Definition: IWORKPropertyContext.h:32
void endOfElement() override
Definition: IWORKPropertyContext.h:52
optional< string > & m_value
Definition: IWORKMetadataElement.cpp:37
Definition: IWORKPropertyContextBase.h:20
const char * name
Definition: IWORKToken.cpp:43
Definition: IWORKXMLParserState.h:30
IWORKPropertyContext(IWORKXMLParserState &state, IWORKPropertyMap &propMap)
Definition: IWORKPropertyContext.h:36
Definition: IWORKToken.h:111
Definition: IWORKPropertyContext.h:22

Generated for libetonyek by doxygen 1.8.13