IWORKNumberElement.h Source File documentation

IWORKNumberElement.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 IWORKNUMBERELEMENT_H_INCLUDED
11#define IWORKNUMBERELEMENT_H_INCLUDED
12
13#include "IWORKNumberConverter.h"
14#include "IWORKToken.h"
15#include "IWORKXMLContextBase.h"
16
17namespace libetonyek
18{
19
20template<typename T>
21 class IWORKNumberElement : public IWORKXMLEmptyContextBase
22{
23public:
24 IWORKNumberElement(IWORKXMLParserState &state, boost::optional<T> &value);
25
26private:
27 void attribute(int name, const char *value) override;
28
29private:
30 boost::optional<T> &m_value;
31};
32
33template<typename T>
34IWORKNumberElement<T>::IWORKNumberElement(IWORKXMLParserState &state, boost::optional<T> &value)
35 : IWORKXMLEmptyContextBase(state)
36 , m_value(value)
37{
38}
39
40template<typename T>
41 void IWORKNumberElement<T>::attribute(const int name, const char *const value)
42{
43 switch (name)
44 {
45 case IWORKToken::NS_URI_SFA | IWORKToken::number :
46 m_value = IWORKNumberConverter<T>::convert(value);
47 break;
48 case IWORKToken::NS_URI_SFA | IWORKToken::sfclass : // with value number
49 case IWORKToken::NS_URI_SFA | IWORKToken::type :
50 break;
51 default:
52 ETONYEK_DEBUG_MSG(("IWORKNumberElement<...>::attribute: found unexpected attribute\n"));
53 break;
54 }
55}
56
57}
58
59#endif // IWORKNUMBERELEMENT_H_INCLUDED
60
61/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
m_value
boost::optional< IWORKGradient > & m_value
Definition IWORKFillElement.cpp:131
IWORKNumberConverter.h
IWORKToken.h
IWORKXMLContextBase.h
libetonyek::IWORKNumberElement
Definition IWORKNumberElement.h:22
libetonyek::IWORKNumberElement::attribute
void attribute(int name, const char *value) override
Definition IWORKNumberElement.h:41
libetonyek::IWORKNumberElement::IWORKNumberElement
IWORKNumberElement(IWORKXMLParserState &state, boost::optional< T > &value)
Definition IWORKNumberElement.h:34
libetonyek::IWORKNumberElement::m_value
boost::optional< T > & m_value
Definition IWORKNumberElement.h:30
libetonyek::IWORKXMLContextBase
Definition IWORKXMLContextBase.h:28
libetonyek::IWORKXMLParserState
Definition IWORKXMLParserState.h:32
ETONYEK_DEBUG_MSG
#define ETONYEK_DEBUG_MSG(M)
Definition libetonyek_utils.h:54
libetonyek::IWORKToken::type
@ type
Definition IWORKToken.h:493
libetonyek::IWORKToken::number
@ number
Definition IWORKToken.h:336
libetonyek::IWORKToken::sfclass
@ sfclass
Definition IWORKToken.h:610
libetonyek::IWORKToken::NS_URI_SFA
@ NS_URI_SFA
Definition IWORKToken.h:697
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::IWORKNumberConverter::convert
static boost::optional< T > convert(const char *value)
Definition IWORKNumberConverter.cpp:20