Difference between revisions of "Truxton artifact save"

From truxwiki.com
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
This saves an artifact object.
 
This saves an artifact object.
 
The data in the artifact object will be written to the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table in the database.
 
The data in the artifact object will be written to the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table in the database.
 +
This will cause a record to be created in the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
  
 
=Syntax=
 
=Syntax=
 
<source lang="C">
 
<source lang="C">
int truxton_artifact_save(uint64_t artifact_handle);
+
int truxton_artifact_save( uint64_t artifact_handle );
 
</source>
 
</source>
  
Line 16: Line 17:
  
 
=Sample=
 
=Sample=
<source lang="C" highlight="8">
+
<source lang="C" highlight="10">
void create_artifact(void)
+
void create_artifact( void )
 
{
 
{
 
   uint64_t truxton = truxton_create();
 
   uint64_t truxton = truxton_create();
  
   uint64_t artifact= truxton_artifact_create(truxton);
+
   uint64_t artifact = truxton_artifact_create( truxton );
  
 
   truxton_artifact_set_name( artifact, "Ducky Momo Server" );
 
   truxton_artifact_set_name( artifact, "Ducky Momo Server" );
  truxton_artifact_save( artifact);
 
  truxton_artifact_tag( artifact, "Too Young", "Yes, yes I am", 1 );
 
  
   char id[ 65 ];
+
   // Commit the data to the database
 +
  if ( truxton_artifact_save( artifact ) == 0 )
 +
  {
 +
      printf( "Cannot save data to the database.\n" );
 +
  }
 +
  else
 +
  {
 +
      truxton_artifact_tag( artifact, "Too Young", "Yes, yes I am", 1 );
  
  truxton_artifact_get_id( artifact, id, sizeof( id ) );
+
      char id[ 65 ];
  
  printf( "Artifact ID is %s\n", id );
+
      truxton_artifact_get_id( artifact, id, sizeof( id ) );
  
   truxton_artifact_destroy(media);
+
      printf( "Artifact ID is %s\n", id );
   truxton_destroy(truxton);
+
  }
 +
 
 +
   truxton_artifact_destroy( artifact );
 +
   truxton_destroy( truxton );
 
}
 
}
 
</source>
 
</source>

Latest revision as of 07:52, 6 February 2021

This saves an artifact object. The data in the artifact object will be written to the [Entity] table in the database. This will cause a record to be created in the [Entity] table.

Syntax

int truxton_artifact_save( uint64_t artifact_handle );

Parameters

artifact_handle

The artifact instance. This handle comes from calling truxton_artifact_create().

Return value

A non-zero value on success, zero on failure.

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
   {
      truxton_artifact_tag( artifact, "Too Young", "Yes, yes I am", 1 );

      char id[ 65 ];

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

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

   truxton_artifact_destroy( artifact );
   truxton_destroy( truxton );
}