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  class Root;
42 
47  bool init(SDFPtr _sdf);
48 
54  bool init(SDFPtr _sdf, const ParserConfig &_config);
55 
61  bool initFile(const std::string &_filename, SDFPtr _sdf);
62 
69  bool initFile(
70  const std::string &_filename, const ParserConfig &_config, SDFPtr _sdf);
71 
77  bool initFile(const std::string &_filename, ElementPtr _sdf);
78 
85  bool initFile(const std::string &_filename, const ParserConfig &_config,
86  ElementPtr _sdf);
87 
93  bool initString(const std::string &_xmlString, SDFPtr _sdf);
94 
101  bool initString(
102  const std::string &_xmlString, const ParserConfig &_config, SDFPtr _sdf);
103 
112  sdf::SDFPtr readFile(const std::string &_filename);
113 
123  sdf::SDFPtr readFile(const std::string &_filename, Errors &_errors);
124 
135  sdf::SDFPtr readFile(const std::string &_filename,
136  const ParserConfig &_config, Errors &_errors);
137 
148  bool readFile(const std::string &_filename, SDFPtr _sdf, Errors &_errors);
149 
161  bool readFile(const std::string &_filename, const ParserConfig &_config,
162  SDFPtr _sdf, Errors &_errors);
163 
177  const std::string &_filename, SDFPtr _sdf, Errors &_errors);
178 
192  bool readFileWithoutConversion(const std::string &_filename,
193  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
194 
204  bool readFile(const std::string &_filename, SDFPtr _sdf);
205 
216  bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
217 
229  bool readString(const std::string &_xmlString, const ParserConfig &_config,
230  SDFPtr _sdf, Errors &_errors);
231 
241  bool readString(const std::string &_xmlString, SDFPtr _sdf);
242 
253  bool readString(const std::string &_xmlString, ElementPtr _sdf,
254  Errors &_errors);
255 
267  bool readString(const std::string &_xmlString, const ParserConfig &_config,
268  ElementPtr _sdf, Errors &_errors);
269 
283  const std::string &_xmlString, SDFPtr _sdf, Errors &_errors);
284 
296  bool readStringWithoutConversion(const std::string &_xmlString,
297  const ParserConfig &_config, SDFPtr _sdf, Errors &_errors);
298 
308  bool readString(const std::string &_xmlString, ElementPtr _sdf);
309 
316  std::string getModelFilePath(const std::string &_modelDirPath);
317 
324  bool convertFile(const std::string &_filename, const std::string &_version,
325  SDFPtr _sdf);
326 
334  bool convertFile(const std::string &_filename, const std::string &_version,
335  const ParserConfig &_config, SDFPtr _sdf);
336 
343  bool convertString(const std::string &_sdfString,
344  const std::string &_version, SDFPtr _sdf);
345 
353  bool convertString(const std::string &_sdfString, const std::string &_version,
354  const ParserConfig &_config, SDFPtr _sdf);
355 
364  bool checkCanonicalLinkNames(const sdf::Root *_root);
365 
375  bool checkFrameAttachedToGraph(const sdf::Root *_root);
376 
386  bool checkFrameAttachedToNames(const sdf::Root *_root);
387 
396  bool checkJointParentChildLinkNames(const sdf::Root *_root);
397 
406  void checkJointParentChildNames(const sdf::Root *_root, Errors &_errors);
407 
417  bool checkPoseRelativeToGraph(const sdf::Root *_root);
418 
427 
436 
446 
454 
460  std::string computeMergedModelProxyFrameName(const std::string &_modelName);
461  }
462 }
463 #endif
sdf::SDF_VERSION_NAMESPACE::readFileWithoutConversion
IGNITION_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::checkPoseRelativeToGraph
IGNITION_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...
sdf::SDF_VERSION_NAMESPACE::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::SDF_VERSION_NAMESPACE::convertString
IGNITION_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::recursiveSameTypeUniqueNames
IGNITION_SDFORMAT_VISIBLE bool recursiveSameTypeUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the same type have unique names.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::init
IGNITION_SDFORMAT_VISIBLE bool init(SDFPtr _sdf)
Initialize the SDF interface from the embedded root spec file.
sdf::SDF_VERSION_NAMESPACE::convertFile
IGNITION_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::readFile
IGNITION_SDFORMAT_VISIBLE sdf::SDFPtr readFile(const std::string &_filename)
Populate the SDF values from a file.
sdf::SDF_VERSION_NAMESPACE::getModelFilePath
IGNITION_SDFORMAT_VISIBLE std::string getModelFilePath(const std::string &_modelDirPath)
Get the file path to the model file.
sdf::SDF_VERSION_NAMESPACE::readString
IGNITION_SDFORMAT_VISIBLE bool readString(const std::string &_xmlString, SDFPtr _sdf, Errors &_errors)
Populate the SDF values from a string.
sdf::SDF_VERSION_NAMESPACE::checkJointParentChildLinkNames
IGNITION_SDFORMAT_VISIBLE bool checkJointParentChildLinkNames(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::shouldValidateElement
IGNITION_SDFORMAT_VISIBLE bool shouldValidateElement(sdf::ElementPtr _elem)
Check whether the element should be validated.
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::recursiveSiblingNoDoubleColonInNames
IGNITION_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::checkCanonicalLinkNames
IGNITION_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::checkFrameAttachedToGraph
IGNITION_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::SDF_VERSION_NAMESPACE::initString
IGNITION_SDFORMAT_VISIBLE bool initString(const std::string &_xmlString, SDFPtr _sdf)
Initialize the SDF interface using a string.
sdf::SDF_VERSION_NAMESPACE::readStringWithoutConversion
IGNITION_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::checkJointParentChildNames
IGNITION_SDFORMAT_VISIBLE void checkJointParentChildNames(const sdf::Root *_root, Errors &_errors)
Check that all joints in contained models specify parent and child names that match the names of sibl...
sdf::SDF_VERSION_NAMESPACE::initFile
IGNITION_SDFORMAT_VISIBLE bool initFile(const std::string &_filename, SDFPtr _sdf)
Initialize the SDF interface using a file.
sdf::SDF_VERSION_NAMESPACE::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:56
SDFImpl.hh
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
sdf::SDF_VERSION_NAMESPACE::recursiveSiblingUniqueNames
IGNITION_SDFORMAT_VISIBLE bool recursiveSiblingUniqueNames(sdf::ElementPtr _elem)
Check that all sibling elements of the any type have unique names.
system_util.hh
sdf::SDF_VERSION_NAMESPACE::checkFrameAttachedToNames
IGNITION_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::computeMergedModelProxyFrameName
IGNITION_SDFORMAT_VISIBLE std::string computeMergedModelProxyFrameName(const std::string &_modelName)
Function to compute a merged model's proxy frame name.
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54