JayBeams  0.1
Another project to have fun coding.
convert_cpu_set.hpp
Go to the documentation of this file.
1 #ifndef jb_convert_cpu_set_hpp
2 #define jb_convert_cpu_set_hpp
3 
4 #include <jb/cpu_set.hpp>
5 #include <yaml-cpp/yaml.h>
6 
7 namespace YAML {
8 
9 /**
10  * Specialize YAML conversions for jb::cpu_set.
11  *
12  * Arguably this might belong in the header defining jb::cpu_set,
13  * but this is specific to using a cpu_set in configuration objects.
14  */
15 template <>
16 struct convert<jb::cpu_set> {
17  static bool decode(YAML::Node node, jb::cpu_set& rhs) {
18  rhs = jb::cpu_set::parse(node.as<std::string>());
19  return true;
20  }
21 
22  static YAML::Node encode(jb::cpu_set const& x) {
23  return YAML::Node(x.as_list_format());
24  }
25 };
26 
27 } // namespace YAML
28 
29 #endif // jb_convert_cpu_set
std::string as_list_format() const
Return the set in the list format representation.
Definition: cpu_set.cpp:55
static cpu_set parse(std::string const &value)
Interpret value as a cpu set in list format.
Definition: cpu_set.cpp:24
static bool decode(YAML::Node node, jb::cpu_set &rhs)
Types and functions for the yaml-cpp library.
A wrapper for the Linux CPU_SET data structure.
Definition: cpu_set.hpp:37
static YAML::Node encode(jb::cpu_set const &x)
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7