Truxton artifact type get short name
Jump to navigation
Jump to search
This retrieves the short name of an artifact type.
This corresponds to the [ShortName] column of the [EntityType] table in the database.
Contents
Syntax
void truxton_artifact_type_get_short_name( uint64_t artifact_type_handle, char * destination_string, size_t max_size );
Parameters
artifact_type_handle
The handle to the object created by the truxton_artifact_type_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 create_artifact_type( void )
{
uint64_t truxton = truxton_create();
uint64_t artifact_type = truxton_artifact_type_create( truxton );
truxton_artifact_type_set_id( artifact_type, 21212 );
truxton_artifact_type_set_short_name( artifact_type, "VIN" );
truxton_artifact_type_set_long_name( artifact_type, "Vehicle Identification Number" );
if ( truxton_artifact_type_save( artifact_type ) == 0 )
{
printf("Cannot save artifact type to the database.\n" );
}
else
{
char type_name[ 128 ];
char description[ 128 ];
uint64_t new_id = truxton_artifact_type_get_id( artifact_type );
truxton_artifact_type_get_short_name( artifact_type, type_name, sizeof( type_name ) );
truxton_artifact_type_get_long_name( artifact_type, description, sizeof( description ) );
printf( "Created artifact type id %" PRIu64 " for %s - %s\n", new_id, type_name, description );
}
truxton_artifact_type_destroy( artifact_type );
truxton_destroy( truxton );
}
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.