You have to define a type that matches your key. For example, if your key is a sequence of two scalars:
struct Key {
std::string a, b;
Key(std::string A="", std::string B=""): a(A), b(B) {}
bool operator==(const Key& rhs) const {
return a == rhs.a && b == rhs.b;
}
};
namespace YAML {
template<>
struct convert<Key> {
static Node encode(const Key& rhs) {
Node node;
node.push_back(rhs.a);
node.push_back(rhs.b);
return node;
}
static bool decode(const Node& node, Key& rhs) {
if(!node.IsSequence() || node.size() != 2)
return false;
rhs.a = node[0].as<std::string>();
rhs.b = node[1].as<std::string>();
return true;
}
};
}
Then, if your YAML file is
? [foo, bar]
: some value
You could write:
YAML::Node doc = YAML::LoadFile("test.yaml");
std::cout << doc[Key("foo", "bar")]; // prints "some value"
Note:
I think your YAML doesn't do what you intended. In block context, an explicit key/value pair must be on separate lines. In other words, you should do
? [L, itsy]
: ISO_LOW_ITSY(out, in, ctrl)
and not
? [L, itsy] : ISO_LOW_ITSY(out, in, ctrl)
The latter makes it a single key, with an (implicit) null value; i.e., it's the same as
? [L, itsy] : ISO_LOW_ITSY(out, in, ctrl)
: ~
(You can see this by how yaml-cpp outputs your example.) See the relevant area in the spec.