- Aldebaran documentation |
- C++ Libraries |
- index

libalvalue 2.8.7.4

- Main Page
- Related Pages
- Classes
- Files

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libalvalue

# 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>
#include <alvalue/alvalue.h>
using namespace AL;
int main()
{
// Create an array of 2 ints and a string
ALValue val;
val.arrayPush(1);
val.arrayPush(2);
val.arrayPush("hello");
// For debugging purposes:
std::cout << "val: " << val.toString() << std::endl;
/*
Or:
ALValue val;
val.setSize(3);
val[0] = 1;
val[1] = 2;
val[2] = "hello";
*/
// Read two ints and a string from an ALValue:
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>)
- There are other limitations when using ALValue from other languages:
  - The conversion from ALValue to a Python type is locale-dependant
  - Not all types of ALValue are supported in Java

# Reference

- AL::ALValue

# Extras