#endif
}
+/**
+ * Returns the number of values remaining in the current array reader.
+ *
+ * @param reader the reader to read from
+ * @returns the number of elements remaining in the array
+ */
+int
+_dbus_type_reader_get_array_length (const DBusTypeReader *reader)
+{
+ _dbus_assert (!reader->klass->types_only);
+ _dbus_assert (reader->klass == &array_reader_class);
+
+ return array_reader_get_array_len (reader);
+}
+
/**
* Reads a block of fixed-length basic values, from the current point
* in an array to the end of the array. Does not work for arrays of
int _dbus_type_reader_get_value_pos (const DBusTypeReader *reader);
void _dbus_type_reader_read_basic (const DBusTypeReader *reader,
void *value);
+int _dbus_type_reader_get_array_length (const DBusTypeReader *reader);
void _dbus_type_reader_read_fixed_multi (const DBusTypeReader *reader,
void *value,
int *n_elements);
_dbus_type_reader_recurse (&real->u.reader, &real_sub->u.reader);
}
+/**
+ * Returns the current signature of a message iterator. This
+ * is useful primarily for dealing with variants; one can
+ * recurse into a variant and determine the signature of
+ * the variant's value.
+ *
+ * @param iter the message iterator
+ * @returns the contained signature, or NULL if out of memory
+ */
+char *
+dbus_message_iter_get_signature (DBusMessageIter *iter)
+{
+ const DBusString *sig;
+ DBusString retstr;
+ char *ret;
+ int start, len;
+ DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
+
+ _dbus_return_val_if_fail (_dbus_message_iter_check (real), NULL);
+
+ if (!_dbus_string_init (&retstr))
+ return NULL;
+
+ _dbus_type_reader_get_signature (&real->u.reader, &sig,
+ &start, &len);
+ if (!_dbus_string_append_len (&retstr,
+ _dbus_string_get_const_data (sig) + start,
+ len))
+ return NULL;
+ if (!_dbus_string_steal_data (&retstr, &ret))
+ return NULL;
+ _dbus_string_free (&retstr);
+ return ret;
+}
+
/**
* Reads a basic-typed value from the message iterator.
* Basic types are the non-containers such as integer and string.
value);
}
+/**
+ * Returns the number of elements in the array;
+ *
+ * @param iter the iterator
+ * @returns the number of elements in the array
+ */
+int
+dbus_message_iter_get_array_len (DBusMessageIter *iter)
+{
+ DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
+
+ _dbus_return_val_if_fail (_dbus_message_iter_check (real), 0);
+
+ return _dbus_type_reader_get_array_length (&real->u.reader);
+}
+
/**
* Reads a block of fixed-length values from the message iterator.
* Fixed-length values are those basic types that are not string-like,
_dbus_return_if_fail (_dbus_message_iter_check (real));
_dbus_return_if_fail (value != NULL);
- _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_element_type (&real->u.reader)));
+ _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_current_type (&real->u.reader)));
_dbus_type_reader_read_fixed_multi (&real->u.reader,
value, n_elements);
DBusMessageIter *iter);
dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter);
dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter);
+char* dbus_message_iter_get_signature (DBusMessageIter *iter);
int dbus_message_iter_get_arg_type (DBusMessageIter *iter);
int dbus_message_iter_get_element_type (DBusMessageIter *iter);
void dbus_message_iter_recurse (DBusMessageIter *iter,
DBusMessageIter *sub);
void dbus_message_iter_get_basic (DBusMessageIter *iter,
void *value);
+int dbus_message_iter_get_array_len (DBusMessageIter *iter);
void dbus_message_iter_get_fixed_array (DBusMessageIter *iter,
void *value,
int *n_elements);
return _dbus_first_type_in_signature_c_str (real_iter->pos, 0);
}
+/**
+ * Returns the full type signature represented by the current
+ * iterator as a C string.
+ *
+ * @param iter pointer to an iterator
+ * @returns current signature; or NULL on OOM. Should be freed with #dbus_free
+ */
+char *
+dbus_signature_iter_get_signature (const DBusSignatureIter *iter)
+{
+ DBusSignatureRealIter *real_iter = (DBusSignatureRealIter *) iter;
+ DBusString str;
+ char *ret;
+ int pos;
+
+ if (!_dbus_string_init (&str))
+ return NULL;
+
+ pos = 0;
+ _dbus_type_signature_next (real_iter->pos, &pos);
+
+ if (!_dbus_string_append_len (&str, real_iter->pos, pos))
+ return NULL;
+ if (!_dbus_string_steal_data (&str, &ret))
+ ret = NULL;
+ _dbus_string_free (&str);
+
+ return ret;
+}
+
/**
* Convenience function for returning the element type of an array;
* This function allows you to avoid initializing a sub-iterator and
int dbus_signature_iter_get_current_type (const DBusSignatureIter *iter);
+char * dbus_signature_iter_get_signature (const DBusSignatureIter *iter);
+
int dbus_signature_iter_get_element_type (const DBusSignatureIter *iter);
dbus_bool_t dbus_signature_iter_next (DBusSignatureIter *iter);