Go to the documentation of this file.00001 #include "options.h"
00002
00003
00004
00005 struct params {
00006 int a_int;
00007 double a_double;
00008 const char * file;
00009 int algo;
00010 };
00011
00012
00013 struct option_alternative alt[4] = {
00014 {"PLICP", 3, "a new algorithm"},
00015 {"ICP", 4, "the standard"},
00016 {"MbICP", 5, "good for rotations"}, {0,0,0}
00017 };
00018
00019 int main(int argc, const char*argv[]) {
00020 options_banner("This is a test program for the options library.");
00021
00022 struct params p;
00023
00024 struct option* ops = options_allocate(3);
00025 options_int (ops, "i", &p.a_int, 42, "An int parameter");
00026 options_double (ops, "d", &p.a_double, 0.42, "A double parameter");
00027 options_string (ops, "s", &p.file , "Hello", "A file parameter");
00028 options_alternative(ops, "algorith", alt, &p.algo, "which algorithm to use" );
00029
00030
00031 if(!options_parse_args(ops, argc, argv)) {
00032 printf("A simple program.\n\nUsage:\n");
00033 options_print_help(ops, stderr);
00034 return -1;
00035 }
00036
00037 printf("i: %d \n", p.a_int);
00038 printf("d: %g \n", p.a_double);
00039 printf("s: %s \n", p.file);
00040
00041 return 0;
00042 }