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 
47  class SDFORMAT_VISIBLE SDF;
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 Root(const ElementPtr _root);
150 
153  public: std::string FilePath() const;
154 
157  public: void SetFilePath(const std::string &_path);
158 
161  public: void SetOriginalVersion(const std::string &_version);
162 
165  public: const std::string &OriginalVersion() const;
166 
169  public: static std::string Version();
170 
173  public: static void Version(const std::string &_version);
174 
178  public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
179 
193  public: static const std::string &EmbeddedSpec(
194  const std::string &_filename, const bool _quiet);
195 
198  private: std::unique_ptr<SDFPrivate> dataPtr;
199 
202  private: static std::string version;
203  };
205  }
206 }
207 
208 #ifdef _WIN32
209 #pragma warning(pop)
210 #endif
211 
212 #endif
sdf::v12::setFindCallback
void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
sdf::v12::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::v12::addURIPath
void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
PrintConfig.hh
ParserConfig.hh
Types.hh
sdf::v12::SDF
Base SDF class.
Definition: SDFImpl.hh:118
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:41
sdf::v12::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::v12::PrintConfig
This class contains configuration options for printing elements.
Definition: PrintConfig.hh:31
Param.hh
sdf::v12::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
sdf::v12::findFile
std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
system_util.hh
sdf::v12::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Element.hh