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
97 std::string findFile(const std::string &_filename,
98 bool _searchLocalPath,
99 bool _useCallback,
100 const ParserConfig &_config);
101
102
108 void addURIPath(const std::string &_uri, const std::string &_path);
109
115 void setFindCallback(std::function<std::string (const std::string &)> _cb);
116
119 {
120 public: SDF();
122 public: ~SDF();
123 public: void PrintDescription();
124 public: void PrintDoc();
125 public: void Write(const std::string &_filename);
126
129 public: void PrintValues(const PrintConfig &_config = PrintConfig());
130
134 public: std::string ToString(
135 const PrintConfig &_config = PrintConfig()) const;
136
138 public: void SetFromString(const std::string &_sdfData);
139
141 public: void Clear();
142
145 public: ElementPtr Root() const;
146
149 public: void SetRoot(const ElementPtr _root);
150
154 public: GZ_DEPRECATED(13) void Root(const ElementPtr _root);
155
158 public: std::string FilePath() const;
159
162 public: void SetFilePath(const std::string &_path);
163
166 public: void SetOriginalVersion(const std::string &_version);
167
170 public: const std::string &OriginalVersion() const;
171
174 public: static std::string Version();
175
178 public: static void Version(const std::string &_version);
179
183 public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
184
198 public: static const std::string &EmbeddedSpec(
199 const std::string &_filename, const bool _quiet);
200
203 private: std::unique_ptr<SDFPrivate> dataPtr;
204
207 private: static std::string version;
208 };
210 }
211}
212
213#ifdef _WIN32
214#pragma warning(pop)
215#endif
216
217#endif
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:100
This class contains configuration options for printing elements.
Definition: PrintConfig.hh:33
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:58
Base SDF class.
Definition: SDFImpl.hh:119
void Write(const std::string &_filename)
void PrintValues(const PrintConfig &_config=PrintConfig())
Output SDF's values to stdout.
void SetRoot(const ElementPtr _root)
Set the root pointer.
ElementPtr Root() const
Get a pointer to the root element.
void SetFromString(const std::string &_sdfData)
Set SDF values from a string.
void Clear()
Clear the data in this object.
GZ_DEPRECATED(13) void Root(const ElementPtr _root)
Set the root pointer.
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::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