source: trunk/gsdl/src/library/cgiargs.h@ 4

Last change on this file since 4 was 4, checked in by sjboddie, 25 years ago

Initial revision

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1#ifndef CGIARGS_H
2#define CGIARGS_H
3
4
5#ifdef __GNUG__
6# include <ostream.h>
7#else
8# ifndef USE_OBJECTSPACE
9# include <ostream>
10# else
11# include <ospace\std\ostream>
12# endif
13#endif
14
15#ifndef USE_OBJECTSPACE
16# include <map>
17#else
18# include <ospace\std\map>
19#endif
20
21
22#include "text_t.h"
23
24typedef map<text_t, text_t, lttext_t> textmap;
25
26
27class cgiargsclass
28{
29protected:
30 textmap args;
31
32public:
33 //type support for textmap
34 typedef textmap::iterator iterator;
35 typedef textmap::const_iterator const_iterator;
36 typedef textmap::reference reference;
37 typedef textmap::const_reference const_reference;
38 typedef textmap::size_type size_type;
39 typedef textmap::difference_type difference_type;
40 typedef textmap::const_reverse_iterator const_reverse_iterator;
41 typedef textmap::reverse_iterator reverse_iterator;
42
43 // constructors
44 cgiargsclass ();
45
46 // basic container support
47 iterator begin () {return args.begin();}
48 const_iterator begin () const {return args.begin();}
49 iterator end () {return args.end();}
50 const_iterator end () const {return args.end();}
51
52 void erase(iterator pos) {args.erase(pos);}
53 void erase(iterator first, iterator last) {args.erase(first, last);}
54 cgiargsclass &operator=(const cgiargsclass &x) {args=x.args;return *this;}
55
56 bool empty () const {return args.empty();}
57 size_type size() const {return args.size();}
58
59
60 // added functionality
61 void clear () {args.erase(args.begin(),args.end());}
62
63 // setdefaultarg, setdefaultintarg, and setdefaultcarg will
64 // only set the argument if it is not already set
65 // getargs NULLs if there isn't an entry with
66 // 'key' already defined, getintarg returns 0 if there wasn't an
67 // entry with 'key' defined and operator[] returns "" if
68 // 'key' wasn't already defined (and sets 'key'="").
69 void setarg (const text_t &key, const text_t &value);
70 void setdefaultarg (const text_t &key, const text_t &value);
71 void setintarg (const text_t &key, int value);
72 void setdefaultintarg (const text_t &key, int value);
73 void setcarg (const text_t &key, unsigned short c);
74 void setdefaultcarg (const text_t &key, unsigned short c);
75 text_t *getarg (const text_t &key);
76 int getintarg (const text_t &key);
77 text_t &operator[] (const text_t &key) {return args[key];}
78};
79
80
81// stream operators to print cgi arguments for debugging purposes
82ostream &operator<<(ostream &outs, const cgiargsclass &args);
83
84
85#endif
Note: See TracBrowser for help on using the repository browser.