summaryrefslogtreecommitdiff
path: root/apps/JAWS2/HTTPU/http_status.h
blob: c4d90657b159e628c77968e097bce39e44d77073 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// $Id$

#ifndef HTTPU_HTTP_STATUS_HPP
#define HTTPU_HTTP_STATUS_HPP

#include "ace/Singleton.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "HTTPU/http_export.h"

class HTTP_SCode_Base;

class HTTPU_Export HTTP_SCode_Node
// Constructor should be passed a string literal.
{
  friend class HTTP_SCode_Base;

public:
  operator int (void) const;
  operator const char * (void) const;

private:
  HTTP_SCode_Node (int code, const char *code_str);

private:
  int code_;
  const char *code_str_;
};

class HTTPU_Export HTTP_SCode_Base
{
public:
  static HTTP_SCode_Node STATUS_OK;
  static HTTP_SCode_Node STATUS_CREATED;
  static HTTP_SCode_Node STATUS_ACCEPTED;
  static HTTP_SCode_Node STATUS_NO_CONTENT;
  static HTTP_SCode_Node STATUS_MULTIPLE_CHOICES;
  static HTTP_SCode_Node STATUS_MOVED_PERMANENTLY;
  static HTTP_SCode_Node STATUS_MOVED_TEMPORARILY;
  static HTTP_SCode_Node STATUS_NOT_MODIFIED;
  static HTTP_SCode_Node STATUS_INSUFFICIENT_DATA;
  static HTTP_SCode_Node STATUS_BAD_REQUEST;
  static HTTP_SCode_Node STATUS_UNAUTHORIZED;
  static HTTP_SCode_Node STATUS_FORBIDDEN;
  static HTTP_SCode_Node STATUS_NOT_FOUND;
  static HTTP_SCode_Node STATUS_INTERNAL_SERVER_ERROR;
  static HTTP_SCode_Node STATUS_NOT_IMPLEMENTED;
  static HTTP_SCode_Node STATUS_BAD_GATEWAY;
  static HTTP_SCode_Node STATUS_SERVICE_UNAVAILABLE;
  static HTTP_SCode_Node STATUS_QUIT;

  enum
  {
    MIN_STATUS_CODE = 200,
    MAX_STATUS_CODE = 599
  };

private:
  static HTTP_SCode_Node DUMMY;
};

class HTTPU_Export HTTP_SCode : public HTTP_SCode_Base
{
  // = TITLE
  //     Go from numeric status codes to descriptive strings.
  //
  friend class HTTP_SCode_Node;
  friend class ACE_Singleton<HTTP_SCode, ACE_SYNCH_MUTEX>;

protected:

  HTTP_SCode (void);
  ~HTTP_SCode (void);

public:

  const char * operator[] (int) const;
  // Return the reason string corresponding to a status code number.

  static HTTP_SCode *instance (void);
  // Return reference to the singleton.

  enum
  {
    SC_TABLE_SIZE = MAX_STATUS_CODE - MIN_STATUS_CODE + 1
  };

  void dump (void);

private:
  static const char *table_[SC_TABLE_SIZE];
};


typedef ACE_Singleton<HTTP_SCode, ACE_SYNCH_MUTEX>
        HTTP_SCode_Singleton;

#if defined (ACE_HAS_INLINED_OSCALLS)
#   if defined (ACE_INLINE)
#     undef ACE_INLINE
#   endif /* ACE_INLINE */
#   define ACE_INLINE inline
#   include "HTTPU/http_status.i"
# endif /* ACE_HAS_INLINED_OSCALLS */

#endif /* HTTPU_HTTP_STATUS_HPP */