List of DBus data types
AN!Tools :: Net::DBus Binding Tutorial :: List of DBus data types |
DBus uses strongly "typed" data. What this means is that all data passed on the DBus needs to be explicitely "typed" which tells the DBus exactly what kind of data it is to work with.
For an opposite comparison, perl is a very loosely typed language. In perl, you can simply store data in a variable without initially indicating if that data will be an integer, a string, etc.
Below is a complete list of the DBus data types currently in use, the DBus code used to indicate the type and the Net::DBus.
list of DBus data types
INT16
A signed 16-bit integer. Valid values are -32,768 to 32,767.
DBus: n Perl: int16
UINT16
An unsigned 16-bit integer. Valid values are 0 to 65,535.
DBus: q Perl: uint16
INT32
A signed 32-bit integer. Valid values are -2,147,483,648 to 2,147,483,647.
DBus: i Perl: int32
UINT32
An unsigned 32-bit integer. Valid values are 0 to 4,294,967,295.
DBus: u Perl: uint32
INT64
A signed 64-bit integer. Valid values are -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
DBus: x Perl: int64
NOTE; - When used on builds of perl not compiled with 64-bit support, these values will be truncated to 32-bit! You may want to check the current build's support and add some form a error checking or warning when you see this data type on non-64-bit systems.
UINT64
An unsigned 64-bit integer. Valid values are 0 to 18,446,744,073,709,551,616.
DBus: t Perl: uint64
NOTE; - When used on builds of perl not compiled with 64-bit support, these values will be truncated to 32-bit! You may want to check the current build's support and add some form a error checking or warning when you see this data type on non-64-bit systems.
DOUBLE
A double-precision (64-bit) IEEE 754 floating point value.
DBus: d Perl: double
BYTE
A single byte (a string of eight binary digits).
DBus: y Perl: byte
STRING
A UTF-8 encoded string.
DBus: s Perl: string
SIGNATURE
A DBus type signature.
DBus: g Perl: signature
OBJECT_PATH
A UTF-8 string whose value is a valid DBus object path.
DBus: o Perl: object_path
BOOLEAN
A boolean value.
DBus: b Perl: bool
ARRAY
A DBus array.
DBus: a Perl: array
Net::DBus Note: Being a compount data type, when using the Net::DBus binding you must specifiy a reference to an array where the first element is the type signature "array" followed by the type signature of the data going into the array. Specifically; ["array", ARRAY-TYPE].
For example, to specify an array consisting of strings, you would use: ["array", "string"] to specify that a method would take an array of strings.
Module:
package Some::Package;
use Net::DBus::Exporter qw(org.example.foo);
use base qw(Net::DBus::Object);
method("Some_method", ["array", "string"]);
Code:
my @array=("John", "Doe");
$object->some_method(\@array);
STRUCT
A DBus structure (like an array with possibly varying data types). This type has three components; the bounding brackets '(' and ')' and the data itself 'r'.
DBus: ( <- Begin the structure ) <- Close the structure r <- Data Perl: struct
DBus Note: The ASCII character 'r' is not actually used on the bus, but is meant to represent the more abstract concept of "data in the array". In reality, 'r' would instead be the actual type signature of the array element's data. For example, an array with the three elements ('INT32', 'INT32', 'UINT32') would be expressed as '(iiu)'.
Net::DBus Note: Being a compound data type, when using the Net::DBus binding you must specify a reference to an array where the first element is the type signature "variant" followed by the type signatures of the subsequent data.
For example, to specify a structure whose first data is a string and whose second data is an int32 value, you would use: ["struct", "string", "int32"].
Module:
package Some::Package;
use Net::DBus::Exporter qw(org.example.foo);
use base qw(Net::DBus::Object);
method("Some_method", ["struct", "string", "int32"]);
Code:
my @array=("John Doe", 32);
$object->some_method(\@array);
DICT_ENTRY
A DBus dictionary entry. This is equivalent of a perl 'hash'. This type has three components; the bounding curly-brackets '{' and '}' and the data itself 'e'.
DBus: { <- Begin the dictionary element } <- Close the dictionary element e <- Data Perl: dict
DBus Note: The ASCII character 'e' is not actually used on the bus, but is meant to represent the more abstract concept of "data in the dictionary". In reality, 'e' would instead be the actual type signature of the dictionary keys and data. For example, a dictionary whose key is a 'UNIT32' and whose data is a 'STRING' would be expressed as '{us}'.
Net::DBus Note: Being a compound data type, when using the Net::DBus binding you must specify a reference to an array where the first element is the type signature "dict" followed by the type signature of the key, then the type-signature of the data going into the dictionary. Specifically; ["dict", KEY-TYPE, DATA-TYPE].
For example, to specify a dictionary (hash) whose key is a string and whose data is a string, you would use: ["dict", "string", "string"].
Module:
package Some::Package;
use Net::DBus::Exporter qw(org.example.foo);
use base qw(Net::DBus::Object);
method("Some_method", ["dict", "string", "string"]);
Code:
my %hash=(
givenname => "John",
familyname => "Doe");
$object->some_method(\%hash);
VARIANT
A DBus variant.
DBus: v Perl: variant
Any questions, feedback, advice, complaints or meanderings are welcome. | |||
Alteeve's Niche! | Alteeve Enterprise Support | Community Support | |
© 2025 Alteeve. Intelligent Availability® is a registered trademark of Alteeve's Niche! Inc. 1997-2025 | |||
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions. |