Difference between revisions of "Truxton event get media id"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This retrieves the identifier of the media this event belongs to. This corresponds to the <code>[MediaID]</code> column of the <code><nowiki>[</nowiki>Event<no...")
 
Line 19: Line 19:
 
=Sample=
 
=Sample=
 
<source lang="C" highlight="8">
 
<source lang="C" highlight="8">
void dump_event(uint64_t event_handle)
+
void dump_event( uint64_t event_handle )
 
{
 
{
 
   char temp_string[ 256 ];
 
   char temp_string[ 256 ];
Line 48: Line 48:
 
}
 
}
 
</source>
 
</source>
 +
 +
The <code>PRIu64</code> in the sample code above is a standard way of [https://en.wikipedia.org/wiki/C_data_types#Printf_and_scanf_format_specifiers formatting] a 64-bit unsigned integer in C.
 +
Over the years, different compilers on different operating systems used different format specifiers for things, these <code>PRI</code> macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.

Revision as of 07:18, 6 February 2021

This retrieves the identifier of the media this event belongs to. This corresponds to the [MediaID] column of the [Event] table.

Syntax

void truxton_event_get_media_id( uint64_t event_handle, char * destination_string, size_t max_size );

Parameters

event_handle

The handle to an event created by the truxton_event_create call.

destination_string

The string to be written to.

max_size

The maximum number of characters that can be written to destination_string.

Sample

void dump_event( uint64_t event_handle )
{
   char temp_string[ 256 ];

   truxton_event_get_file_id( event_handle, temp_string, sizeof(temp_string) );
   printf( "File ID is %s\n", temp_string);

   truxton_event_get_media_id( event_handle, temp_string, sizeof(temp_string) );
   printf( "Media ID is %s\n", temp_string);

   truxton_event_get_id( event_handle, temp_string, sizeof(temp_string) );
   printf( "Event ID is %s\n", temp_string);

   truxton_event_get_title( event_handle, temp_string, sizeof(temp_string) );
   printf( "Title is %s\n", temp_string);

   truxton_event_get_description( event_handle, temp_string, sizeof(temp_string) );
   printf( "Description is %s\n", temp_string);

   uint64_t value = truxton_event_get_type( event_handle );
   printf( "Type is %" PRIu64 "\n", value );

   value = truxton_event_get_start( event_handle );
   printf( "Start is %" PRIu64 "\n", value );

   value = truxton_event_get_end( event_handle );
   printf( "End is %" PRIu64 "\n", value );
}

The PRIu64 in the sample code above is a standard way of formatting a 64-bit unsigned integer in C. Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.