libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNInt.cpp
Go to the documentation of this file.
1 /* Copyright 2009-2016 INSA Lyon, CoReNum, ENS-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNInt.cpp
19  * \author Yann LEYDIER
20  */
21 
22 #include <CRNData/CRNInt.h>
23 #include <CRNException.h>
24 #include <CRNData/CRNDataFactory.h>
25 #include <CRNi18n.h>
26 
27 using namespace crn;
28 
29 /*****************************************************************************/
38 {
39  if (el.GetValue() != "Int")
40  {
41  throw ExceptionInvalidArgument(StringUTF8("void Int::Deserialize(xml::Element &el): ") +
42  _("Wrong XML element."));
43  }
44  val = el.GetAttribute<int>("value");
45 }
46 
47 /*****************************************************************************/
55 {
56  xml::Element el(parent.PushBackElement("Int"));
57  el.SetAttribute("value", val);
58  return el;
59 }
60 
63  Cloner::Register<Int>();
64  Ruler::Register<Int>();
66 
void Deserialize(xml::Element &el)
Reads from an XML element.
Definition: CRNInt.cpp:37
XML element.
Definition: CRNXml.h:135
#define _(String)
Definition: CRNi18n.h:51
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Definition: CRNObject.h:198
xml::Element Serialize(xml::Element &parent) const
Dumps to an XML element.
Definition: CRNInt.cpp:54
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
virtual StringUTF8 GetValue() const
Gets the content of the node.
Definition: CRNXml.cpp:171
void SetAttribute(const StringUTF8 &name, const StringUTF8 &value)
Sets the value of an attribute.
Definition: CRNXml.cpp:595
T GetAttribute(const StringUTF8 &name, bool silent=true) const
Gets an attribute.
Definition: CRNXml.h:219
Interface class for the metric real number class.
Definition: CRNInt.h:40
A character string class.
Definition: CRNStringUTF8.h:49
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Definition: CRNXml.cpp:355
Invalid argument error (e.g.: nullptr pointer)
Definition: CRNException.h:107
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Definition: CRNObject.h:185