libsysprof-analyze: add format helper

This commit is contained in:
Christian Hergert
2023-07-05 17:53:44 -07:00
parent d865a0ed99
commit 68cda70138
2 changed files with 18 additions and 5 deletions

View File

@ -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);
}

View File

@ -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