Data Structures | |
struct | DBusSignatureIter |
DBusSignatureIter struct; contains no public fields. More... | |
Functions | |
void | dbus_signature_iter_init (DBusSignatureIter *iter, const char *signature) |
Initializes a DBusSignatureIter for reading a type signature. | |
int | dbus_signature_iter_get_current_type (const DBusSignatureIter *iter) |
Returns the current type pointed to by the iterator. | |
char * | dbus_signature_iter_get_signature (const DBusSignatureIter *iter) |
Returns the signature of the single complete type starting at the given iterator. | |
int | dbus_signature_iter_get_element_type (const DBusSignatureIter *iter) |
Convenience function for returning the element type of an array; This function allows you to avoid initializing a sub-iterator and getting its current type. | |
dbus_bool_t | dbus_signature_iter_next (DBusSignatureIter *iter) |
Skip to the next value on this "level". | |
void | dbus_signature_iter_recurse (const DBusSignatureIter *iter, DBusSignatureIter *subiter) |
Initialize a new iterator pointing to the first type in the current container. | |
dbus_bool_t | dbus_signature_validate (const char *signature, DBusError *error) |
Check a type signature for validity. | |
dbus_bool_t | dbus_signature_validate_single (const char *signature, DBusError *error) |
Check that a type signature is both valid and contains exactly one complete type. | |
dbus_bool_t | dbus_type_is_container (int typecode) |
A "container type" can contain basic types, or nested container types. | |
dbus_bool_t | dbus_type_is_basic (int typecode) |
A "basic type" is a somewhat arbitrary concept, but the intent is to include those types that are fully-specified by a single typecode, with no additional type information or nested values. | |
dbus_bool_t | dbus_type_is_fixed (int typecode) |
Tells you whether values of this type can change length if you set them to some other value. |
int dbus_signature_iter_get_current_type | ( | const DBusSignatureIter * | iter | ) |
Returns the current type pointed to by the iterator.
If the iterator is pointing at a type code such as 's', then it will be returned directly.
However, when the parser encounters a container type start character such as '(' for a structure, the corresponding type for the container will be returned, e.g. DBUS_TYPE_STRUCT, not '('. In this case, you should initialize a sub-iterator with dbus_signature_iter_recurse() to parse the container type.
iter | pointer to an iterator |
Definition at line 90 of file dbus-signature.c.
References _dbus_first_type_in_signature_c_str(), and DBusSignatureRealIter::pos.
Referenced by dbus_signature_iter_get_element_type(), dbus_signature_iter_recurse(), and dbus_signature_validate_single().
int dbus_signature_iter_get_element_type | ( | const DBusSignatureIter * | iter | ) |
Convenience function for returning the element type of an array; This function allows you to avoid initializing a sub-iterator and getting its current type.
Undefined behavior results if you invoke this function when the current type of the iterator is not DBUS_TYPE_ARRAY.
iter | pointer to an iterator |
Definition at line 144 of file dbus-signature.c.
References _dbus_first_type_in_signature_c_str(), dbus_signature_iter_get_current_type(), DBUS_TYPE_ARRAY, DBUS_TYPE_INVALID, and DBusSignatureRealIter::pos.
char * dbus_signature_iter_get_signature | ( | const DBusSignatureIter * | iter | ) |
Returns the signature of the single complete type starting at the given iterator.
For example, if the iterator is pointing at the start of "(ii)ii" (which is "a struct of two ints, followed by an int, followed by an int"), then "(ii)" would be returned. If the iterator is pointing at one of the "i" then just that "i" would be returned.
iter | pointer to an iterator |
Definition at line 110 of file dbus-signature.c.
References _dbus_string_append_len(), _dbus_string_free(), _dbus_string_init(), _dbus_string_steal_data(), _dbus_type_signature_next(), NULL, and DBusSignatureRealIter::pos.
void dbus_signature_iter_init | ( | DBusSignatureIter * | iter, | |
const char * | signature | |||
) |
Initializes a DBusSignatureIter for reading a type signature.
This function is not safe to use on invalid signatures; be sure to validate potentially invalid signatures with dbus_signature_validate before using this function.
iter | pointer to an iterator to initialize | |
signature | the type signature |
Definition at line 65 of file dbus-signature.c.
References FALSE, DBusSignatureRealIter::finished, DBusSignatureRealIter::in_array, and DBusSignatureRealIter::pos.
Referenced by dbus_signature_validate_single().
dbus_bool_t dbus_signature_iter_next | ( | DBusSignatureIter * | iter | ) |
Skip to the next value on this "level".
e.g. the next field in a struct, the next value in an array. Returns FALSE at the end of the current container.
iter | the iterator |
Definition at line 162 of file dbus-signature.c.
References _dbus_type_signature_next(), DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_INVALID, FALSE, DBusSignatureRealIter::finished, DBusSignatureRealIter::in_array, DBusSignatureRealIter::pos, and TRUE.
Referenced by dbus_signature_validate_single().
void dbus_signature_iter_recurse | ( | const DBusSignatureIter * | iter, | |
DBusSignatureIter * | subiter | |||
) |
Initialize a new iterator pointing to the first type in the current container.
The results are undefined when calling this if the current type is a non-container (i.e. if dbus_type_is_container() returns FALSE for the result of dbus_signature_iter_get_current_type()).
iter | the current interator | |
subiter | an iterator to initialize pointing to the first child |
Definition at line 205 of file dbus-signature.c.
References dbus_signature_iter_get_current_type(), DBUS_TYPE_ARRAY, dbus_type_is_container(), FALSE, DBusSignatureRealIter::in_array, DBusSignatureRealIter::pos, and TRUE.
dbus_bool_t dbus_signature_validate | ( | const char * | signature, | |
DBusError * | error | |||
) |
Check a type signature for validity.
Remember that NULL can always be passed instead of a DBusError*, if you don't care about having an error name and message.
signature | a potentially invalid type signature | |
error | error return |
Definition at line 231 of file dbus-signature.c.
References _dbus_string_init_const(), _dbus_validate_signature(), DBUS_ERROR_INVALID_SIGNATURE, dbus_set_error(), FALSE, and TRUE.
Referenced by dbus_signature_validate_single().
dbus_bool_t dbus_signature_validate_single | ( | const char * | signature, | |
DBusError * | error | |||
) |
Check that a type signature is both valid and contains exactly one complete type.
"One complete type" means a single basic type, array, struct, or dictionary, though the struct or array may be arbitrarily recursive and complex. More than one complete type would mean for example "ii" or two integers in sequence.
signature | a potentially invalid type signature | |
error | error return |
Definition at line 256 of file dbus-signature.c.
References DBUS_ERROR_INVALID_SIGNATURE, dbus_set_error(), dbus_signature_iter_get_current_type(), dbus_signature_iter_init(), dbus_signature_iter_next(), dbus_signature_validate(), DBUS_TYPE_INVALID, FALSE, and TRUE.
dbus_bool_t dbus_type_is_basic | ( | int | typecode | ) |
A "basic type" is a somewhat arbitrary concept, but the intent is to include those types that are fully-specified by a single typecode, with no additional type information or nested values.
So all numbers and strings are basic types and structs, arrays, and variants are not basic types. DBUS_TYPE_INVALID is not a basic type.
This function will crash if passed a typecode that isn't in dbus-protocol.h
Definition at line 306 of file dbus-signature.c.
References _dbus_type_is_valid(), DBUS_TYPE_INVALID, and FALSE.
Referenced by _dbus_marshal_read_basic(), _dbus_marshal_write_basic(), _dbus_message_iter_get_args_valist(), _dbus_type_reader_set_basic(), _dbus_validate_signature_with_reason(), dbus_message_append_args_valist(), and dbus_message_iter_append_basic().
dbus_bool_t dbus_type_is_container | ( | int | typecode | ) |
A "container type" can contain basic types, or nested container types.
DBUS_TYPE_INVALID is not a container type.
This function will crash if passed a typecode that isn't in dbus-protocol.h
Definition at line 284 of file dbus-signature.c.
References _dbus_type_is_valid(), DBUS_TYPE_INVALID, and FALSE.
Referenced by dbus_message_iter_open_container(), and dbus_signature_iter_recurse().
dbus_bool_t dbus_type_is_fixed | ( | int | typecode | ) |
Tells you whether values of this type can change length if you set them to some other value.
For this purpose, you assume that the first byte of the old and new value would be in the same location, so alignment padding is not a factor.
This function is useful to determine whether dbus_message_iter_get_fixed_array() may be used.
Some structs are fixed-size (if they contain only fixed-size types) but struct is not considered a fixed type for purposes of this function.
This function will crash if passed a typecode that isn't in dbus-protocol.h
Definition at line 335 of file dbus-signature.c.
References _dbus_type_is_valid(), DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_INVALID, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, FALSE, and TRUE.
Referenced by _dbus_marshal_write_fixed_multi(), _dbus_message_iter_get_args_valist(), _dbus_type_reader_read_fixed_multi(), _dbus_type_reader_set_basic(), _dbus_type_writer_write_fixed_multi(), dbus_message_append_args_valist(), dbus_message_iter_append_fixed_array(), and dbus_message_iter_get_fixed_array().