FFSM++  1.1.0
French Forest Sector Model ++
InputNode.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU 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, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #ifndef INPUTNODE_H
23 #define INPUTNODE_H
24 
25 #include <iostream>
26 #include <cstdlib>
27 
28 #include <string>
29 #include <sstream>
30 #include <stdexcept>
31 #include <list>
32 #include <vector>
33 
34 #include <QDomElement>
35 
36 //regmas headers...
37 #include "BaseClass.h"
38 
39 using namespace std;
40 
41 //class QDomElement;
42 
43 ///Wrapper around the underlying library for reading DOM elements (nodes).
44 
45 /**
46 A small wrapper class using an underlying library (currently QtXml) to read DOM nodes.
47 <br>This class works with the individual nodes (DOM Elements), while the companion class InputDocument wrapper the whole document (DOM Document).
48 <br>Note: In the DOM terminology "Elements" are a subset of the more general "nodes" (that include comments and other typologies..)
49 @author Antonello Lobianco
50 */
51 class InputNode: public BaseClass{
52 
53 public:
54  InputNode();
55  InputNode(QDomElement domElement_h){domElement=domElement_h;}; //<Constructor
56  ~InputNode();
57  bool setWorkingFile (std::string filename_h); ///< Load the file on memory. Return false if no success.
58  int getIntContent(); ///< Get the content between its tagName as integer
59  double getDoubleContent(); ///< Get the content between its tagName as double
60  string getStringContent(); ///< Get the content between its tagName as std::string
61  bool getBoolContent(); ///< Get the content between its tagName as bool
62  int getIntAttributeByName(string attributeName_h); ///< Get an attribute by name as integer
63  double getDoubleAttributeByName(string attributeName_h); ///< Get an attribute by name as double
64  string getStringAttributeByName(string attributeName_h); ///< Get an attribute by name as string
65  bool hasAttributeByName(string attributeName_h); ///< Check if an attribute with a certain name exist
66  InputNode getNodeByName (string nodeName_h, int debugLevel=MSG_CRITICAL_ERROR, bool childFlag=false); ///< return 0-or-1 nodes by name.
67  vector <InputNode> getNodesByName (string nodeName_h, int debugLevel=MSG_WARNING, bool childFlag=false); ///< return 0-to-n nodes by name
68  /// Retrieve a child node with gived name and optionally with gived attribute or gived pair attribute/value. It raises an error if more than one.
69  //InputNode getNode(string nodeName_h, string attributeName_h="", string attributeValue_h="", int debugLevel=MSG_WARNING);
70  /// Retrieve all child nodes with gived name and optionally with gived attribute or gived pair attribute/value. It raises an error if more than one.
71  //vector <InputNode> getNodes(string nodeName_h, string attributeName_h="", string attributeValue_h="", int debugLevel=MSG_WARNING);
72 
73 
74  vector <InputNode> getChildNodes(); ///< Filtered to return only child <b>Elements</b>
75  bool hasChildNode(string name_h); ///< True if it has specified child node
76  int getChildNodesCount(); ///< Only <b>Elements</b>
77  string getNodeName();
78 
79 private:
80  QDomElement domElement; ///< The underlying library-depending DOM rappresentation of the element
81 
82 };
83 
84 #endif
Wrapper around the underlying library for reading DOM elements (nodes).
Definition: InputNode.h:51
STL namespace.
QDomElement domElement
The underlying library-depending DOM rappresentation of the element.
Definition: InputNode.h:80
Print an error message and stop the model.
Definition: BaseClass.h:62
Print a WARNING message.
Definition: BaseClass.h:60
Base class for the regmas application.
Definition: BaseClass.h:239
InputNode(QDomElement domElement_h)
Definition: InputNode.h:55
This file is the header of BaseClass and it is included by ALL compiled code.