IWORKPtrPropertyContext.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 IWORKPTRPROPERTYCONTEXT_H_INCLUDED
11#define IWORKPTRPROPERTYCONTEXT_H_INCLUDED
12
14#include "IWORKPropertyInfo.h"
15
16namespace libetonyek
17{
18
19template<typename Property, typename Context, int TokenId>
21{
22public:
24
25private:
26 IWORKXMLContextPtr_t element(int name) override;
27 void endOfElement() override;
28
29private:
31};
32
33template<typename Property, typename Context, int TokenId>
39
40template<typename Property, typename Context, int TokenId>
42{
43 m_default = false;
44 if (TokenId == name)
45 return std::make_shared<Context>(getState(), m_value);
46 return IWORKXMLContextPtr_t();
47}
48
49template<typename Property, typename Context, int TokenId>
51{
52 if (bool(m_value))
53 m_propMap.put<Property>(m_value);
54 else if (m_default)
55 m_propMap.clear<Property>();
56}
57
58}
59
60#endif // IWORKPTRPROPERTYCONTEXT_H_INCLUDED
61
62/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
boost::optional< IWORKGradient > & m_value
Definition IWORKFillElement.cpp:131
IWORKPropertyMap & m_propMap
Definition IWORKPropertyMapElement.cpp:756
Definition IWORKPropertyContextBase.h:21
Represents a (hierarchical) property map.
Definition IWORKPropertyMap.h:25
void put(const typename IWORKPropertyInfo< Property >::ValueType &value)
Insert a new value for key key.
Definition IWORKPropertyMap.h:134
void clear()
Clear property.
Definition IWORKPropertyMap.h:145
Definition IWORKPtrPropertyContext.h:21
IWORKPropertyInfo< Property >::ValueType m_value
Definition IWORKPtrPropertyContext.h:30
void endOfElement() override
Definition IWORKPtrPropertyContext.h:50
IWORKXMLContextPtr_t element(int name) override
Definition IWORKPtrPropertyContext.h:41
IWORKPtrPropertyContext(IWORKXMLParserState &state, IWORKPropertyMap &propMap)
Definition IWORKPtrPropertyContext.h:34
Definition IWORKXMLParserState.h:32
@ element
Definition IWORKToken.h:192
@ name
Definition IWORKToken.h:585
Definition IWORKBezierElement.cpp:21
std::shared_ptr< IWORKXMLContext > IWORKXMLContextPtr_t
Definition IWORKXMLContext.h:20
Definition IWORKPropertyInfo.h:22

Generated for libetonyek by doxygen 1.12.0