cisst-saw
Loading...
Searching...
No Matches
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 Author(s): Ankur Kapoor, Anton Deguet, Ali Uneri
6 Created on: 2004-04-30
7
8 (C) Copyright 2004-2012 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17
18*/
19
20
25
26#pragma once
27
28#ifndef _cmnXMLPath_h
29#define _cmnXMLPath_h
30
33
34#if CISST_HAS_XML
35
36// always include last
38
39// forward declaration of struct containing all data used by wrapper.
40class cmnXMLPathData;
41
103class CISST_EXPORT cmnXMLPath: public cmnGenericObject
104{
107
108protected:
109 cmnXMLPathData * Data;
110
111public:
113 cmnXMLPath();
114
116 virtual ~cmnXMLPath();
117
120 void SetInputSource(const char * filename);
121 void SetInputSource(const std::string & fileName);
123
126 bool ValidateWithSchema(const char * filename);
127 bool ValidateWithSchema(const std::string & fileName);
129
134 const std::string & GetLastErrors(void) const;
135
138 bool SaveAs(const char * filename) const;
139 bool SaveAs(const std::string & fileName) const;
141
143 void PrintValue(std::ostream & out, const char * context, const char * XPath);
144
146 bool Exists(const char * context);
147
150 bool GetXMLValue(const char * context, const char * XPath, bool & value);
151 bool GetXMLValue(const char * context, const char * XPath, bool & value, const bool & valueIfMissing);
152 bool SetXMLValue(const char * context, const char * XPath, const bool & value);
153 bool Query(const char * query, bool & value);
155
158 bool GetXMLValue(const char * context, const char * XPath, int & value);
159 bool GetXMLValue(const char * context, const char * XPath, int & value, const int & valueIfMissing);
160 bool SetXMLValue(const char * context, const char * XPath, const int & value);
161 bool Query(const char * query, int & value);
163
166 bool GetXMLValue(const char * context, const char * XPath, double & value);
167 bool GetXMLValue(const char * context, const char * XPath, double & value, const double & valueIfMissing);
168 bool SetXMLValue(const char * context, const char * XPath, const double & value);
169 bool Query(const char * query, double & value);
171
174 bool GetXMLValue(const char * context, const char * XPath, std::string & value);
175 bool GetXMLValue(const char * context, const char * XPath, std::string & value, const std::string & valueIfMissing);
176 bool SetXMLValue(const char * context, const char * XPath, const std::string & value);
177 bool Query(const char * query, std::string & value);
179
182 bool Exists(const std::string & context) {
183 return this->Exists(context.c_str());
184 }
185
186 template <class __elementType>
187 bool GetXMLValue(const std::string & context, const std::string & XPath, __elementType & value) {
188 return this->GetXMLValue(context.c_str(), XPath.c_str(), value);
189 }
190
191 template <class __elementType>
192 bool GetXMLValue(const std::string & context, const std::string & XPath, __elementType & value, const __elementType & valueIfMissing) {
193 return this->GetXMLValue(context.c_str(), XPath.c_str(), value, valueIfMissing);
194 }
195
196 template <class __elementType>
197 bool SetXMLValue(const std::string & context, const std::string & XPath, const __elementType & value)
198 {
199 return this->SetXMLValue(context.c_str(), XPath.c_str(), value);
200 }
201
202 template <class __elementType>
203 bool Query(const std::string & query, __elementType & value) {
204 return this->Query(query.c_str(), value);
205 }
206};
207
208
210
211#endif // CISST_HAS_XML
212
213#endif // _cmnXMLPath_h
Base class for high level objects.
Definition cmnGenericObject.h:53
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_NO_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:325
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition cmnClassRegisterMacros.h:113
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Macros to export the symbols of cisstCommonXML (in a Dll).
Defines cmnGenericObject.
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76