Data types

The data type used by the liburbi are described below:

UMessage

The UMessage structure is capable of storing the informations contained in any kind of URBI message by using a "type" field and an UValue (union of type-dependant structures). These two structures are defined as follows:

class UMessage
{
  public:
    /// Connection from which originated the message.
    UAbstractClient &client;
    /// Server-side timestamp.
    int timestamp;
    /// Associated tag.
    std::string tag;

    UMessageType type;

    urbi::UValue *value;
    std::string message;
    /// Raw message without the binary data.
    std::string rawMessage;
};

UValue

class UValue
{
  public:
    UDataType type;
    ufloat val;  // value if of type DATA_DOUBLE
    union
    {
      std::string       *stringValue;   // value if of type DATA_STRING
      UBinary           *binary;        // value if of type DATA_BINARY
      UList             *list;          // value if of type DATA_LIST
      UObjectStruct     *object;        // value if of type DATA_OBJ
    };
}

The type field UMessageType can be MESSAGE_SYSTEM, MESSAGE_ERROR or MESSAGE_DATA. If the type is MESSAGE_DATA, the message contains an UValue. The UValue itself contains an UDataType which can take the values: DATA_DOUBLE, DATA_STRING, DATA_BINARY, DATA_LIST, DATA_OBJECT, DATA_VOID. Depending of this field, the corresponding value in the union will be set. If the UValue is of the binary type, it contains an UBinary structure defined hereafter. The UBinaryType in the UBinary structure will give additional informations on the type of data (BINARY_NONE, BINARY_UNKNOWN, BINARY_IMAGE, BINARY_SOUND), and the appropriate sound or image structure will be filled.

UBinary

class UBinary
{
  public:
  UBinaryType  type;
  union
  {
    struct
    {
       void *data; /// binary data
       int  size;
    } common;
    UImage image;
    USound sound;
  };
}

USound

class USound {
 public:
 char                  *data;            // pointer to sound data
 int                   size;             // total size in byte
 int                   channels;         // number of audio channels
 int                   rate;             // rate in Hertz
 int                   sampleSize;       // sample size in bit
 USoundFormat          soundFormat;      // format of the sound data 
                                         // (SOUND_RAW, SOUND_WAV, SOUND_MP3...)
 USoundSampleFormat    sampleFormat;     // sample format
};

UImage

class UImage {
 public:
  char                  *data;            // pointer to image data
  int                   size;             // image size in byte
  int                   width, height;    // size of the image
  UImageFormat          imageFormat;      // IMAGE_RGB, IMAGE_YCbCr, IMAGE_JPEG...
};