summaryrefslogtreecommitdiffabout
path: root/include/kingate/cgi_interface.h
blob: 84ea6dd532c858011a938d146981934cfd01a319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __KINGATE_CGI_INTERFACE_H
#define __KINGATE_CGI_INTERFACE_H

#include <iostream>
#include <string>
#include <map>

/**
 * @file
 * @brief the abstract base for various interfaces to CGI.
 */

namespace kingate {
    using namespace std;

    /**
     * The abstract base class for interface to CGI subsystem.
     */
    class cgi_interface {
	public:
	    /**
	     * The type for map holding 'environment' meta-variables.
	     */
	    typedef map<string,string> metavars_t;
	    /**
	     * The environment variables.
	     */
	    metavars_t metavars;

	    cgi_interface() { }
	    virtual ~cgi_interface() { }

	    /**
	     * Check to see whether there is a particular 'environment'
	     * meta-variable passed.
	     * @param n the variable name.
	     * @return true if yes.
	     */
	    bool has_meta(const string& n) const;
	    /**
	     * Retrieve the 'environment' variable.
	     * @param n the variable name.
	     * @return the variable contents.
	     * @see exception_notfound
	     */
	    const string& get_meta(const string& n) const;

	    /**
	     * Fetch reference to CGI 'stdout' stream.
	     * @return reference to the corresponding ostream object.
	     */
	    virtual ostream& out() = 0;
	    /**
	     * Fetch reference to CGI 'stdin' stream.
	     * @return reference to the corresponding istream object.
	     */
	    virtual istream& in() = 0;
	    /**
	     * Fetch reference to CGI 'stderr' stream.
	     * @return reference to the corresponding ostream object.
	     */
	    virtual ostream& err() = 0;
    };

}

#endif /* __KINGATE_CGI_INTERFACE_H */
/*
 * vim:set ft=cpp:
 */