1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * cgiargs.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: cgiargs.cpp 105 1999-01-08 07:50:31Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.1 1999/01/08 07:50:30 rjmcnab
|
---|
15 |
|
---|
16 | Moved from src/library directory to lib directory.
|
---|
17 |
|
---|
18 | */
|
---|
19 |
|
---|
20 | static char *RCSID = "$Id: cgiargs.cpp 105 1999-01-08 07:50:31Z rjmcnab $";
|
---|
21 |
|
---|
22 |
|
---|
23 | #include "cgiargs.h"
|
---|
24 | #include "gsdlunicode.h"
|
---|
25 |
|
---|
26 |
|
---|
27 | // constructors
|
---|
28 | cgiargsclass::cgiargsclass ()
|
---|
29 | {
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 | // this returns NULL if there isn't an entry with a value of
|
---|
34 | // 'key' already defined
|
---|
35 |
|
---|
36 | void cgiargsclass::setarg (const text_t &key, const text_t &value)
|
---|
37 | {
|
---|
38 | args[key] = value;
|
---|
39 | }
|
---|
40 |
|
---|
41 | void cgiargsclass::setdefaultarg (const text_t &key, const text_t &value)
|
---|
42 | {
|
---|
43 | if (getarg(key) == NULL) setarg (key, value);
|
---|
44 | }
|
---|
45 |
|
---|
46 | void cgiargsclass::setintarg (const text_t &key, int value)
|
---|
47 | {
|
---|
48 | setarg (key, value);
|
---|
49 | }
|
---|
50 |
|
---|
51 | void cgiargsclass::setdefaultintarg (const text_t &key, int value)
|
---|
52 | {
|
---|
53 | if (getarg(key) == NULL) setintarg (key, value);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void cgiargsclass::setcarg (const text_t &key, unsigned short c)
|
---|
57 | {
|
---|
58 | text_t t;
|
---|
59 | t.push_back(c);
|
---|
60 | setarg(key,t);
|
---|
61 | }
|
---|
62 |
|
---|
63 | void cgiargsclass::setdefaultcarg (const text_t &key, unsigned short c)
|
---|
64 | {
|
---|
65 | if (getarg(key) == NULL) setcarg (key, c);
|
---|
66 | }
|
---|
67 |
|
---|
68 | text_t *cgiargsclass::getarg (const text_t &key)
|
---|
69 | {
|
---|
70 | iterator here = args.find (key);
|
---|
71 | if (here == args.end()) return NULL;
|
---|
72 |
|
---|
73 | return &((*here).second);
|
---|
74 | }
|
---|
75 |
|
---|
76 | int cgiargsclass::getintarg (const text_t &key)
|
---|
77 | {
|
---|
78 | text_t *text = getarg (key);
|
---|
79 | if (text == NULL) return 0;
|
---|
80 | return text->getint();
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | // stream operators to print cgi arguments for debugging purposes
|
---|
86 | ostream &operator<<(ostream &outs, const cgiargsclass &args)
|
---|
87 | {
|
---|
88 | utf8outconvertclass text_t2utf8;
|
---|
89 | cgiargsclass::const_iterator here = args.begin ();
|
---|
90 | cgiargsclass::const_iterator end = args.end ();
|
---|
91 |
|
---|
92 | outs << "*** cgiargsclass\n";
|
---|
93 |
|
---|
94 | while (here != end)
|
---|
95 | {
|
---|
96 | outs << text_t2utf8 << " \"" << (*here).first << "\"=\"" <<
|
---|
97 | (*here).second << "\"\n";
|
---|
98 | here++;
|
---|
99 | }
|
---|
100 | outs << "\n";
|
---|
101 |
|
---|
102 | return outs;
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|