Changeset 364
- Timestamp:
- 1999-07-11T13:02:13+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/cgiargs.cpp
r154 r364 12 12 /* 13 13 $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 14 17 Revision 1.5 1999/02/08 01:28:00 rjmcnab 18 15 19 Got the receptionist producing something using the statusaction. 16 20 … … 42 46 #include "gsdlunicode.h" 43 47 44 48 49 50 void cgiarg_t::clear () { 51 value.clear(); 52 source = program_arg; 53 } 54 55 cgiarg_t &cgiarg_t::operator=(const cgiarg_t &x) { 56 value=x.value; 57 source=x.source; 58 return *this; 59 } 60 61 62 63 45 64 // constructors 46 65 cgiargsclass::cgiargsclass () { … … 51 70 // 'key' already defined 52 71 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 { 72 void 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 80 void 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 85 void cgiargsclass::setintarg (const text_t &key, int value, 86 cgiarg_t::source_t source) { 87 setarg (key, value, source); 88 } 89 90 void 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 95 void cgiargsclass::setcarg (const text_t &key, unsigned short c, 96 cgiarg_t::source_t source) { 75 97 text_t t; 76 98 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 102 void 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 107 text_t *cgiargsclass::getarg (const text_t &key) { 87 108 iterator here = args.find (key); 88 109 if (here == args.end()) return NULL; 89 110 90 return &((*here).second); 91 } 92 93 int cgiargsclass::getintarg (const text_t &key) 94 { 111 return &((*here).second.value); 112 } 113 114 int cgiargsclass::getintarg (const text_t &key) { 95 115 text_t *text = getarg (key); 96 116 if (text == NULL) return 0; … … 101 121 102 122 // stream operators to print cgi arguments for debugging purposes 103 ostream &operator<<(ostream &outs, const cgiargsclass &args) 104 { 123 ostream &operator<<(ostream &outs, const cgiargsclass &args) { 105 124 utf8outconvertclass text_t2utf8; 106 125 cgiargsclass::const_iterator here = args.begin (); … … 109 128 outs << "*** cgiargsclass\n"; 110 129 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 } 117 135 outs << "\n"; 118 136 -
trunk/gsdl/src/recpt/cgiargs.h
r154 r364 39 39 40 40 41 typedef map<text_t, text_t, lttext_t> textmap; 41 struct 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 52 typedef map<text_t, cgiarg_t, lttext_t> cgiarg_tmap; 42 53 43 54 // cgiargsclass is used to store a particular set 44 55 // of cgi arguments. 45 class cgiargsclass 46 { 56 class cgiargsclass { 47 57 protected: 48 textmap args;58 cgiarg_tmap args; 49 59 50 60 public: 51 //type support for textmap52 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; 60 70 61 71 // constructors … … 85 95 // entry with 'key' defined and operator[] returns "" if 86 96 // '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); 93 109 text_t *getarg (const text_t &key); 94 110 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];} 96 113 }; 97 114
Note:
See TracChangeset
for help on using the changeset viewer.