Truxton options exists

From truxwiki.com
Jump to navigation Jump to search

Determines if a value exists in the options.

Syntax

int64_t truxton_options_exists( uint64_t options_handle, char const * name );

Parameters

options_handle

The handle to the options object created by calling the truxton_options_create function.

name

The name of the option to test for.

Return value

Zero if the value is no where to be found in the options. One is returned if the named option was found.

Remarks

It is not possible for truxton_options_get_boolean() to tell you if a false value was specified by the user or the default value of false was used. This method will tell you if the named setting exists anywhere in Truxton.

Sample

void process_free( void )
{
   uint64_t options = truxton_options_create();

   if ( truxton_options_exists( "pfree" ) == 1 )
   {
      if ( truxton_options_get_boolean( "pfree" ) == 1 )
      {
         printf( "Yes, we will process free space\n" );
      }
      else
      {
         printf( "No, we will not process free space\n" );
      }
   }
   else
   {
      printf( "The user did not specify the pfree option, we will assume they do not want to process free space.\n" );
   }

   truxton_options_destroy( options );
}