diff --git a/src/libsysprof-analyze/sysprof-document-counter-value.c b/src/libsysprof-analyze/sysprof-document-counter-value.c index 4fb9bf95..c374aba9 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-value.c +++ b/src/libsysprof-analyze/sysprof-document-counter-value.c @@ -151,3 +151,14 @@ sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *se else return (double)self->value.v_int64; } + +char * +sysprof_document_counter_value_format (SysprofDocumentCounterValue *self) +{ + g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER_VALUE (self), NULL); + + if (self->type == SYSPROF_CAPTURE_COUNTER_DOUBLE) + return g_strdup_printf ("%lf", self->value.v_double); + else + return g_strdup_printf ("%ld", self->value.v_int64); +} diff --git a/src/libsysprof-analyze/sysprof-document-counter-value.h b/src/libsysprof-analyze/sysprof-document-counter-value.h index d780baf8..6f7cfee4 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-value.h +++ b/src/libsysprof-analyze/sysprof-document-counter-value.h @@ -32,14 +32,16 @@ SYSPROF_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (SysprofDocumentCounterValue, sysprof_document_counter_value, SYSPROF, DOCUMENT_COUNTER_VALUE, GObject) SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self); +gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self, - GValue *value); +void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self, + GValue *value); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self); +gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self); SYSPROF_AVAILABLE_IN_ALL -double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self); +double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self); +SYSPROF_AVAILABLE_IN_ALL +char *sysprof_document_counter_value_format (SysprofDocumentCounterValue *self); G_END_DECLS