Truxton artifact tag

From truxwiki.com
Revision as of 07:21, 11 February 2021 by Sam (talk | contribs) (→‎Sample)
Jump to navigation Jump to search

This will tag the artifact. You can only tag an artifact after truxton_artifact_save() has been called. This will cause a record to be created in the [Tagged] table.

Syntax

void truxton_artifact_tag( uint64_t child_handle, char const * tag_name, char const * why, uint64_t origin );

Parameters

child_handle

The handle created by calling truxton_artifact_create().

tag_name

The small bit of text that will serve as the tag. This will show up in the user interface. This parameter must match one of the values in the [Name] column of the [Tag] table. You can create tags using the truxton_create_tag API.

why

The reason why this item was tagged.

origin

What produced this tag. If an algorithm produced this tag, it should be set to 1. If you are calling this method because a human told you to, the value should be 2.

Sample

void create_artifact( void )
{
   uint64_t truxton = truxton_create();

   uint64_t artifact = truxton_artifact_create( truxton );

   truxton_artifact_set_name( artifact, "Ducky Momo Server" );

   // Commit the data to the database 
   if ( truxton_artifact_save( artifact ) == 0 )
   {
      printf( "Cannot save data to the database.\n" );
   }
   else
   {
      char id[ 65 ];

      truxton_artifact_get_id( artifact, id, sizeof( id ) );

      printf( "Artifact ID is %s\n", id );

      truxton_artifact_tag( artifact, "Mine", "I found it", TAG_ORIGIN_AUTOMATIC );
   }

   truxton_artifact_destroy( artifact );
   truxton_destroy( truxton );
}