source: trunk/gsdl/lib/cgiargs.h@ 105

Last change on this file since 105 was 105, checked in by rjmcnab, 25 years ago

Moved from src/library directory to lib directory.

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