What is ALValue?
ALValue is a variant used by ALCommon.
It is a recursive type. An ALValue can be:
- an int
- a bool
- a float
- a string
- an array of ALValue objects
#include <iostream>
using namespace AL;
int main()
{
std::cout <<
"val: " << val.
toString() << std::endl;
int a, b;
std::string c;
a = (int) val[0];
b = (int) val[1];
c = (std::string) val[2];
std::cout << "a : " << a << std::endl
<< "b : " << b << std::endl
<< "c : " << c << std::endl;
return 0;
}
limitations
- It's not easy to store maps in ALValue. You have to do something like a list of lists of 2 elements (key, value).
- The type double is not supported
- Some automatic conversions from std::vector to ALValue work, but not all of them (std::vector<int> and std::vector<float> works, but not std::vector<std::string> and std::vector<bool>)
Reference
Extras