ParserConfig.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 
18 #ifndef SDF_PARSER_CONFIG_HH_
19 #define SDF_PARSER_CONFIG_HH_
20 
21 #include <functional>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 #include <gz/utils/ImplPtr.hh>
27 
28 #include "sdf/Error.hh"
29 #include "sdf/InterfaceElements.hh"
30 #include "sdf/sdf_config.h"
31 #include "sdf/system_util.hh"
32 
33 
34 namespace sdf
35 {
36 inline namespace SDF_VERSION_NAMESPACE
37 {
40 {
42  ERR,
43 
45  WARN,
46 
48  LOG,
49 };
50 
51 // Forward declare private data class.
52 class ParserConfigPrivate;
53 
85 {
87  public: using SchemeToPathMap =
88  std::map<std::string, std::vector<std::string> >;
89 
91  public: ParserConfig();
92 
97  public: static ParserConfig &GlobalConfig();
98 
101  public: const std::function<std::string(const std::string &)> &
102  FindFileCallback() const;
103 
117  public: void SetFindCallback(
118  std::function<std::string(const std::string &)> _cb);
119 
122  public: const SchemeToPathMap &URIPathMap() const;
123 
129  public: void AddURIPath(const std::string &_uri, const std::string &_path);
130 
133  public: void SetWarningsPolicy(EnforcementPolicy _policy);
134 
137  public: EnforcementPolicy WarningsPolicy() const;
138 
141  public: void SetUnrecognizedElementsPolicy(EnforcementPolicy _policy);
142 
145  public: EnforcementPolicy UnrecognizedElementsPolicy() const;
146 
149  public: void SetDeprecatedElementsPolicy(EnforcementPolicy _policy);
150 
153  public: void ResetDeprecatedElementsPolicy();
154 
161  public: EnforcementPolicy DeprecatedElementsPolicy() const;
162 
166  public: void RegisterCustomModelParser(CustomModelParser _modelParser);
167 
170  public: const std::vector<CustomModelParser> &CustomModelParsers() const;
171 
175  public: void URDFSetPreserveFixedJoint(bool _preserveFixedJoint);
176 
180  public: bool URDFPreserveFixedJoint() const;
181 
184  public: void SetStoreResovledURIs(bool _resolveURI);
185 
195  public: void SetStoreResolvedURIs(bool _resolveURI);
196 
200  public: bool StoreResolvedURIs() const;
201 
203  GZ_UTILS_IMPL_PTR(dataPtr)
204 };
205 }
206 }
207 
208 #endif
Error.hh
sdf::SDF_VERSION_NAMESPACE::EnforcementPolicy
EnforcementPolicy
Policy to describe how to treat certain conditions when parsing.
Definition: ParserConfig.hh:39
sdf::SDF_VERSION_NAMESPACE::EnforcementPolicy::ERR
@ ERR
Policy is to treat condition as an error and fail parsing.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::EnforcementPolicy::LOG
@ LOG
Ignore condition in favor of best effort parsing.
InterfaceElements.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::SDF_VERSION_NAMESPACE::EnforcementPolicy::WARN
@ WARN
Treat condition as a warning and issue to user.
system_util.hh
sdf::SDF_VERSION_NAMESPACE::CustomModelParser
std::function< sdf::InterfaceModelPtr(const sdf::NestedInclude &, Errors &)> CustomModelParser
Defines a custom model parser.
Definition: InterfaceElements.hh:198