Use a variable on the stack to not have a temporary in the call
[ACE_TAO.git] / ACE / protocols / ace / INet / HeaderBase.inl
blobfee02f025b12353f3e4ecdda6bafe00c48c6a904
1 // -*- C++ -*-
2 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
4 namespace ACE
6   namespace INet
7   {
9     ACE_INLINE
10     int HeaderBase::get_content_length() const
11       {
12         ACE_CString lenstr;
13         if (this->get (CONTENT_LENGTH, lenstr))
14           {
15             return ACE_OS::atoi (lenstr.c_str ());
16           }
17         return UNKNOWN_CONTENT_LENGTH;
18       }
20     ACE_INLINE
21     void HeaderBase::set_content_type(const ACE_CString& mime_type)
22       {
23         if (mime_type == UNKNOWN_CONTENT_TYPE)
24           {
25             this->remove (CONTENT_TYPE);
26           }
27         else
28           {
29             this->set (CONTENT_TYPE, UNKNOWN_CONTENT_TYPE);
30           }
31       }
33     ACE_INLINE
34     ACE_CString HeaderBase::get_content_type() const
35       {
36         ACE_CString val = UNKNOWN_CONTENT_TYPE;
37         this->get (CONTENT_TYPE, val);
38         return val;
39       }
41     ACE_INLINE
42     void HeaderBase::clear ()
43       {
44         this->header_values_.reset ();
45       }
47     ACE_INLINE
48     void HeaderBase::add (const ACE_CString& name, const ACE_CString& value)
49       {
50         this->header_values_.insert (NVPair (name, value));
51       }
53     ACE_INLINE
54     void HeaderBase::remove (const ACE_CString& name)
55       {
56         this->header_values_.remove (NVPair (name, EMPTY));
57       }
59     ACE_INLINE
60     bool HeaderBase::get (const ACE_CString& name, ACE_CString& value) const
61       {
62         TNVMap::ITERATOR it (const_cast<TNVMap&> (this->header_values_));
63         if (this->header_values_.find (NVPair (name), it) == 0)
64           {
65             value = (*it).second ();
66             return true;
67           }
68         return false;
69       }
71     ACE_INLINE
72     bool HeaderBase::has (const ACE_CString& name) const
73       {
74         TNVMap::ITERATOR it (const_cast<TNVMap&> (this->header_values_));
75         if (this->header_values_.find (NVPair (name), it) == 0)
76           {
77             return true;
78           }
79         return false;
80       }
82     ACE_INLINE
83     int HeaderBase::read_field (std::istream& str, ACE_CString& var, size_t maxlen, char delim)
84       {
85         int ch = str.get ();
86         while (ch != eof_ && ch != delim && ch != '\n' && var.length () < maxlen)
87           {
88             var += ch;
89             ch = str.get ();
90           }
91         return ch;
92       }
94     ACE_INLINE
95     int HeaderBase::read_ws_field (std::istream& str, ACE_CString& var, size_t maxlen)
96       {
97         int ch = str.get ();
98         while (!ACE_OS::ace_isspace (ch) && ch != eof_ && var.length () < maxlen)
99           {
100             var += ch;
101             ch = str.get ();
102           }
103         return ch;
104       }
106     ACE_INLINE
107     NVPair& NVPair::operator =(const NVPair& pair)
108       {
109         this->first (pair.first ());
110         this->second (pair.second ());
111         return *this;
112       }
114     ACE_INLINE
115     bool NVPair::operator ==(const NVPair& pair) const
116       {
117         return this->first_ == pair.first ();
118       }
120     ACE_INLINE
121     bool NVPair::operator <(const NVPair& pair) const
122       {
123         return this->first_ < pair.first ();
124       }
126     ACE_INLINE
127     const ACE_CString& NVPair::first () const
128       {
129         return this->first_;
130       }
132     ACE_INLINE
133     void NVPair::first (const ACE_CString& t1)
134       {
135         this->first_ = t1;
136       }
138     ACE_INLINE
139     const ACE_CString& NVPair::second () const
140       {
141         return this->second_;
142       }
144     ACE_INLINE
145     void NVPair::second (const ACE_CString& t2)
146       {
147         this->second_ = t2;
148       }
150   }
153 ACE_END_VERSIONED_NAMESPACE_DECL