Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseargs.hfa

    rd1abc63c r481f882  
    1616#pragma once
    1717
    18 #include <array.hfa>
    19 
    2018struct cfa_option {
    21         int val; // reserved
    22         char short_name;
    23         const char * long_name;
    24         const char * help;
    25         void * variable;
    26         bool (*parse)(const char *, void * );
     19      int val; // reserved
     20      char short_name;
     21      const char * long_name;
     22      const char * help;
     23      void * variable;
     24      bool (*parse)(const char *, void * );
    2725};
    2826
     
    3331forall(T & | { bool parse(const char *, T & ); })
    3432static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable ) {
    35         this.val        = 0;
    36         this.short_name = short_name;
    37         this.long_name  = long_name;
    38         this.help       = help;
    39         this.variable   = (void*)&variable;
    40         this.parse      = (bool (*)(const char *, void * ))parse;
     33      this.val        = 0;
     34      this.short_name = short_name;
     35      this.long_name  = long_name;
     36      this.help       = help;
     37      this.variable   = (void*)&variable;
     38      this.parse      = (bool (*)(const char *, void * ))parse;
    4139}
    4240
    4341forall(T &)
    4442static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable, bool (*parse)(const char *, T & )) {
    45         this.val        = 0;
    46         this.short_name = short_name;
    47         this.long_name  = long_name;
    48         this.help       = help;
    49         this.variable   = (void*)&variable;
    50         this.parse      = (bool (*)(const char *, void * ))parse;
     43      this.val        = 0;
     44      this.short_name = short_name;
     45      this.long_name  = long_name;
     46      this.help       = help;
     47      this.variable   = (void*)&variable;
     48      this.parse      = (bool (*)(const char *, void * ))parse;
    5149}
    5250
     
    5452void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left );
    5553
    56 forall( [N] ) {
    57         void parse_args( const array( cfa_option, N ) & options, const char * usage, char ** & left );
    58         void parse_args( int argc, char * argv[], const array( cfa_option, N ) & options, const char * usage, char ** & left );
    59 }
    60 
    6154void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
    6255void print_args_usage(int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
    63 
    64 forall( [N] ) {
    65         void print_args_usage( const array(cfa_option, N ) & options, const char * usage, bool error)  __attribute__ ((noreturn));
    66         void print_args_usage(int argc, char * argv[], const array( cfa_option, N ) & options, const char * usage, bool error)  __attribute__ ((noreturn));
    67 }
    6856
    6957bool parse_yesno    (const char *, bool & );
Note: See TracChangeset for help on using the changeset viewer.