Logical switches

This commit is contained in:
Raphael Coeffic
2021-12-31 10:53:09 +01:00
parent 80c62bb1f0
commit c6b23797a7
8 changed files with 269 additions and 22 deletions
@@ -51,8 +51,7 @@ const YamlLookupTable specialSourceLut = {
// TODO: { ???, "TX_GPS" },
};
namespace YAML {
Node convert<RawSource>::encode(const RawSource& rhs)
std::string YamlRawSourceEncode(const RawSource& rhs)
{
std::string src_str;
switch (rhs.type) {
@@ -123,13 +122,12 @@ Node convert<RawSource>::encode(const RawSource& rhs)
src_str = "NONE";
break;
}
return Node(src_str);
return src_str;
}
bool convert<RawSource>::decode(const Node& node, RawSource& rhs)
RawSource YamlRawSourceDecode(const std::string& src_str)
{
std::string src_str = node.Scalar();
RawSource rhs;
const char* val = src_str.data();
size_t val_len = src_str.size();
@@ -252,8 +250,20 @@ bool convert<RawSource>::decode(const Node& node, RawSource& rhs)
rhs.index = 0;
}
}
// TODO: raw analogs
return rhs;
}
namespace YAML {
Node convert<RawSource>::encode(const RawSource& rhs)
{
return Node(YamlRawSourceEncode(rhs));
}
bool convert<RawSource>::decode(const Node& node, RawSource& rhs)
{
std::string src_str = node.Scalar();
rhs = YamlRawSourceDecode(src_str);
return true;
}
} // namespace YAML