diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-18 11:43:22 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-18 11:43:22 +0000 |
commit | 837daa9ddd8560930925f9009915431b73dd950e (patch) | |
tree | 3623b91965d7e4ba46460c9d67b65324ad38cd7f /apps | |
parent | b7fe9de26f55b75336f5b46f2592797a95c6f2b8 (diff) | |
download | ATCD-837daa9ddd8560930925f9009915431b73dd950e.tar.gz |
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.cpp | 53 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.h | 155 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/URL_Properties.i | 201 |
3 files changed, 409 insertions, 0 deletions
diff --git a/apps/JAWS/clients/Caching/URL_Properties.cpp b/apps/JAWS/clients/Caching/URL_Properties.cpp new file mode 100644 index 00000000000..0a6a0cc24db --- /dev/null +++ b/apps/JAWS/clients/Caching/URL_Properties.cpp @@ -0,0 +1,53 @@ +// URL_Locator.cpp +// $Id$ + +#if !defined (ACE_URL_LOCATOR_C) +#define ACE_URL_LOCATOR_C + +#define ACE_BUILD_DLL +#include "URL_Locator.h" + +#if !defined (__ACE_INLINE__) +#include "URL_Locator.i" +#endif /* __ACE_INLINE__ */ + +template <class T> +size_t ace_array_bsize (T &x) +{ + size_t sum = sizeof (ACE_UINT32); + for (int i = 0; i < x.size (); i++) + sum += x[i].bsize (); + return sum; +} + +void +ACE_URL_Property::encode (void *buf) const +{ + size_t len = (this->name_->length () + 1) * sizeof (ACE_USHORT16); + ACE_OS::memcpy (buf, (void *) this->name_->fast_rep (), len); + ACE_OS::memcpy ((void *) ((char *) buf + len), + (void *) this->value_->fast_rep(), + (this->value_->length () + 1) * sizeof (ACE_USHORT16)); +} + +ACE_URL_Property * +ACE_URL_Property::decode (void *buf) +{ + ACE_USHORT16 *n = (ACE_USHORT16 *) buf; + ACE_USHORT16 *val = n; + ACE_URL_Property *retv; + + for (int i = 0; n[i] != 0; i++) ; + ACE_NEW_RETURN (retv, ACE_URL_Property (n, val), 0); + return retv; +} + +size_t +ACE_URL_Offer::bsize (void) const +{ + size_t sum = ACE_OS::strlen (this->url_) + 1; + sum += ::ace_array_bsize (this->prop_); + return sum; +} + +#endif /* ACE_URL_LOCATOR_C */ diff --git a/apps/JAWS/clients/Caching/URL_Properties.h b/apps/JAWS/clients/Caching/URL_Properties.h new file mode 100644 index 00000000000..f6672a3fe9a --- /dev/null +++ b/apps/JAWS/clients/Caching/URL_Properties.h @@ -0,0 +1,155 @@ +/* -*- C++ -*- */ + +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// none +// +// = FILENAME +// URL_Locator.h +// +// = AUTHOR +// Nanbor Wang +// +// ============================================================================ + +#if !defined (ACE_URL_LOCATOR_H) +#define ACE_URL_LOCATOR_H + +#include "ace/SString.h" +#include "ace/Array.h" + +class ACE_Export ACE_URL_Property + // = TITLE + // Defines a property of a URL. + // + // = DESCRIPTION + // A property contains a <name> and a <value>. +{ +public: + ACE_URL_Property (const char *name = 0, const char *value=0); + // Create a property. + + ACE_URL_Property (const ACE_USHORT16 *name, + const ACE_USHORT16 *value); + + ACE_URL_Property (ACE_URL_Property &p); + // Copy constructor. + + ~ACE_URL_Property (void); + // Destructor. + + ACE_URL_Property &operator= (ACE_URL_Property &rhs); + // Assignment operator. + + int operator== (ACE_URL_Property &rhs) const; + // Equals operator. + + int operator!= (ACE_URL_Property &rhs) const; + // Not equals operator. + + ACE_WString *name (void); + // Query property name. + + void name (const ACE_USHORT16 *n); + void name (const char *n); + // Set property name. + + ACE_WString *value (void); + // Query property value. + + void value (const ACE_USHORT16 *v); + void value (const char *v); + // Set property value. + + // Some helper functions for encoding and decoding. + size_t bsize (void) const; + // Returns memory size required to encode this object. + + void encode (void *buf) const; + // Encode this object into buf for network transmission. + + static ACE_URL_Property *decode (void *buf); + // Decode buf and create an object of this class. + +protected: + ACE_WString *name_; + // Property name pointer. + + ACE_WString *value_; + // Property value. +} ; + +typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq; + +class ACE_Export ACE_URL_Offer + // = TITLE + // Defines a URL offer. + // + // = DESCRIPTION + // A URL offer is defined by a <url> and an + // <ACE_URL_Property_Seq>. +{ +public: + ACE_URL_Offer (const char *url, size_t size); + // Create an offer. + + ACE_URL_Offer (ACE_URL_Offer &o); + // Copy ctor. + + ~ACE_URL_Offer (void); + // Default destructor. + + ACE_URL_Offer &operator= (ACE_URL_Offer &rhs); + // Assignment operator. + + int operator== (ACE_URL_Offer &rhs) const; + // Equality operator. + + int operator!= (ACE_URL_Offer &rhs) const; + // Inequality operator. + + const char *url (void) const; + // Get URL string. + + void url (const char *url); + // Set URL. + + ACE_URL_Property_Seq &url_properties (void); + // Get properties of this offer. + + void url_properties (ACE_URL_Property_Seq &prop); + // Set properties of this offer. + + // Some helper functions for encoding and decoding. + size_t bsize (void) const; + // Returns memory size required to encode this object. + + void encode (void *buf) const; + // Encode this object into buf for network transmission. + + static ACE_URL_Offer *decode (void *buf); + // Decode buf and create an object of this class. + +protected: + char *url_; + // URL of this offer. + + ACE_URL_Property_Seq prop_; + // Properties associate with this offer. + +private: + ACE_UNIMPLEMENTED_FUNC (ACE_URL_Offer (void)) + // Do not allow access to default constructor +}; + +typedef ACE_Array<ACE_URL_Offer> ACE_URL_Offer_Seq; +typedef char *ACE_URL_OfferID; + +#if defined (__ACE_INLINE__) +#include "URL_Locator.i" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_WEB_LOCATOR_H */ diff --git a/apps/JAWS/clients/Caching/URL_Properties.i b/apps/JAWS/clients/Caching/URL_Properties.i new file mode 100644 index 00000000000..55c14fd61ff --- /dev/null +++ b/apps/JAWS/clients/Caching/URL_Properties.i @@ -0,0 +1,201 @@ +/* -*- C++ -*- */ + +// $Id$ + +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_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_INLINE +ACE_URL_Property::ACE_URL_Property (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_INLINE +ACE_URL_Property::~ACE_URL_Property (void) +{ + delete this->name_; + delete this->value_; +} + +ACE_INLINE ACE_URL_Property & +ACE_URL_Property::operator= (ACE_URL_Property &rhs) +{ + if (this != &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); + } + return *this; +} + +ACE_INLINE int +ACE_URL_Property::operator== (ACE_URL_Property &rhs) const +{ + if (this == &rhs || *this->name_ != *rhs.name () || + *this->value_ != *rhs.value ()) + return 1; + else + return 0; +} + +ACE_INLINE int +ACE_URL_Property::operator!= (ACE_URL_Property &rhs) const +{ + return !(*this == rhs); +} + +ACE_INLINE ACE_WString * +ACE_URL_Property::name (void) +{ + return this->name_; +} + +ACE_INLINE void +ACE_URL_Property::name (const char *n) +{ + delete this->name_; + if (n != 0) + 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_INLINE ACE_WString * +ACE_URL_Property::value (void) +{ + return this->value_; +} + +ACE_INLINE void +ACE_URL_Property::value (const char *v) +{ + delete this->value_; + if (v != 0) + 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_INLINE size_t +ACE_URL_Property::bsize (void) const +{ + return (this->name_->length () + this->value_->length () + 2) * + sizeof (ACE_USHORT16); +} + +ACE_INLINE +ACE_URL_Offer::ACE_URL_Offer (const char *url, size_t size) + : url_ (0), + prop_ (size) +{ + this->url (url); +} + +ACE_INLINE +ACE_URL_Offer::~ACE_URL_Offer (void) +{ + delete [] this->url_; +} + +ACE_INLINE ACE_URL_Offer & +ACE_URL_Offer::operator= (ACE_URL_Offer &rhs) +{ + if (this != &rhs) + { + this->url (rhs.url ()); + this->url_properties (rhs.url_properties ()); + } + return *this; +} + +ACE_INLINE int +ACE_URL_Offer::operator== (ACE_URL_Offer &rhs) const +{ + if (this == &rhs + && ACE_OS::strcmp (this->url (), rhs.url ()) == 0 + && this->prop_ == rhs.url_properties ()) + return 1; + else + return 0; +} + +ACE_INLINE int +ACE_URL_Offer::operator!= (ACE_URL_Offer &rhs) const +{ + return !(*this == rhs); +} + +ACE_INLINE const char * +ACE_URL_Offer::url (void) const +{ + return this->url_; +} + +ACE_INLINE void +ACE_URL_Offer::url (const char *url) +{ + delete [] this->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 ACE_URL_Property_Seq & +ACE_URL_Offer::url_properties (void) +{ + return this->prop_; +} + +ACE_INLINE void +ACE_URL_Offer::url_properties (ACE_URL_Property_Seq &prop) +{ + this->prop_ = prop; +} |