Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ACE_INET_HEADER_BASE_H
00010 #define ACE_INET_HEADER_BASE_H
00011
00012 #include "ace/pre.h"
00013
00014 #include "ace/config-all.h"
00015
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 # pragma once
00018 #endif
00019
00020 #include "ace/SString.h"
00021 #include "ace/Containers_T.h"
00022 #include "ace/Array.h"
00023 #include "ace/OS_NS_ctype.h"
00024 #include "ace/INet/INet_Export.h"
00025 #include <iostream>
00026
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 namespace ACE
00030 {
00031 namespace INet
00032 {
00033
00034
00035
00036
00037
00038
00039 class NVPair
00040 {
00041 public:
00042 NVPair ();
00043 NVPair (const ACE_CString& first);
00044 NVPair (const ACE_CString& first, const ACE_CString& second);
00045 NVPair (const NVPair& pair);
00046 virtual ~NVPair ();
00047 NVPair& operator =(const NVPair& pair);
00048 bool operator ==(const NVPair& pair) const;
00049 bool operator <(const NVPair& pair) const;
00050
00051 const ACE_CString& first (void) const;
00052
00053 void first (const ACE_CString& t1);
00054
00055 const ACE_CString& second (void) const;
00056
00057 void second (const ACE_CString& t2);
00058
00059 private:
00060 ACE_CString first_;
00061 ACE_CString second_;
00062 };
00063
00064 typedef ACE_Ordered_MultiSet<NVPair> TNVMap;
00065
00066
00067
00068
00069
00070
00071
00072
00073 class ACE_INET_Export HeaderBase
00074 {
00075 public:
00076
00077 HeaderBase();
00078
00079
00080 virtual ~HeaderBase();
00081
00082
00083
00084
00085 virtual void set_content_length(int length);
00086
00087
00088
00089
00090 virtual int get_content_length() const;
00091
00092
00093
00094
00095 virtual void set_content_type(const ACE_CString& mime_type);
00096
00097
00098
00099
00100 virtual ACE_CString get_content_type() const;
00101
00102 void clear ();
00103
00104
00105 virtual void write(std::ostream& str) const;
00106
00107
00108
00109 virtual bool read(std::istream& str);
00110
00111 static const int UNKNOWN_CONTENT_LENGTH;
00112 static const ACE_CString UNKNOWN_CONTENT_TYPE;
00113
00114 static const ACE_CString CONTENT_LENGTH;
00115 static const ACE_CString CONTENT_TYPE;
00116
00117 static const ACE_CString EMPTY;
00118
00119
00120 void set (const ACE_CString& name, const ACE_CString& value);
00121
00122
00123 void add (const ACE_CString& name, const ACE_CString& value);
00124
00125
00126 void remove (const ACE_CString& name);
00127
00128
00129 bool get (const ACE_CString& name, ACE_CString& value) const;
00130
00131
00132 bool has (const ACE_CString& name) const;
00133
00134
00135 void get_values (const ACE_CString& name, ACE_Array<ACE_CString>& values) const;
00136
00137 protected:
00138 int read_field (std::istream& str, ACE_CString& var, size_t maxlen, char delim);
00139 int read_ws_field (std::istream& str, ACE_CString& var, size_t maxlen);
00140
00141 static const int eof_;
00142
00143 private:
00144
00145 enum Limits
00146 {
00147 MAX_NAME_LENGTH = 256,
00148 MAX_VALUE_LENGTH = 4096
00149 };
00150
00151 TNVMap header_values_;
00152 };
00153 }
00154 }
00155
00156 ACE_END_VERSIONED_NAMESPACE_DECL
00157
00158 #if defined (__ACE_INLINE__)
00159 #include "ace/INet/HeaderBase.inl"
00160 #endif
00161
00162 #include "ace/post.h"
00163 #endif