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 
64  bool init(sdf::Errors &_errors, SDFPtr _sdf, const ParserConfig &_config);
65 
71  bool initFile(const std::string &_filename, SDFPtr _sdf);
72 
79  bool initFile(
80  const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf);
81 
89  bool initFile(
90  const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf,
91  sdf::Errors &_errors);
92 
98  bool initFile(const std::string &_filename, ElementPtr _sdf);
99 
106  bool initFile(const std::string &_filename, const ParserConfig &_config,
107  ElementPtr _sdf);
108 
116  bool initFile(const std::string &_filename, const ParserConfig &_config,
117  ElementPtr _sdf, sdf::Errors &_errors);
118 
124  bool initString(const std::string &_xmlString, SDFPtr _sdf);
125 
132  bool initString(
133  const std::string &_xmlString, const ParserConfig &_config, SDFPtr _sdf);
134 
142  bool initString(const std::string &_xmlString, const ParserConfig &_config,
143  SDFPtr _sdf, sdf::Errors &_errors);
144 
153  sdf::SDFPtr readFile(const std::string &_filename);
154 
164  sdf::SDFPtr readFile(const std::string &_filename, Errors &_errors);
165 
176  sdf::SDFPtr readFile(const std::string &_filename,
177  const ParserConfig &_config, Errors &_errors);
178 
189  bool readFile(const std::string &_filename, SDFPtr _sdf, Errors &_errors);
190 
202  bool readFile(const std::string &_filename, const ParserConfig &_config,
203  SDFPtr _sdf, Errors &_errors);
204 
218  const std::string &_filename, SDFPtr _sdf, Errors &_errors);
219 
233  bool readFileWithoutConversion(const std::string &_filename,
234  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
235 
245  bool readFile(const std::string &_filename, SDFPtr _sdf);
246 
257  bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
258 
270  bool readString(const std::string &_xmlString, const ParserConfig &_config,
271  SDFPtr _sdf, Errors &_errors);
272 
282  bool readString(const std::string &_xmlString, SDFPtr _sdf);
283 
294  bool readString(const std::string &_xmlString, ElementPtr _sdf,
295  Errors &_errors);
296 
308  bool readString(const std::string &_xmlString, const ParserConfig &_config,
309  ElementPtr _sdf, Errors &_errors);
310 
324  const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
325 
337  bool readStringWithoutConversion(const std::string &_xmlString,
338  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
339 
349  bool readString(const std::string &_xmlString, ElementPtr _sdf);
350 
357  std::string getModelFilePath(const std::string &_modelDirPath);
358 
366  std::string getModelFilePath(sdf::Errors &_errors,
367  const std::string &_modelDirPath);
368 
375  bool convertFile(const std::string &_filename, const std::string &_version,
376  SDFPtr _sdf);
377 
385  bool convertFile(const std::string &_filename, const std::string &_version,
386  const ParserConfig &_config, SDFPtr _sdf);
387 
396  SDFPtr _sdf, const std::string &_filename, const std::string &_version,
397  const ParserConfig &_config = ParserConfig::GlobalConfig());
398 
405  bool convertString(const std::string &_sdfString,
406  const std::string &_version, SDFPtr _sdf);
407 
415  bool convertString(const std::string &_sdfString, const std::string &_version,
416  const ParserConfig &_config, SDFPtr _sdf);
417 
426  SDFPtr _sdf, const std::string &_sdfString, const std::string &_version,
427  const ParserConfig &_config = ParserConfig::GlobalConfig());
428 
437  bool checkCanonicalLinkNames(const sdf::Root *_root);
438 
448  bool checkCanonicalLinkNames(sdf::Errors &_errors, const sdf::Root *_root);
449 
459  bool checkFrameAttachedToGraph(const sdf::Root *_root);
460 
471  bool checkFrameAttachedToGraph(sdf::Errors &_errors, const sdf::Root *_root);
472 
482  bool checkFrameAttachedToNames(const sdf::Root *_root);
483 
494  bool checkFrameAttachedToNames(sdf::Errors &_errors, const sdf::Root *_root);
495 
504  bool checkJointParentChildNames(const sdf::Root *_root);
505 
515  bool checkJointParentChildLinkNames(const sdf::Root *_root);
516 
525  void checkJointParentChildNames(const sdf::Root *_root, Errors &_errors);
526 
534  void checkJointAxisExpressedInValues(const sdf::Root *_root, Errors &_errors);
535 
545  bool checkPoseRelativeToGraph(const sdf::Root *_root);
546 
557  bool checkPoseRelativeToGraph(sdf::Errors &_errors, const sdf::Root *_root);
558 
567 
576  bool recursiveSameTypeUniqueNames(sdf::Errors &_errors,
577  sdf::ElementPtr _elem);
578 
587 
596  bool recursiveSiblingUniqueNames(sdf::Errors &_errors, sdf::ElementPtr _elem);
597 
607 
618  sdf::ElementPtr _elem);
619 
626  bool shouldValidateElement(sdf::ElementPtr _elem);
627 
633  std::string computeMergedModelProxyFrameName(const std::string &_modelName);
634  }
635 }
636 #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::convertFile
GZ_SDFORMAT_VISIBLE bool convertFile(const std::string &_filename, const std::string &_version, SDFPtr _sdf)
Convert an SDF file to a specific SDF version.
sdf::SDF_VERSION_NAMESPACE::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::SDF_VERSION_NAMESPACE::checkFrameAttachedToNames
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...
sdf::SDF_VERSION_NAMESPACE::init
GZ_SDFORMAT_VISIBLE bool init(SDFPtr _sdf)
Initialize the SDF interface from the embedded root spec file.
sdf::SDF_VERSION_NAMESPACE::initString
GZ_SDFORMAT_VISIBLE bool initString(const std::string &_xmlString, SDFPtr _sdf)
Initialize the SDF interface using a string.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::getModelFilePath
GZ_SDFORMAT_VISIBLE std::string getModelFilePath(const std::string &_modelDirPath)
Get the file path to the model file.
sdf::SDF_VERSION_NAMESPACE::checkJointAxisExpressedInValues
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 ...
sdf::SDF_VERSION_NAMESPACE::checkFrameAttachedToGraph
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...
sdf_config.h
sdf::SDF_VERSION_NAMESPACE::recursiveSameTypeUniqueNames
GZ_SDFORMAT_VISIBLE bool recursiveSameTypeUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the same type have unique names.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::convertString
GZ_SDFORMAT_VISIBLE bool convertString(const std::string &_sdfString, const std::string &_version, SDFPtr _sdf)
Convert an SDF string to a specific SDF version.
sdf::SDF_VERSION_NAMESPACE::computeMergedModelProxyFrameName
GZ_SDFORMAT_VISIBLE std::string computeMergedModelProxyFrameName(const std::string &_modelName)
Function to compute a merged model's proxy frame name.
sdf::SDF_VERSION_NAMESPACE::readStringWithoutConversion
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.
sdf::SDF_VERSION_NAMESPACE::recursiveSiblingUniqueNames
GZ_SDFORMAT_VISIBLE bool recursiveSiblingUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the any type have unique names.
sdf::SDF_VERSION_NAMESPACE::readFileWithoutConversion
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.
sdf::SDF_VERSION_NAMESPACE::initFile
GZ_SDFORMAT_VISIBLE bool initFile(const std::string &_filename, SDFPtr _sdf)
Initialize the SDF interface using a file.
sdf::SDF_VERSION_NAMESPACE::checkCanonicalLinkNames
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...
sdf::SDF_VERSION_NAMESPACE::checkJointParentChildNames
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...
sdf::SDF_VERSION_NAMESPACE::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:57
SDFImpl.hh
sdf::SDF_VERSION_NAMESPACE::recursiveSiblingNoDoubleColonInNames
GZ_SDFORMAT_VISIBLE bool recursiveSiblingNoDoubleColonInNames(sdf::ElementPtr _elem)
Check that all sibling elements do not contain the delimiter double colons '::' in element names,...
sdf::SDF_VERSION_NAMESPACE::readString
GZ_SDFORMAT_VISIBLE bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors)
Populate the SDF values from a string.
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
sdf::SDF_VERSION_NAMESPACE::shouldValidateElement
GZ_SDFORMAT_VISIBLE bool shouldValidateElement(sdf::ElementPtr _elem)
Check whether the element should be validated.
sdf::SDF_VERSION_NAMESPACE::readFile
GZ_SDFORMAT_VISIBLE sdf::SDFPtr readFile(const std::string &_filename)
Populate the SDF values from a file.
sdf::SDF_VERSION_NAMESPACE::checkPoseRelativeToGraph
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...
system_util.hh
sdf::SDF_VERSION_NAMESPACE::ParserConfig::GlobalConfig
static ParserConfig & GlobalConfig()
Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all pars...
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55