Loading...
Searching...
No Matches
SDFImpl.hh
Go to the documentation of this file.
1/*
2 * Copyright 2012 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef SDFIMPL_HH_
18#define SDFIMPL_HH_
19
20#include <functional>
21#include <memory>
22#include <string>
23
24#include "sdf/Element.hh"
25#include "sdf/Param.hh"
26#include "sdf/ParserConfig.hh"
27#include "sdf/PrintConfig.hh"
28#include "sdf/Types.hh"
29#include "sdf/sdf_config.h"
30#include "sdf/system_util.hh"
31
32#ifdef _WIN32
33// Disable warning C4251 which is triggered by
34// std::unique_ptr
35#pragma warning(push)
36#pragma warning(disable: 4251)
37#endif
38
41namespace sdf
42{
43 // Inline bracket to help doxygen filtering.
44 inline namespace SDF_VERSION_NAMESPACE {
45 //
46
48 class SDFPrivate;
49
52 typedef std::shared_ptr<SDF> SDFPtr;
53
56
79 std::string findFile(const std::string &_filename,
80 bool _searchLocalPath = true,
81 bool _useCallback = false);
82
106 std::string findFile(sdf::Errors &_errors,
107 const std::string &_filename,
108 bool _searchLocalPath = true,
109 bool _useCallback = false);
110
125 std::string findFile(const std::string &_filename,
126 bool _searchLocalPath,
127 bool _useCallback,
128 const ParserConfig &_config);
129
145 std::string findFile(sdf::Errors &_errors,
146 const std::string &_filename,
147 bool _searchLocalPath,
148 bool _useCallback,
149 const ParserConfig &_config);
150
156 void addURIPath(const std::string &_uri, const std::string &_path);
157
163 void setFindCallback(std::function<std::string (const std::string &)> _cb);
164
167 {
168 public: SDF();
170 public: ~SDF();
171 public: void PrintDescription();
172 public: void PrintDescription(sdf::Errors &_errors);
173 public: void PrintDoc();
174 public: void Write(const std::string &_filename);
175 public: void Write(sdf::Errors &_errors, const std::string &_filename);
176
179 public: void PrintValues(const PrintConfig &_config = PrintConfig());
180
184 public: void PrintValues(sdf::Errors &_errors,
185 const PrintConfig &_config = PrintConfig());
186
190 public: std::string ToString(
191 const PrintConfig &_config = PrintConfig()) const;
192
197 public: std::string ToString(
198 sdf::Errors &_errors,
199 const PrintConfig &_config = PrintConfig()) const;
200
203 public: void SetFromString(const std::string &_sdfData);
204
208 public: void SetFromString(sdf::Errors &_Errors,
209 const std::string &_sdfData);
210
212 public: void Clear();
213
216 public: ElementPtr Root() const;
217
220 public: void SetRoot(const ElementPtr _root);
221
224 public: std::string FilePath() const;
225
228 public: void SetFilePath(const std::string &_path);
229
232 public: void SetOriginalVersion(const std::string &_version);
233
236 public: const std::string &OriginalVersion() const;
237
240 public: static std::string Version();
241
244 public: static void Version(const std::string &_version);
245
249 public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
250
255 public: static ElementPtr WrapInRoot(sdf::Errors &_errors,
256 const ElementPtr &_sdf);
257
271 public: static const std::string &EmbeddedSpec(
272 const std::string &_filename, const bool _quiet);
273
287 public: static const std::string &EmbeddedSpec(
288 sdf::Errors &_errors, const std::string &_filename);
289
292 private: std::unique_ptr<SDFPrivate> dataPtr;
293
296 private: static std::string version;
297 };
299 }
300}
301
302#ifdef _WIN32
303#pragma warning(pop)
304#endif
305
306#endif
This class contains configuration options for the libsdformat parser.
Definition ParserConfig.hh:106
This class contains configuration options for printing elements.
Definition PrintConfig.hh:33
Base SDF class.
Definition SDFImpl.hh:167
void Write(const std::string &_filename)
static ElementPtr WrapInRoot(sdf::Errors &_errors, const ElementPtr &_sdf)
wraps the SDF element into a root element with the version info.
std::string ToString(sdf::Errors &_errors, const PrintConfig &_config=PrintConfig()) const
Convert the SDF values to a string representation.
void SetOriginalVersion(const std::string &_version)
Set the spec version that this was originally parsed from.
void SetFromString(sdf::Errors &_Errors, const std::string &_sdfData)
Set SDF values from a string.
void PrintValues(sdf::Errors &_errors, const PrintConfig &_config=PrintConfig())
Output SDF's values to stdout.
static std::string Version()
Get the version.
static const std::string & EmbeddedSpec(const std::string &_filename, const bool _quiet)
Get a string representation of an SDF specification file.
void PrintValues(const PrintConfig &_config=PrintConfig())
Output SDF's values to stdout.
void SetRoot(const ElementPtr _root)
Set the root pointer.
static const std::string & EmbeddedSpec(sdf::Errors &_errors, const std::string &_filename)
Get a string representation of an SDF specification file.
static ElementPtr WrapInRoot(const ElementPtr &_sdf)
wraps the SDF element into a root element with the version info.
void Write(sdf::Errors &_errors, const std::string &_filename)
ElementPtr Root() const
Get a pointer to the root element.
void SetFilePath(const std::string &_path)
Set the path on disk.
const std::string & OriginalVersion() const
Get the spec version that this was originally parsed from.
void PrintDescription(sdf::Errors &_errors)
std::string FilePath() const
Get the path to the SDF document on disk.
void SetFromString(const std::string &_sdfData)
Set SDF values from a string.
void Clear()
Clear the data in this object.
static void Version(const std::string &_version)
Set the version string.
std::string ToString(const PrintConfig &_config=PrintConfig()) const
Convert the SDF values to a string representation.
GZ_SDFORMAT_VISIBLE void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
GZ_SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
GZ_SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
std::shared_ptr< SDF > SDFPtr
Definition SDFImpl.hh:52
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:81
std::shared_ptr< Element > ElementPtr
Definition Element.hh:55
namespace for Simulation Description Format parser
Definition Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:25