This class contains configuration options for the libsdformat parser. More...
#include <ParserConfig.hh>
Public Types | |
using | SchemeToPathMap = std::map< std::string, std::vector< std::string > > |
type alias for the map from URI scheme to search directories More... | |
Public Member Functions | |
ParserConfig () | |
Default constructor. More... | |
void | AddURIPath (const std::string &_uri, const std::string &_path) |
Associate paths to a URI. More... | |
const std::vector< CustomModelParser > & | CustomModelParsers () const |
Get the registered custom model parsers. More... | |
EnforcementPolicy | DeprecatedElementsPolicy () const |
Get the current deprecated elements policy. More... | |
const std::function< std::string(const std::string &)> & | FindFileCallback () const |
Get the find file callback function. More... | |
void | RegisterCustomModelParser (CustomModelParser _modelParser) |
Registers a custom model parser. More... | |
void | ResetDeprecatedElementsPolicy () |
Resets the policy for deprecated elements so that it follows WarningsPolicy. More... | |
void | SetDeprecatedElementsPolicy (EnforcementPolicy _policy) |
Set the policy for deprecated elements. More... | |
void | SetFindCallback (std::function< std::string(const std::string &)> _cb) |
Set the callback to use when libsdformat can't find a file. More... | |
void | SetUnrecognizedElementsPolicy (EnforcementPolicy _policy) |
Set the policy for unrecogonized elements without an xmlns. More... | |
void | SetWarningsPolicy (EnforcementPolicy _policy) |
Set the warning enforcment policy. More... | |
EnforcementPolicy | UnrecognizedElementsPolicy () const |
Get the current unrecognized elements policy. More... | |
bool | URDFPreserveFixedJoint () const |
Get the preserveFixedJoint flag value. More... | |
void | URDFSetPreserveFixedJoint (bool _preserveFixedJoint) |
Set the preserveFixedJoint flag. More... | |
const SchemeToPathMap & | URIPathMap () const |
Get the URI scheme to search directories map. More... | |
EnforcementPolicy | WarningsPolicy () const |
Get the current warning enforcement policy. More... | |
Static Public Member Functions | |
static ParserConfig & | GlobalConfig () |
Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all parsing operations that do not specify their own ParserConfig. More... | |
This class contains configuration options for the libsdformat parser.
The configuration options include:
For backward compatibility, the functions sdf::setFindCallback() and sdf::addURIPath() update a singleton ParserConfig object, which can be retrieved by ParserConfig::GlobalConfig().
The functions sdf::readFile(), sdf::readString(), and sdf::Root::Load() have overloads that take a ParserConfig object. If the ParserConfig object is omitted, these functions will use the singleton ParserConfig object.
Example: To set an additional URI scheme search directory without affecting the global config,
using sdf::v12::ParserConfig::SchemeToPathMap = std::map<std::string, std::vector<std::string> > |
type alias for the map from URI scheme to search directories
sdf::v12::ParserConfig::ParserConfig | ( | ) |
Default constructor.
void sdf::v12::ParserConfig::AddURIPath | ( | const std::string & | _uri, |
const std::string & | _path | ||
) |
Associate paths to a URI.
Example paramters: "model://", "/usr/share/models:~/.gazebo/models"
[in] | _uri | URI that will be mapped to _path |
[in] | _path | Colon separated set of paths. |
const std::vector<CustomModelParser>& sdf::v12::ParserConfig::CustomModelParsers | ( | ) | const |
Get the registered custom model parsers.
EnforcementPolicy sdf::v12::ParserConfig::DeprecatedElementsPolicy | ( | ) | const |
Get the current deprecated elements policy.
By default, the policy is the same as the overall WarningsPolicy, but it can be overriden by SetDeprecatedElementsPolicy. Once it is overriden, changing SetWarningsPolicy will not change the value of DeprecatedElementsPolicy unless ResetDeprecatedElementsPolicy is called.
const std::function<std::string(const std::string &)>& sdf::v12::ParserConfig::FindFileCallback | ( | ) | const |
Get the find file callback function.
|
static |
Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all parsing operations that do not specify their own ParserConfig.
void sdf::v12::ParserConfig::RegisterCustomModelParser | ( | CustomModelParser | _modelParser | ) |
Registers a custom model parser.
[in] | _modelParser | Callback as described in sdf/InterfaceElements.hh. |
void sdf::v12::ParserConfig::ResetDeprecatedElementsPolicy | ( | ) |
Resets the policy for deprecated elements so that it follows WarningsPolicy.
void sdf::v12::ParserConfig::SetDeprecatedElementsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the policy for deprecated elements.
[in] | _policy | The deprecated elements enforcement policy |
void sdf::v12::ParserConfig::SetFindCallback | ( | std::function< std::string(const std::string &)> | _cb | ) |
Set the callback to use when libsdformat can't find a file.
The callback should return a complete path to the requested file, or an empty string if the file was not found in the callback. Generally, the input argument is a URI or a file path (absolute or relative) obtained from a //include/uri
element. For example, if the value custom://model_name
is given in a //include/uri
, sdf::findFile() may invoke the callback with the argument custom://model_name
if it is unable to find a file using the steps listed in sdf::findfile().
Note, however, the input is not limited to URIs and file paths, and it is left up to the callback to interpret the contents of the input string.
[in] | _cb | The callback function. |
void sdf::v12::ParserConfig::SetUnrecognizedElementsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the policy for unrecogonized elements without an xmlns.
[in] | _policy | The unrecognized elements enforcement policy |
void sdf::v12::ParserConfig::SetWarningsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the warning enforcment policy.
[in] | _policy | policy enum value to set |
EnforcementPolicy sdf::v12::ParserConfig::UnrecognizedElementsPolicy | ( | ) | const |
Get the current unrecognized elements policy.
bool sdf::v12::ParserConfig::URDFPreserveFixedJoint | ( | ) | const |
Get the preserveFixedJoint flag value.
void sdf::v12::ParserConfig::URDFSetPreserveFixedJoint | ( | bool | _preserveFixedJoint | ) |
Set the preserveFixedJoint flag.
const SchemeToPathMap& sdf::v12::ParserConfig::URIPathMap | ( | ) | const |
Get the URI scheme to search directories map.
EnforcementPolicy sdf::v12::ParserConfig::WarningsPolicy | ( | ) | const |
Get the current warning enforcement policy.