Truxton delete artifact type

From truxwiki.com
Jump to navigation Jump to search

This deletes an artifact type.

Syntax

void truxton_delete_artifact_type( uint64_t truxton_handle, uint64_t artifact_type_id );

Parameters

truxton_handle

The Truxton instance where this artifact type exists. This handle comes from calling truxton_create().

artifact_type_id

The integer value of the artifact type.

Remarks

This will delete the artifact type from the [EntityType] table in the database.

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_delete_artifact_type( truxton, 21212 );
   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.