00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* 00003 * This file is part of the libetonyek project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 */ 00009 00010 #ifndef IWORKNUMBERELEMENT_H_INCLUDED 00011 #define IWORKNUMBERELEMENT_H_INCLUDED 00012 00013 #include "IWORKNumberConverter.h" 00014 #include "IWORKToken.h" 00015 #include "IWORKXMLContextBase.h" 00016 00017 namespace libetonyek 00018 { 00019 00020 template<typename T> 00021 class IWORKNumberElement : public IWORKXMLEmptyContextBase 00022 { 00023 public: 00024 IWORKNumberElement(IWORKXMLParserState &state, boost::optional<T> &value); 00025 00026 private: 00027 virtual void attribute(int name, const char *value); 00028 00029 private: 00030 boost::optional<T> &m_value; 00031 }; 00032 00033 template<typename T> 00034 IWORKNumberElement<T>::IWORKNumberElement(IWORKXMLParserState &state, boost::optional<T> &value) 00035 : IWORKXMLEmptyContextBase(state) 00036 , m_value(value) 00037 { 00038 } 00039 00040 template<typename T> 00041 void IWORKNumberElement<T>::attribute(const int name, const char *const value) 00042 { 00043 switch (name) 00044 { 00045 case IWORKToken::NS_URI_SFA | IWORKToken::number : 00046 m_value = IWORKNumberConverter<T>::convert(value); 00047 break; 00048 } 00049 } 00050 00051 } 00052 00053 #endif // IWORKNUMBERELEMENT_H_INCLUDED 00054 00055 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */