A map of string keys to values whose type can vary at runtime.
Values in an AnyMap are held by instances of AnyValue. Instances of AnyMap can be nested to form a tree.
Setting elements
AnyMap breakfast;
breakfast["spam"] = 123.4;
breakfast["eggs"] = "scrambled";
std::vector<double> v{3.14, 1.59, 2.65};
breakfast["beans/baked"] = v;
breakfast["beans"]["baked"] = v;
std::map<std::string, double> breads{{"wheat", 4.0}, {"white", 2.5}};
breakfast["toast"] = breads;
breakfast["toast"]["wheat"] = 4.0
breakfast["toast"]["white"] = 2.5
Accessing elements
double val1 = breakfast["spam"].asDouble();
std::string val2 = breakfast["eggs"].asString();
vector_fp val3 = breakfast[
"beans"][
"baked"].asVector<
double>();
std::map<std::string, double> = breakfast["toast"].asMap<double>();
Checking for elements
try {
breakfast["waffle"].asDouble();
} except (std::exception& err) {
}
try {
breakfast.at("grits").asDouble();
} except (std::exception& err) {
}
if (breakfast.hasKey("grits")) {
}
Checking element types
if (breakfast["sausage"].is<vector<double>>()) {
} else if (breakfast["sausage"].type() == typeid(vector<std::string>)) {
}
Definition at line 173 of file AnyMap.h.