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 
41 namespace 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 
225  public: GZ_DEPRECATED(13) void Root(const ElementPtr _root);
226 
229  public: std::string FilePath() const;
230 
233  public: void SetFilePath(const std::string &_path);
234 
237  public: void SetOriginalVersion(const std::string &_version);
238 
241  public: const std::string &OriginalVersion() const;
242 
245  public: static std::string Version();
246 
249  public: static void Version(const std::string &_version);
250 
254  public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
255 
260  public: static ElementPtr WrapInRoot(sdf::Errors &_errors,
261  const ElementPtr &_sdf);
262 
276  public: static const std::string &EmbeddedSpec(
277  const std::string &_filename, const bool _quiet);
278 
292  public: static const std::string &EmbeddedSpec(
293  sdf::Errors &_errors, const std::string &_filename);
294 
297  private: std::unique_ptr<SDFPrivate> dataPtr;
298 
301  private: static std::string version;
302  };
304  }
305 }
306 
307 #ifdef _WIN32
308 #pragma warning(pop)
309 #endif
310 
311 #endif
sdf::SDF_VERSION_NAMESPACE::GZ_DEPRECATED
class GZ_SDFORMAT_VISIBLE GZ_DEPRECATED(13) Inertia
A class for inertial information about a link.
Definition: Types.hh:147
sdf::SDF_VERSION_NAMESPACE::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::SDF_VERSION_NAMESPACE::findFile
GZ_SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::SDF
Base SDF class.
Definition: SDFImpl.hh:166
PrintConfig.hh
sdf::SDF_VERSION_NAMESPACE::PrintConfig
This class contains configuration options for printing elements.
Definition: PrintConfig.hh:32
sdf::SDF_VERSION_NAMESPACE::setFindCallback
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.
ParserConfig.hh
sdf::SDF_VERSION_NAMESPACE::addURIPath
GZ_SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
Types.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
Param.hh
sdf::SDF_VERSION_NAMESPACE::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:57
sdf::SDF_VERSION_NAMESPACE::SDF
class GZ_SDFORMAT_VISIBLE SDF
Definition: SDFImpl.hh:47
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
system_util.hh
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
Element.hh