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 | SetStoreResolvedURIs (bool _resolveURI) |
Set the storeResolvedURIs flag value. More... | |
void | SetStoreResovledURIs (bool _resolveURI) |
Set the storeResolvedURIs flag value. 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... | |
bool | StoreResolvedURIs () const |
Get the storeResolvedURIs flag value. 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::SDF_VERSION_NAMESPACE::ParserConfig::SchemeToPathMap = std::map<std::string, std::vector<std::string> > |
type alias for the map from URI scheme to search directories
sdf::SDF_VERSION_NAMESPACE::ParserConfig::ParserConfig | ( | ) |
Default constructor.
void sdf::SDF_VERSION_NAMESPACE::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::SDF_VERSION_NAMESPACE::ParserConfig::CustomModelParsers | ( | ) | const |
Get the registered custom model parsers.
EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::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::SDF_VERSION_NAMESPACE::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::SDF_VERSION_NAMESPACE::ParserConfig::RegisterCustomModelParser | ( | CustomModelParser | _modelParser | ) |
Registers a custom model parser.
[in] | _modelParser | Callback as described in sdf/InterfaceElements.hh. |
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::ResetDeprecatedElementsPolicy | ( | ) |
Resets the policy for deprecated elements so that it follows WarningsPolicy.
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetDeprecatedElementsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the policy for deprecated elements.
[in] | _policy | The deprecated elements enforcement policy |
void sdf::SDF_VERSION_NAMESPACE::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::SDF_VERSION_NAMESPACE::ParserConfig::SetStoreResolvedURIs | ( | bool | _resolveURI | ) |
Set the storeResolvedURIs flag value.
[in] | _resolveURI | True to make the parser attempt to resolve any URIs found and store them. False to preserve original URIs |
The Parser will use the FindFileCallback provided to attempt to resolve URIs in the Mesh, Material, Heightmap, and Skybox DOM objects If the FindFileCallback provides a non-empty string, the URI will be stored in the DOM object, and the original (unresolved) URI will be stored in the underlying Element.
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetStoreResovledURIs | ( | bool | _resolveURI | ) |
Set the storeResolvedURIs flag value.
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetUnrecognizedElementsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the policy for unrecogonized elements without an xmlns.
[in] | _policy | The unrecognized elements enforcement policy |
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetWarningsPolicy | ( | EnforcementPolicy | _policy | ) |
Set the warning enforcment policy.
[in] | _policy | policy enum value to set |
bool sdf::SDF_VERSION_NAMESPACE::ParserConfig::StoreResolvedURIs | ( | ) | const |
Get the storeResolvedURIs flag value.
EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::ParserConfig::UnrecognizedElementsPolicy | ( | ) | const |
Get the current unrecognized elements policy.
bool sdf::SDF_VERSION_NAMESPACE::ParserConfig::URDFPreserveFixedJoint | ( | ) | const |
Get the preserveFixedJoint flag value.
void sdf::SDF_VERSION_NAMESPACE::ParserConfig::URDFSetPreserveFixedJoint | ( | bool | _preserveFixedJoint | ) |
Set the preserveFixedJoint flag.
[in] | _preserveFixedJoint | True to preserve fixed joints, false to reduce the fixed joints and merge the child link into the parent. |
const SchemeToPathMap& sdf::SDF_VERSION_NAMESPACE::ParserConfig::URIPathMap | ( | ) | const |
Get the URI scheme to search directories map.
EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::ParserConfig::WarningsPolicy | ( | ) | const |
Get the current warning enforcement policy.