Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS / clients / Caching / URL_Properties.cpp
blob8c1ab1a7444a26129a5dff9bc0752364d6559a68
1 #if !defined (ACE_URL_PROPERTIES_C)
2 #define ACE_URL_PROPERTIES_C
4 #include "URL_Properties.h"
6 #if !defined (__ACE_INLINE__)
7 #include "URL_Properties.inl"
8 #endif /* __ACE_INLINE__ */
10 #include "URL_Array_Helper.h"
11 #include <memory>
13 size_t
14 ACE_WString_Helper::encode (void *buf, const ACE_WString &wstr)
16 ACE_UINT16 *wptr = (ACE_UINT16 *) buf;
17 size_t i;
19 for (i= 0; i <= wstr.length (); i++)
20 wptr[i] = htons (wstr[i]);
22 return i * sizeof (ACE_UINT16);
25 size_t
26 ACE_WString_Helper::decode (void *buf)
28 ACE_UINT16 *wptr = (ACE_UINT16 *) buf;
29 size_t i;
31 for (i = 0; wptr[i] != 0; i++)
32 wptr[i] = ntohs (wptr[i]);
34 return (i + 1) * sizeof (ACE_UINT16);
37 size_t
38 ACE_URL_Property::encode (void *buf) const
40 size_t blen = ACE_WString_Helper::encode (buf, this->name_);
41 blen += ACE_WString_Helper::encode ((void *) ((char *) buf + blen),
42 this->value_);
43 return blen;
46 size_t
47 ACE_URL_Property::decode (void *buf)
49 char *cbuf = (char *) buf;
50 size_t len = ACE_WString_Helper::decode(buf);
51 this->name ((ACE_UINT16 *) cbuf);
53 cbuf += len;
54 len += ACE_WString_Helper::decode ((void *) cbuf);
55 this->value ((ACE_UINT16 *) cbuf);
56 return len;
59 void
60 ACE_URL_Property::dump () const
62 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
64 if (this->name_.length () > 0)
65 ACE_DEBUG ((LM_DEBUG, "\n name_: \"%s\"\n",
66 std::unique_ptr<char[]> (this->name_.char_rep ()).get ()));
67 else
68 ACE_DEBUG ((LM_DEBUG, "\n name_: \"\"\n"));
70 if (this->value_.length () > 0)
71 ACE_DEBUG ((LM_DEBUG, " value_: \"%s\"\n",
72 std::unique_ptr<char[]> (this->value_.char_rep ()).get ()));
73 else
74 ACE_DEBUG ((LM_DEBUG, " value_: \"\"\n"));
76 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
79 size_t
80 ACE_URL_Offer::size () const
82 size_t sum = (this->url_.length () + 1) * sizeof (ACE_UINT16);
83 sum += ::ace_array_size (this->prop_);
84 return sum;
87 size_t
88 ACE_URL_Offer::encode (void *buf) const
90 ACE_UINT32 *s_buf = (ACE_UINT32 *) buf;
91 *s_buf = htonl (this->prop_.size ());
93 size_t len = sizeof (ACE_UINT32);
94 len += ACE_WString_Helper::encode ((void *) ((char *) buf + len),
95 this->url_);
97 len += ::ace_array_encode ((void *) ((char *) buf + len),
98 this->prop_);
99 return len;
102 size_t
103 ACE_URL_Offer::decode (void *buf)
105 size_t len = sizeof (ACE_UINT32);
106 size_t a_size = (size_t) ntohl (*(ACE_UINT32 *) buf);
107 len += ACE_WString_Helper::decode ((void *) ((char *) buf + len));
108 this->url ((ACE_UINT16 *) ((char *) buf + len));
110 ACE_URL_Property_Seq prop_seq (a_size);
111 this->url_properties (prop_seq);
113 len += ::ace_array_decode ((void *)((char *) buf + len),
114 this->prop_);
115 return len;
118 void
119 ACE_URL_Offer::dump () const
121 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
123 if (this->url_.length () > 0)
124 ACE_DEBUG ((LM_DEBUG, "\n url_: \"%s\"\n",
125 std::unique_ptr<char[]> (this->url_.char_rep ()).get ()));
126 else
127 ACE_DEBUG ((LM_DEBUG, "\n url_: \"\"\n"));
129 for (size_t i = 0; i < this->prop_.size (); i++)
130 this->prop_[i].dump ();
132 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
135 #endif /* ACE_URL_PROPERTIES_C */