lib/cgi/cgi-args.h
changeset 0 6f7a81934006
child 2 b3afb9f1e801
equal deleted inserted replaced
-1:000000000000 0:6f7a81934006
       
     1 #ifndef CHECKVPW__CGI_ARGS__H__
       
     2 #define CHECKVPW__CGI_ARGS__H__
       
     3 
       
     4 #include "mystring/mystring.h"
       
     5 
       
     6 class CGIArgs 
       
     7 {
       
     8 private:
       
     9   struct arg
       
    10   {
       
    11     arg* next;
       
    12     const mystring var;
       
    13     const mystring val;
       
    14     arg(mystring r, mystring l)
       
    15       : next(0), var(r), val(l)
       
    16       {
       
    17       }
       
    18     ~arg()
       
    19       {
       
    20 	delete next;
       
    21       }
       
    22   };
       
    23   arg* head;
       
    24   arg* tail;
       
    25   unsigned argc;
       
    26   mystring errstr;
       
    27 protected:
       
    28   void init();
       
    29   void append(mystring, mystring);
       
    30 public:
       
    31   CGIArgs() : head(0), tail(0), argc(0)
       
    32     {
       
    33       init();
       
    34     }
       
    35   ~CGIArgs();
       
    36   bool error() const 
       
    37     {
       
    38       return !errstr.empty();
       
    39     }
       
    40   mystring errorstr() const
       
    41     {
       
    42       return errstr;
       
    43     }
       
    44   bool exists(mystring) const;
       
    45   mystring get(mystring var, mystring dflt = 0) const;
       
    46   mystring operator[](mystring var) const
       
    47     {
       
    48       return get(var);
       
    49     }
       
    50 };
       
    51 
       
    52 #endif