Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseargs.hfa

    r481f882 rd1abc63c  
    1616#pragma once
    1717
     18#include <array.hfa>
     19
    1820struct cfa_option {
    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 * );
     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 * );
    2527};
    2628
     
    3133forall(T & | { bool parse(const char *, T & ); })
    3234static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable ) {
    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;
     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;
    3941}
    4042
    4143forall(T &)
    4244static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable, bool (*parse)(const char *, T & )) {
    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;
     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;
    4951}
    5052
     
    5254void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left );
    5355
     56forall( [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
    5461void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
    5562void print_args_usage(int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
     63
     64forall( [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}
    5668
    5769bool parse_yesno    (const char *, bool & );
Note: See TracChangeset for help on using the changeset viewer.