Changeset 364


Ignore:
Timestamp:
1999-07-11T13:02:13+12:00 (25 years ago)
Author:
rjmcnab
Message:

Stored information relating to the cgi argument's origin with the cgi argument.

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/cgiargs.cpp

    r154 r364  
    1212/*
    1313   $Log$
     14   Revision 1.6  1999/07/11 01:02:13  rjmcnab
     15   Stored information relating to the cgi argument's origin with the cgi argument.
     16
    1417   Revision 1.5  1999/02/08 01:28:00  rjmcnab
     18
    1519   Got the receptionist producing something using the statusaction.
    1620
     
    4246#include "gsdlunicode.h"
    4347
    44  
     48
     49
     50void cgiarg_t::clear () {
     51  value.clear();
     52  source = program_arg;
     53}
     54
     55cgiarg_t &cgiarg_t::operator=(const cgiarg_t &x) {
     56  value=x.value;
     57  source=x.source;
     58  return *this;
     59}
     60
     61
     62
     63
    4564// constructors
    4665cgiargsclass::cgiargsclass () {
     
    5170// 'key' already defined
    5271
    53 void cgiargsclass::setarg (const text_t &key, const text_t &value)
    54 {
    55   args[key] = value;
    56 }
    57 
    58 void cgiargsclass::setdefaultarg (const text_t &key, const text_t &value)
    59 {
    60   if (getarg(key) == NULL) setarg (key, value);
    61 }
    62 
    63 void cgiargsclass::setintarg (const text_t &key, int value)
    64 {
    65   setarg (key, value);
    66 }
    67 
    68 void cgiargsclass::setdefaultintarg (const text_t &key, int value)
    69 {
    70   if (getarg(key) == NULL) setintarg (key, value);
    71 }
    72 
    73 void cgiargsclass::setcarg (const text_t &key, unsigned short c)
    74 {
     72void cgiargsclass::setarg (const text_t &key, const text_t &value,
     73               cgiarg_t::source_t source) {
     74  cgiarg_t temparg;
     75  temparg.value = value;
     76  temparg.source = source;
     77  args[key] = temparg;
     78}
     79
     80void cgiargsclass::setdefaultarg (const text_t &key, const text_t &value,
     81                  cgiarg_t::source_t source) {
     82  if (getarg(key) == NULL) setarg (key, value, source);
     83}
     84
     85void cgiargsclass::setintarg (const text_t &key, int value,
     86                  cgiarg_t::source_t source) {
     87  setarg (key, value, source);
     88}
     89
     90void cgiargsclass::setdefaultintarg (const text_t &key, int value,
     91                     cgiarg_t::source_t source) {
     92  if (getarg(key) == NULL) setintarg (key, value, source);
     93}
     94
     95void cgiargsclass::setcarg (const text_t &key, unsigned short c,
     96                cgiarg_t::source_t source) {
    7597  text_t t;
    7698  t.push_back(c);
    77   setarg(key,t);
    78 }
    79 
    80 void cgiargsclass::setdefaultcarg (const text_t &key, unsigned short c)
    81 {
    82   if (getarg(key) == NULL) setcarg (key, c);
    83 }
    84 
    85 text_t *cgiargsclass::getarg (const text_t &key)
    86 {
     99  setarg(key,t, source);
     100}
     101
     102void cgiargsclass::setdefaultcarg (const text_t &key, unsigned short c,
     103                   cgiarg_t::source_t source) {
     104  if (getarg(key) == NULL) setcarg (key, c, source);
     105}
     106
     107text_t *cgiargsclass::getarg (const text_t &key) {
    87108  iterator here = args.find (key);
    88109  if (here == args.end()) return NULL;
    89110
    90   return &((*here).second);
    91 }
    92 
    93 int cgiargsclass::getintarg (const text_t &key)
    94 {
     111  return &((*here).second.value);
     112}
     113
     114int cgiargsclass::getintarg (const text_t &key) {
    95115  text_t *text = getarg (key);
    96116  if (text == NULL) return 0;
     
    101121
    102122// stream operators to print cgi arguments for debugging purposes
    103 ostream &operator<<(ostream &outs, const cgiargsclass &args)
    104 {
     123ostream &operator<<(ostream &outs, const cgiargsclass &args) {
    105124  utf8outconvertclass text_t2utf8;
    106125  cgiargsclass::const_iterator here = args.begin ();
     
    109128  outs << "*** cgiargsclass\n";
    110129 
    111   while (here != end)
    112     {
    113       outs << text_t2utf8 << " \"" << (*here).first << "\"=\"" <<
    114     (*here).second << "\"\n";
    115       here++;
    116     }
     130  while (here != end) {
     131    outs << text_t2utf8 << " \"" << (*here).first << "\"=\"" <<
     132      (*here).second.value << "\"\n";
     133    here++;
     134  }
    117135  outs << "\n";
    118136
  • trunk/gsdl/src/recpt/cgiargs.h

    r154 r364  
    3939
    4040
    41 typedef map<text_t, text_t, lttext_t> textmap;
     41struct cgiarg_t {
     42  void clear ();
     43  cgiarg_t () {clear();}
     44  cgiarg_t &operator=(const cgiarg_t &x);
     45 
     46  enum source_t {default_arg, compressed_arg, cgi_arg, program_arg};
     47 
     48  text_t value;
     49  source_t source;
     50};
     51
     52typedef map<text_t, cgiarg_t, lttext_t> cgiarg_tmap;
    4253
    4354// cgiargsclass is used to store a particular set
    4455// of cgi arguments.
    45 class cgiargsclass
    46 {
     56class cgiargsclass {
    4757protected:
    48   textmap args;
     58  cgiarg_tmap args;
    4959
    5060public:
    51   //type support for textmap
    52   typedef textmap::iterator iterator;
    53   typedef textmap::const_iterator const_iterator;
    54   typedef textmap::reference reference;
    55   typedef textmap::const_reference const_reference;
    56   typedef textmap::size_type size_type;
    57   typedef textmap::difference_type difference_type;
    58   typedef textmap::const_reverse_iterator const_reverse_iterator;
    59   typedef textmap::reverse_iterator reverse_iterator;
     61  //type support for cgiarg_tmap
     62  typedef cgiarg_tmap::iterator iterator;
     63  typedef cgiarg_tmap::const_iterator const_iterator;
     64  typedef cgiarg_tmap::reference reference;
     65  typedef cgiarg_tmap::const_reference const_reference;
     66  typedef cgiarg_tmap::size_type size_type;
     67  typedef cgiarg_tmap::difference_type difference_type;
     68  typedef cgiarg_tmap::const_reverse_iterator const_reverse_iterator;
     69  typedef cgiarg_tmap::reverse_iterator reverse_iterator;
    6070 
    6171  // constructors
     
    8595  // entry with 'key' defined and operator[] returns "" if
    8696  // 'key' wasn't already defined (and sets 'key'="").
    87   void setarg (const text_t &key, const text_t &value);
    88   void setdefaultarg (const text_t &key, const text_t &value);
    89   void setintarg (const text_t &key, int value);
    90   void setdefaultintarg (const text_t &key, int value);
    91   void setcarg (const text_t &key, unsigned short c);
    92   void setdefaultcarg (const text_t &key, unsigned short c);
     97  void setarg (const text_t &key, const text_t &value,
     98           cgiarg_t::source_t source=cgiarg_t::program_arg);
     99  void setdefaultarg (const text_t &key, const text_t &value,
     100              cgiarg_t::source_t source=cgiarg_t::default_arg);
     101  void setintarg (const text_t &key, int value,
     102          cgiarg_t::source_t source=cgiarg_t::program_arg);
     103  void setdefaultintarg (const text_t &key, int value,
     104             cgiarg_t::source_t source=cgiarg_t::default_arg);
     105  void setcarg (const text_t &key, unsigned short c,
     106        cgiarg_t::source_t source=cgiarg_t::program_arg);
     107  void setdefaultcarg (const text_t &key, unsigned short c,
     108               cgiarg_t::source_t source=cgiarg_t::default_arg);
    93109  text_t *getarg (const text_t &key);
    94110  int getintarg (const text_t &key);
    95   text_t &operator[] (const text_t &key) {return args[key];}
     111  text_t &operator[] (const text_t &key) {return args[key].value;}
     112  cgiarg_t &lookupcgiarg (const text_t &key) {return args[key];}
    96113};
    97114
Note: See TracChangeset for help on using the changeset viewer.