JayBeams  0.1
Another project to have fun coding.
convert_severity_level.hpp
Go to the documentation of this file.
1 #ifndef jb_convert_severity_level_hpp
2 #define jb_convert_severity_level_hpp
3 
4 #include <jb/severity_level.hpp>
5 #include <yaml-cpp/yaml.h>
6 
7 namespace YAML {
8 /**
9  * Specialize YAML conversions for jb::severity_level.
10  *
11  * Arguably this might belong in the header defining jb::severity_level,
12  * but this is specific to using a jb::severity_level in configuration objects.
13  */
14 template <>
15 struct convert<jb::severity_level> {
16  static bool decode(YAML::Node node, jb::severity_level& rhs) {
17  jb::parse(rhs, node.as<std::string>());
18  return true;
19  }
20 
21  static YAML::Node encode(jb::severity_level const& x) {
22  return YAML::Node(jb::get_name(x));
23  }
24 };
25 } // namespace YAML
26 
27 #endif // jb_convert_severity_level_hpp
severity_level
Severity levels for JayBeams, based on syslog.
static bool decode(YAML::Node node, jb::severity_level &rhs)
char const * get_name(severity_level const &rhs)
Get the name of a security level.
Types and functions for the yaml-cpp library.
void parse(severity_level &lhs, std::string const &rhs)
Parse a severity level.
static YAML::Node encode(jb::severity_level const &x)
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7