diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-19 21:58:03 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-19 21:58:03 +0000 |
commit | c41a8b660cb152617d93452d615fe5c46bde9401 (patch) | |
tree | 79cd772e779b2aa00c0070df1cca487984408fa3 /apps | |
parent | 5650f03605a268ee4c405f02cc02094114b34732 (diff) | |
download | ATCD-c41a8b660cb152617d93452d615fe5c46bde9401.tar.gz |
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.cpp | 80 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.h | 12 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.i | 86 |
3 files changed, 104 insertions, 74 deletions
diff --git a/apps/JAWS/clients/Caching/URL_Properties.cpp b/apps/JAWS/clients/Caching/URL_Properties.cpp index e2806aefd2d..d16fbd0cebe 100644 --- a/apps/JAWS/clients/Caching/URL_Properties.cpp +++ b/apps/JAWS/clients/Caching/URL_Properties.cpp @@ -14,6 +14,8 @@ #include "ace/OS.h" #include "ace/Auto_Ptr.h" +char ACE_URL_Offer::NULL_STRING = '\0'; + template <class T> size_t ace_array_bsize (T &x) { @@ -45,13 +47,10 @@ void ace_array_decode (void *buf, T &x) } } -void wstring_dump (const char *n, ACE_WString *wstr) +ACE_URL_Property::~ACE_URL_Property (void) { - if (wstr == 0) - ACE_DEBUG ((LM_DEBUG, "%s: %x\n", n, wstr)); - else - ACE_DEBUG ((LM_DEBUG, "%s: %x (\"%s\")\n", n, wstr, - ACE_Auto_Basic_Array_Ptr<char> (wstr->char_rep ()).get ())); + delete this->name_; + delete this->value_; } void @@ -88,15 +87,27 @@ void ACE_URL_Property::dump (void) const { ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - wstring_dump ("\n name_", this->name_); - wstring_dump (" value_", this->value_); + if (this->name_->length () > 0) + { + ACE_DEBUG ((LM_DEBUG, "\n name_: \"%s\"\n", + ACE_Auto_Basic_Array_Ptr<char> (this->name_->char_rep ()).get ())); + } + else + ACE_DEBUG ((LM_DEBUG, "\n name_: \"\"\n")); + if (this->value_->length () > 0) + { + ACE_DEBUG ((LM_DEBUG, " value_: \"%s\"\n", + ACE_Auto_Basic_Array_Ptr<char> (this->value_->char_rep ()).get ())); + } + else + ACE_DEBUG ((LM_DEBUG, " value_: \"\"\n")); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } size_t ACE_URL_Offer::bsize (void) const { - size_t sum = ACE_OS::strlen (this->url_) + 1; + size_t sum = (this->url_->length () + 1) * sizeof (ACE_USHORT16); sum += ::ace_array_bsize (this->prop_); return sum; } @@ -107,9 +118,13 @@ ACE_URL_Offer::encode (void *buf) const ACE_UINT32 *s_buf = (ACE_UINT32 *) buf; *s_buf = htonl (this->prop_.size ()); - size_t len = ACE_OS::strlen (this->url_) + 1; - ACE_OS::memcpy ((void *) ((char *) buf + sizeof (ACE_UINT32)), - this->url_, len); + size_t len = (this->url_->length () + 1) * sizeof (ACE_USHORT16); + ACE_USHORT16 *w_buf = (ACE_USHORT16 *) ((char *) buf + sizeof (ACE_UINT32)); + + ACE_OS::memcpy ((void *) w_buf, + this->url_->fast_rep (), len); + for (int i = 0; w_buf[i] != 0; i++) + w_buf[i] = htons (w_buf[i]); len += sizeof (ACE_UINT32); ::ace_array_encode ((void *) ((char *) buf + len), this->prop_); @@ -119,15 +134,17 @@ ACE_URL_Offer * ACE_URL_Offer::decode (void *buf) { size_t a_size = (size_t) ntohl ((ACE_UINT32 *) buf); - this->url ((const char *) buf + sizeof (ACE_UINT32)); + ACE_USHORT16 *url = (ACE_USHORT16 *) ((char *) buf + sizeof (ACE_UINT32)); + for (int i = 0; url[i] != 0; i++) + url[i] = ntohs (url[i]); + this->url (url); ACE_URL_Property_Seq prop_seq (a_size); this->url_properties (prop_seq); - // Set this property array to correct size. - ::ace_array_decode ((void *)((char *) buf + ACE_OS::strlen (this->url ()) - + 1 + sizeof (ACE_UINT32)), - this->prop_); + ::ace_array_decode ((void *)((char *) buf + (this->url_->length () + 1) * + sizeof (ACE_USHORT16) + sizeof (ACE_UINT32)), + this->prop_); return this; } @@ -135,10 +152,37 @@ void ACE_URL_Offer::dump (void) const { ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "\n URL: %s\n", this->url_)); + if (this->url_->length () > 0) + { + ACE_DEBUG ((LM_DEBUG, "\n url_: \"%s\"\n", + ACE_Auto_Basic_Array_Ptr<char> (this->url_->char_rep ()).get ())); + } + else + ACE_DEBUG ((LM_DEBUG, "\n url_: \"\"\n")); for (int i = 0; i < this->prop_.size (); i++) this->prop_[i].dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Auto_Basic_Array_Ptr<char>; +template class ACE_Array<ACE_URL_Property>; +template class ACE_Array<ACE_URL_Offer>; +template size_t ace_array_bsize (ACE_Array<ACE_URL_Property> &); +template void ace_array_encode (void *, ACE_Array<ACE_URL_Property> &); +template void ace_array_decode (void *, ACE_Array<ACE_URL_Property> &); +template size_t ace_array_bsize (ACE_Array<ACE_URL_Offer> &); +template void ace_array_encode (void *, ACE_Array<ACE_URL_Offer> &); +template void ace_array_decode (void *, ACE_Array<ACE_URL_Offer> &); +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Auto_Basic_Array_Ptr<char> +#pragma instantiate ACE_Array<ACE_URL_Property> +#pragma instantiate ACE_Array<ACE_URL_Offer> +#pragma instantiate size_t ace_array_bsize (ACE_Array<ACE_URL_Property> &) +#pragma instantiate void ace_array_encode (void *, ACE_Array<ACE_URL_Property> &) +#pragma instantiate void ace_array_decode (void *, ACE_Array<ACE_URL_Property> &) +#pragma instantiate size_t ace_array_bsize (ACE_Array<ACE_URL_Offer> &) +#pragma instantiate void ace_array_encode (void *, ACE_Array<ACE_URL_Offer> &) +#pragma instantiate void ace_array_decode (void *, ACE_Array<ACE_URL_Offer> &) +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ #endif /* ACE_URL_PROPERTIES_C */ diff --git a/apps/JAWS/clients/Caching/URL_Properties.h b/apps/JAWS/clients/Caching/URL_Properties.h index 39bac483e8b..66a8742b85e 100644 --- a/apps/JAWS/clients/Caching/URL_Properties.h +++ b/apps/JAWS/clients/Caching/URL_Properties.h @@ -117,17 +117,20 @@ public: int operator!= (const ACE_URL_Offer &rhs) const; // Inequality operator. - const char *url (void) const; + ACE_WString *url_rep (void); + const ACE_WString *url (void) const; // Get URL string. void url (const char *url); + void url (const ACE_USHORT16 *url); // Set URL. ACE_URL_Property_Seq &url_properties (void); // Get properties of this offer. void url_properties (const ACE_URL_Property_Seq &prop); - // Set properties of this offer. + // Set properties of this offer. This operation + // virtually get a copy of the passed in prop. // Some helper functions for encoding and decoding. size_t bsize (void) const; @@ -144,13 +147,16 @@ public: // Dump this object for debug. protected: - char *url_; + ACE_WString *url_; // URL of this offer. ACE_URL_Property_Seq prop_; // Properties associate with this offer. private: + static char NULL_STRING; + // A constant null string. + // ACE_UNIMPLEMENTED_FUNC (ACE_URL_Offer (void)) // Do not allow access to default constructor }; diff --git a/apps/JAWS/clients/Caching/URL_Properties.i b/apps/JAWS/clients/Caching/URL_Properties.i index d0ca4d73378..7eef3e90d9c 100644 --- a/apps/JAWS/clients/Caching/URL_Properties.i +++ b/apps/JAWS/clients/Caching/URL_Properties.i @@ -4,45 +4,26 @@ ACE_INLINE ACE_URL_Property::ACE_URL_Property (const char *name, const char *value) - : name_ (0), - value_ (0) { - if (name != 0) - ACE_NEW (this->name_, ACE_WString (name)); - if (value != 0) - ACE_NEW (this->value_, ACE_WString (value)); + ACE_NEW (this->name_, ACE_WString (name)); + ACE_NEW (this->value_, ACE_WString (value)); } ACE_INLINE ACE_URL_Property::ACE_URL_Property (const ACE_USHORT16 *name, const ACE_USHORT16 *value) - : name_ (0), - value_ (0) { - if (name != 0) - ACE_NEW (this->name_, ACE_WString (name)); - if (value != 0) - ACE_NEW (this->value_, ACE_WString (value)); + ACE_NEW (this->name_, ACE_WString (name)); + ACE_NEW (this->value_, ACE_WString (value)); } ACE_INLINE ACE_URL_Property::ACE_URL_Property (const ACE_URL_Property &p) - : name_ (0), - value_ (0) { - if (p.name_ != 0) - ACE_NEW (this->name_, ACE_WString (*p.name_)); - if (p.value_ != 0) - ACE_NEW (this->value_, ACE_WString (*p.value_)); + ACE_NEW (this->name_, ACE_WString (*p.name_)); + ACE_NEW (this->value_, ACE_WString (*p.value_)); } -ACE_INLINE -ACE_URL_Property::~ACE_URL_Property (void) -{ - delete this->name_; - delete this->value_; -} - ACE_INLINE ACE_URL_Property & ACE_URL_Property::operator= (const ACE_URL_Property &rhs) { @@ -50,10 +31,8 @@ ACE_URL_Property::operator= (const ACE_URL_Property &rhs) { delete this->name_; delete this->value_; - if (rhs.name_ != 0) - ACE_NEW_RETURN (this->name_, ACE_WString(*rhs.name_), *this); - if (rhs.value_ != 0) - ACE_NEW_RETURN (this->value_, ACE_WString(*rhs.value_), *this); + ACE_NEW_RETURN (this->name_, ACE_WString(*rhs.name_), *this); + ACE_NEW_RETURN (this->value_, ACE_WString(*rhs.value_), *this); } return *this; } @@ -90,16 +69,14 @@ ACE_INLINE void ACE_URL_Property::name (const char *n) { delete this->name_; - if (n != 0) - ACE_NEW (this->name_, ACE_WString (n)); + ACE_NEW (this->name_, ACE_WString (n)); } ACE_INLINE void ACE_URL_Property::name (const ACE_USHORT16 *n) { delete this->name_; - if (n != 0) - ACE_NEW (this->name_, ACE_WString (n)); + ACE_NEW (this->name_, ACE_WString (n)); } ACE_INLINE ACE_WString * @@ -118,16 +95,14 @@ ACE_INLINE void ACE_URL_Property::value (const char *v) { delete this->value_; - if (v != 0) - ACE_NEW (this->value_, ACE_WString (v)); + ACE_NEW (this->value_, ACE_WString (v)); } ACE_INLINE void ACE_URL_Property::value (const ACE_USHORT16 *v) { delete this->value_; - if (v != 0) - ACE_NEW (this->value_, ACE_WString (v)); + ACE_NEW (this->value_, ACE_WString (v)); } @@ -144,16 +119,15 @@ ACE_URL_Property::bsize (void) const ACE_INLINE ACE_URL_Offer::ACE_URL_Offer (const size_t size, const char *url) - : url_ (0), - prop_ (size) + : prop_ (size) { - this->url (url); + ACE_NEW (this->url_, ACE_WString (url)); } ACE_INLINE ACE_URL_Offer::~ACE_URL_Offer (void) { - delete [] this->url_; + delete this->url_; } ACE_INLINE ACE_URL_Offer & @@ -161,7 +135,7 @@ ACE_URL_Offer::operator= (const ACE_URL_Offer &rhs) { if (this != &rhs) { - this->url (rhs.url_); + *this->url_ = *rhs.url (); this->url_properties (rhs.prop_); } return *this; @@ -171,7 +145,7 @@ ACE_INLINE int ACE_URL_Offer::operator== (const ACE_URL_Offer &rhs) const { if (this == &rhs - && ACE_OS::strcmp (this->url (), rhs.url ()) == 0 + && this->url () == rhs.url () && this->prop_ == rhs.prop_) return 1; else @@ -184,24 +158,30 @@ ACE_URL_Offer::operator!= (const ACE_URL_Offer &rhs) const return !(*this == rhs); } -ACE_INLINE const char * +ACE_INLINE ACE_WString * +ACE_URL_Offer::url_rep (void) +{ + return this->url_; +} + +ACE_INLINE const ACE_WString * ACE_URL_Offer::url (void) const { return this->url_; } ACE_INLINE void -ACE_URL_Offer::url (const char *url) +ACE_URL_Offer::url (const ACE_USHORT16 *url) { - delete [] this->url_; + delete this->url_; + ACE_NEW (this->url_, ACE_WString (url)); +} - if (url != 0) - { - ACE_NEW (this->url_, char[ACE_OS::strlen (url) + 1]); - ACE_OS::strcpy (this->url_, url); - } - else - this->url_ = 0; +ACE_INLINE void +ACE_URL_Offer::url (const char *url) +{ + delete this->url_; + ACE_NEW (this->url_, ACE_WString (url)); } ACE_INLINE ACE_URL_Property_Seq & |