cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmnXMLPath.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ankur Kapoor, Anton Deguet, Ali Uneri
7  Created on: 2004-04-30
8 
9  (C) Copyright 2004-2012 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 
28 #pragma once
29 
30 #ifndef _cmnXMLPath_h
31 #define _cmnXMLPath_h
32 
35 
36 #if CISST_HAS_XML
37 
38 // always include last
40 
41 // forward declaration of struct containing all data used by wrapper.
42 class cmnXMLPathData;
43 
105 class CISST_EXPORT cmnXMLPath: public cmnGenericObject
106 {
109 
110 protected:
111  cmnXMLPathData * Data;
112 
113 public:
115  cmnXMLPath();
116 
118  virtual ~cmnXMLPath();
119 
122  void SetInputSource(const char * filename);
123  void SetInputSource(const std::string & fileName);
125 
128  bool ValidateWithSchema(const char * filename);
129  bool ValidateWithSchema(const std::string & fileName);
131 
136  const std::string & GetLastErrors(void) const;
137 
140  bool SaveAs(const char * filename) const;
141  bool SaveAs(const std::string & fileName) const;
143 
145  void PrintValue(std::ostream & out, const char * context, const char * XPath);
146 
149  bool GetXMLValue(const char * context, const char * XPath, bool & value);
150  bool GetXMLValue(const char * context, const char * XPath, bool & value, const bool & valueIfMissing);
151  bool SetXMLValue(const char * context, const char * XPath, const bool & value);
152  bool Query(const char * query, bool & value);
154 
157  bool GetXMLValue(const char * context, const char * XPath, int & value);
158  bool GetXMLValue(const char * context, const char * XPath, int & value, const int & valueIfMissing);
159  bool SetXMLValue(const char * context, const char * XPath, const int & value);
160  bool Query(const char * query, int & value);
162 
165  bool GetXMLValue(const char * context, const char * XPath, double & value);
166  bool GetXMLValue(const char * context, const char * XPath, double & value, const double & valueIfMissing);
167  bool SetXMLValue(const char * context, const char * XPath, const double & value);
168  bool Query(const char * query, double & value);
170 
173  bool GetXMLValue(const char * context, const char * XPath, std::string & value);
174  bool GetXMLValue(const char * context, const char * XPath, std::string & value, const std::string & valueIfMissing);
175  bool SetXMLValue(const char * context, const char * XPath, const std::string & value);
176  bool Query(const char * query, std::string & value);
178 
181  template <class __elementType>
182  bool GetXMLValue(const std::string & context, const std::string & XPath, __elementType & value) {
183  return this->GetXMLValue(context.c_str(), XPath.c_str(), value);
184  }
185 
186  template <class __elementType>
187  bool GetXMLValue(const std::string & context, const std::string & XPath, __elementType & value, const __elementType & valueIfMissing) {
188  return this->GetXMLValue(context.c_str(), XPath.c_str(), value, valueIfMissing);
189  }
190 
191  template <class __elementType>
192  bool SetXMLValue(const std::string & context, const std::string & XPath, const __elementType & value)
193  {
194  return this->SetXMLValue(context.c_str(), XPath.c_str(), value);
195  }
196 
197  template <class __elementType>
198  bool Query(const std::string & query, __elementType & value) {
199  return this->Query(query.c_str(), value);
200  }
201 };
202 
203 
205 
206 #endif // CISST_HAS_XML
207 
208 #endif // _cmnXMLPath_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Base class for high level objects.
Definition: cmnGenericObject.h:51
Defines cmnGenericObject.
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Macros to export the symbols of cisstCommonXML (in a Dll).
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76