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"
14 ACE_WString_Helper::encode (void *buf
, const ACE_WString
&wstr
)
16 ACE_UINT16
*wptr
= (ACE_UINT16
*) buf
;
19 for (i
= 0; i
<= wstr
.length (); i
++)
20 wptr
[i
] = htons (wstr
[i
]);
22 return i
* sizeof (ACE_UINT16
);
26 ACE_WString_Helper::decode (void *buf
)
28 ACE_UINT16
*wptr
= (ACE_UINT16
*) buf
;
31 for (i
= 0; wptr
[i
] != 0; i
++)
32 wptr
[i
] = ntohs (wptr
[i
]);
34 return (i
+ 1) * sizeof (ACE_UINT16
);
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
),
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
);
54 len
+= ACE_WString_Helper::decode ((void *) cbuf
);
55 this->value ((ACE_UINT16
*) cbuf
);
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 ()));
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 ()));
74 ACE_DEBUG ((LM_DEBUG
, " value_: \"\"\n"));
76 ACE_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
80 ACE_URL_Offer::size () const
82 size_t sum
= (this->url_
.length () + 1) * sizeof (ACE_UINT16
);
83 sum
+= ::ace_array_size (this->prop_
);
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
),
97 len
+= ::ace_array_encode ((void *) ((char *) buf
+ len
),
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
),
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 ()));
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 */