Truxton relation get source type
This retrieves the type of object of the source of the relation.
This corresponds to the [SourceObjectTypeID] column of the [Relation] table.
Syntax
uint64_t truxton_relation_get_source_type( uint64_t relation_handle );
Parameters
relation_handle
This handle comes from calling truxton_relation_create()
Return value
The type of the object as stored in the [SourceObjectTypeID] column in the [Relation] table.
It should also be one of the defined constants values and present in the [ID] column of the [ObjectType] reference table in the database.
Sample
void dump_relation(uint64_t relation_handle)
{
uint64_t value = 0;
char guid_string[ 65 ];
value = truxton_relation_get_a_type( relation_handle );
truxton_relation_get_a_id( relation_handle, guid_string, sizeof( guid_string ) );
printf( "A (%" PRIu64 ") %s is a ", value, guid_string );
value = truxton_relation_get_relation( relation_handle );
printf( "%" PRIu64 " of ", value );
value = truxton_relation_get_b_type( relation_handle );
truxton_relation_get_b_id( relation_handle, guid_string, sizeof( guid_string ) );
printf( "B (%" PRIu64 ") %s is a ", value, guid_string );
value = truxton_relation_get_source_type( relation_handle );
truxton_relation_get_source_id( relation_handle, guid_string, sizeof( guid_string ) );
printf( "Source (%" PRIu64 ") is %s\n", value, guid_string );
}
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.