parser.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 SDF_PARSER_HH_
18 #define SDF_PARSER_HH_
19 
20 #include <string>
21 
22 #include "sdf/SDFImpl.hh"
23 #include "sdf/sdf_config.h"
24 #include "sdf/system_util.hh"
25 
36 namespace sdf
37 {
38  // Inline bracket to help doxygen filtering.
39  inline namespace SDF_VERSION_NAMESPACE {
40  //
41  // TODO(marcoag): Deprecate function overloads that do not use sdf::Errors,
42  // see: https://github.com/gazebosim/sdformat/issues/1186
43  class Root;
44 
49  bool init(SDFPtr _sdf);
50 
56  bool init(SDFPtr _sdf, const ParserConfig &_config);
57 
63  bool initFile(const std::string &_filename, SDFPtr _sdf);
64 
71  bool initFile(
72  const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf);
73 
79  bool initFile(const std::string &_filename, ElementPtr _sdf);
80 
87  bool initFile(const std::string &_filename, const ParserConfig &_config,
88  ElementPtr _sdf);
89 
95  bool initString(const std::string &_xmlString, SDFPtr _sdf);
96 
104  const std::string &_xmlString, const ParserConfig &_config, SDFPtr _sdf);
105 
114  sdf::SDFPtr readFile(const std::string &_filename);
115 
125  sdf::SDFPtr readFile(const std::string &_filename, Errors &_errors);
126 
137  sdf::SDFPtr readFile(const std::string &_filename,
138  const ParserConfig &_config, Errors &_errors);
139 
150  bool readFile(const std::string &_filename, SDFPtr _sdf, Errors &_errors);
151 
163  bool readFile(const std::string &_filename, const ParserConfig &_config,
164  SDFPtr _sdf, Errors &_errors);
165 
179  const std::string &_filename, SDFPtr _sdf, Errors &_errors);
180 
194  bool readFileWithoutConversion(const std::string &_filename,
195  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
196 
206  bool readFile(const std::string &_filename, SDFPtr _sdf);
207 
218  bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
219 
231  bool readString(const std::string &_xmlString, const ParserConfig &_config,
232  SDFPtr _sdf, Errors &_errors);
233 
243  bool readString(const std::string &_xmlString, SDFPtr _sdf);
244 
255  bool readString(const std::string &_xmlString, ElementPtr _sdf,
256  Errors &_errors);
257 
269  bool readString(const std::string &_xmlString, const ParserConfig &_config,
270  ElementPtr _sdf, Errors &_errors);
271 
285  const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
286 
298  bool readStringWithoutConversion(const std::string &_xmlString,
299  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
300 
310  bool readString(const std::string &_xmlString, ElementPtr _sdf);
311 
318  std::string getModelFilePath(const std::string &_modelDirPath);
319 
326  bool convertFile(const std::string &_filename, const std::string &_version,
327  SDFPtr _sdf);
328 
336  bool convertFile(const std::string &_filename, const std::string &_version,
337  const ParserConfig &_config, SDFPtr _sdf);
338 
347  SDFPtr _sdf, const std::string &_filename, const std::string &_version,
348  const ParserConfig &_config = ParserConfig::GlobalConfig());
349 
356  bool convertString(const std::string &_sdfString,
357  const std::string &_version, SDFPtr _sdf);
358 
366  bool convertString(const std::string &_sdfString, const std::string &_version,
367  const ParserConfig &_config, SDFPtr _sdf);
368 
377  SDFPtr _sdf, const std::string &_sdfString, const std::string &_version,
378  const ParserConfig &_config = ParserConfig::GlobalConfig());
379 
388  bool checkCanonicalLinkNames(const sdf::Root *_root);
389 
400 
411 
421 
431  bool checkJointParentChildLinkNames(const sdf::Root *_root);
432 
441  void checkJointParentChildNames(const sdf::Root *_root, Errors &_errors);
442 
450  void checkJointAxisExpressedInValues(const sdf::Root *_root, Errors &_errors);
451 
461  bool checkPoseRelativeToGraph(const sdf::Root *_root);
462 
471 
480 
490 
498 
504  std::string computeMergedModelProxyFrameName(const std::string &_modelName);
505  }
506 }
507 #endif
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:85
static ParserConfig & GlobalConfig()
Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all pars...
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:58
GZ_SDFORMAT_VISIBLE bool init(SDFPtr _sdf)
Initialize the SDF interface from the embedded root spec file.
GZ_SDFORMAT_VISIBLE bool convertString(const std::string &_sdfString, const std::string &_version, SDFPtr _sdf)
Convert an SDF string to a specific SDF version.
GZ_SDFORMAT_VISIBLE bool initString(const std::string &_xmlString, SDFPtr _sdf)
Initialize the SDF interface using a string.
GZ_SDFORMAT_VISIBLE void checkJointAxisExpressedInValues(const sdf::Root *_root, Errors &_errors)
Check that all joint axes in contained joints specify xyz expressed-in names that match the names of ...
GZ_SDFORMAT_VISIBLE bool recursiveSiblingUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the any type have unique names.
class GZ_SDFORMAT_VISIBLE GZ_DEPRECATED(13) Inertia
A class for inertial information about a link.
Definition: Types.hh:147
GZ_SDFORMAT_VISIBLE bool checkFrameAttachedToNames(const sdf::Root *_root)
Check that for each frame, the attached_to attribute value does not match its own frame name but does...
GZ_SDFORMAT_VISIBLE bool readFileWithoutConversion(const std::string &_filename, SDFPtr _sdf, Errors &_errors)
Populate the SDF values from a file without converting to the latest SDF version.
GZ_SDFORMAT_VISIBLE std::string computeMergedModelProxyFrameName(const std::string &_modelName)
Function to compute a merged model's proxy frame name.
GZ_SDFORMAT_VISIBLE bool recursiveSameTypeUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the same type have unique names.
GZ_SDFORMAT_VISIBLE bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors)
Populate the SDF values from a string.
GZ_SDFORMAT_VISIBLE std::string getModelFilePath(const std::string &_modelDirPath)
Get the file path to the model file.
GZ_SDFORMAT_VISIBLE bool checkCanonicalLinkNames(const sdf::Root *_root)
Check that for each model, the canonical_link attribute value matches the name of a link in the model...
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
GZ_SDFORMAT_VISIBLE bool convertFile(const std::string &_filename, const std::string &_version, SDFPtr _sdf)
Convert an SDF file to a specific SDF version.
GZ_SDFORMAT_VISIBLE bool checkPoseRelativeToGraph(const sdf::Root *_root)
For the world and each model, check that the attached_to graphs build without errors and have no cycl...
GZ_SDFORMAT_VISIBLE sdf::SDFPtr readFile(const std::string &_filename)
Populate the SDF values from a file.
GZ_SDFORMAT_VISIBLE bool readStringWithoutConversion(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors)
Populate the SDF values from a string without converting to the latest SDF version.
GZ_SDFORMAT_VISIBLE bool recursiveSiblingNoDoubleColonInNames(sdf::ElementPtr _elem)
Check that all sibling elements do not contain the delimiter double colons '::' in element names,...
GZ_SDFORMAT_VISIBLE bool checkFrameAttachedToGraph(const sdf::Root *_root)
For the world and each model, check that the attached_to graphs build without errors and have no cycl...
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
GZ_SDFORMAT_VISIBLE bool checkJointParentChildNames(const sdf::Root *_root)
Check that all joints in contained models specify parent and child link names that match the names of...
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
GZ_SDFORMAT_VISIBLE bool initFile(const std::string &_filename, SDFPtr _sdf)
Initialize the SDF interface using a file.
GZ_SDFORMAT_VISIBLE bool shouldValidateElement(sdf::ElementPtr _elem)
Check whether the element should be validated.
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