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/Types.hh"
28 #include "sdf/sdf_config.h"
29 #include "sdf/system_util.hh"
30 
31 #ifdef _WIN32
32 // Disable warning C4251 which is triggered by
33 // std::unique_ptr
34 #pragma warning(push)
35 #pragma warning(disable: 4251)
36 #endif
37 
40 namespace sdf
41 {
42  // Inline bracket to help doxygen filtering.
43  inline namespace SDF_VERSION_NAMESPACE {
44  //
45 
47  class SDFPrivate;
48 
51  typedef std::shared_ptr<SDF> SDFPtr;
52 
55 
78  std::string findFile(const std::string &_filename,
79  bool _searchLocalPath = true,
80  bool _useCallback = false);
81 
96  std::string findFile(const std::string &_filename,
97  bool _searchLocalPath,
98  bool _useCallback,
99  const ParserConfig &_config);
100 
101 
107  void addURIPath(const std::string &_uri, const std::string &_path);
108 
114  void setFindCallback(std::function<std::string (const std::string &)> _cb);
115 
118  {
119  public: SDF();
121  public: ~SDF();
122  public: void PrintDescription();
123  public: void PrintValues();
124  public: void PrintDoc();
125  public: void Write(const std::string &_filename);
126  public: std::string ToString() const;
127 
129  public: void SetFromString(const std::string &_sdfData);
130 
132  public: void Clear();
133 
136  public: ElementPtr Root() const;
137 
140  public: void Root(const ElementPtr _root);
141 
144  public: std::string FilePath() const;
145 
148  public: void SetFilePath(const std::string &_path);
149 
152  public: void SetOriginalVersion(const std::string &_version);
153 
156  public: const std::string &OriginalVersion() const;
157 
160  public: static std::string Version();
161 
164  public: static void Version(const std::string &_version);
165 
169  public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
170 
184  public: static const std::string &EmbeddedSpec(
185  const std::string &_filename, const bool _quiet);
186 
189  private: std::unique_ptr<SDFPrivate> dataPtr;
190 
193  private: static std::string version;
194  };
196  }
197 }
198 
199 #ifdef _WIN32
200 #pragma warning(pop)
201 #endif
202 
203 #endif
Base SDF class.
Definition: SDFImpl.hh:117
SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
SDFORMAT_VISIBLE void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can&#39;t find a file.
SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath, bool _useCallback, const ParserConfig &_config)
Find the absolute path of a file.
class SDFORMAT_VISIBLE SDF
Definition: SDFImpl.hh:46
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
namespace for Simulation Description Format parser
Definition: Actor.hh:33
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:51