summaryrefslogtreecommitdiffstats
path: root/src/utl_yaml.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utl_yaml.h')
-rwxr-xr-xsrc/utl_yaml.h55
1 files changed, 44 insertions, 11 deletions
diff --git a/src/utl_yaml.h b/src/utl_yaml.h
index 71655488..59104b21 100755
--- a/src/utl_yaml.h
+++ b/src/utl_yaml.h
@@ -24,23 +24,56 @@ limitations under the License.
#include <stdint.h>
#include <yaml-cpp/yaml.h>
-
+
+/* static methods - please prefer the wrapper over those */
bool utl_yaml_read_ip_addr(const YAML::Node& node,
- std::string name,
- uint32_t & val
- );
+ const std::string &name,
+ uint32_t & val);
bool utl_yaml_read_uint32(const YAML::Node& node,
- std::string name,
- uint32_t & val);
+ const std::string &name,
+ uint32_t & val);
+
bool utl_yaml_read_uint16(const YAML::Node& node,
- std::string name,
- uint16_t & val);
+ const std::string &name,
+ uint16_t & val);
+
+/* a thin wrapper to customize errors */
+class YAMLParserWrapper {
+public:
+ /* a header that will start every error message */
+ YAMLParserWrapper(const std::string &filename) : m_filename(filename) {
+ }
+
+ /**
+ * loads the file (while parsing it)
+ *
+ */
+ void load(YAML::Node &root);
+
+ /* bool */
+ bool parse_bool(const YAML::Node &node, const std::string &name);
+ bool parse_bool(const YAML::Node &node, const std::string &name, bool def);
-bool utl_yaml_read_bool(const YAML::Node& node,
- std::string name,
- bool & val);
+ const YAML::Node & parse_list(const YAML::Node &node, const std::string &name);
+ const YAML::Node & parse_map(const YAML::Node &node, const std::string &name);
+ uint32_t parse_ip(const YAML::Node &node, const std::string &name);
+ uint64_t parse_mac_addr(const YAML::Node &node, const std::string &name);
+ uint64_t parse_mac_addr(const YAML::Node &node, const std::string &name, uint64_t def);
+
+ uint64_t parse_uint(const YAML::Node &node, const std::string &name, uint64_t low = 0, uint64_t high = UINT64_MAX);
+ uint64_t parse_uint(const YAML::Node &node, const std::string &name, uint64_t low, uint64_t high, uint64_t def);
+
+
+public:
+ void parse_err(const std::string &err, const YAML::Node &node) const;
+ void parse_err(const std::string &err) const;
+
+
+private:
+ std::string m_filename;
+};
#endif