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 
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();
121  public: SDF(const SDF& other);
122  public: SDF& operator=(const SDF& other);
124  public: ~SDF();
125  public: void PrintDescription();
126  public: void PrintDoc();
127  public: void Write(const std::string &_filename);
128 
131  public: void PrintValues(const PrintConfig &_config = PrintConfig());
132 
136  public: std::string ToString(
137  const PrintConfig &_config = PrintConfig()) const;
138 
140  public: void SetFromString(const std::string &_sdfData);
141 
143  public: void Clear();
144 
147  public: ElementPtr Root() const;
148 
151  public: void Root(const ElementPtr _root);
152 
155  public: std::string FilePath() const;
156 
159  public: void SetFilePath(const std::string &_path);
160 
163  public: void SetOriginalVersion(const std::string &_version);
164 
167  public: const std::string &OriginalVersion() const;
168 
171  public: static std::string Version();
172 
175  public: static void Version(const std::string &_version);
176 
180  public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
181 
195  public: static const std::string &EmbeddedSpec(
196  const std::string &_filename, const bool _quiet);
197 
200  private: std::unique_ptr<SDFPrivate> dataPtr;
201 
204  private: static std::string version;
205  };
207  }
208 }
209 
210 #ifdef _WIN32
211 #pragma warning(pop)
212 #endif
213 
214 #endif
sdf::SDF_VERSION_NAMESPACE::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::SDF_VERSION_NAMESPACE::SDF
class IGNITION_SDFORMAT_VISIBLE SDF
Definition: SDFImpl.hh:47
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::SDF
Base SDF class.
Definition: SDFImpl.hh:118
PrintConfig.hh
sdf::SDF_VERSION_NAMESPACE::setFindCallback
IGNITION_SDFORMAT_VISIBLE void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
sdf::SDF_VERSION_NAMESPACE::PrintConfig
This class contains configuration options for printing elements.
Definition: PrintConfig.hh:31
ParserConfig.hh
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
sdf::SDF_VERSION_NAMESPACE::addURIPath
IGNITION_SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
Param.hh
sdf::SDF_VERSION_NAMESPACE::findFile
IGNITION_SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
sdf::SDF_VERSION_NAMESPACE::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:56
system_util.hh
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Element.hh