summaryrefslogtreecommitdiff
path: root/src/super.cpp
blob: 6b0291687e7adfbdf2852d2c5ee2947b76edbbb8 (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
/**
 *  Super.cpp
 *
 *  @copyright 2014 Copernica BV
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 */
#include "includes.h"

/**
 *  Set up namespace
 */
namespace Php {

/**
 *  A number of super-globals are always accessible
 */
Super POST      (TRACK_VARS_POST);
Super GET       (TRACK_VARS_GET);
Super COOKIE    (TRACK_VARS_COOKIE);
Super SERVER    (TRACK_VARS_SERVER);
Super ENV       (TRACK_VARS_ENV);
Super FILES     (TRACK_VARS_FILES);
Super REQUEST   (TRACK_VARS_REQUEST);

/**
 *  Array access operator
 *  This can be used for accessing associative arrays
 *  @param  key
 *  @return Value
 */
Value Super::operator[](const std::string &key) const
{
    // create a value object that wraps around the actual zval
    Value value(PG(http_globals)[_index]);
    
    // pass on the call
    return value[key];
}

/**
 *  Array access operator
 *  This can be used for accessing associative arrays
 *  @param  key
 *  @return Value
 */
Value Super::operator[](const char *key) const
{
    // create a value object that wraps around the actual zval
    Value value(PG(http_globals)[_index]);
    
    // pass on the call
    return value[key];
}

/**
 *  End namespace
 */
}