summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-20 00:01:48 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-20 00:01:48 +0000
commit0f32197c34f5ece130bfdb6b7422dbc8df57e7fb (patch)
tree316fb4435a8a3fd82c21ee4f7898690396ec116f /apps
parentc65d8f7aa13d335b8c4cc7c3e863aade466200c1 (diff)
downloadATCD-0f32197c34f5ece130bfdb6b7422dbc8df57e7fb.tar.gz
Reworked.
Diffstat (limited to 'apps')
-rw-r--r--apps/JAWS/clients/Caching/ID_Generator.cpp2
-rw-r--r--apps/JAWS/clients/Caching/ID_Generator.h17
-rw-r--r--apps/JAWS/clients/Caching/Local_Locator.cpp162
-rw-r--r--apps/JAWS/clients/Caching/Local_Locator.h6
-rw-r--r--apps/JAWS/clients/Caching/Locator_Request_Reply.cpp248
-rw-r--r--apps/JAWS/clients/Caching/Locator_Request_Reply.h17
-rw-r--r--apps/JAWS/clients/Caching/URL_Array_Helper.cpp5
-rw-r--r--apps/JAWS/clients/Caching/URL_Array_Helper.h2
-rw-r--r--apps/JAWS/clients/Caching/URL_Locator.cpp35
-rw-r--r--apps/JAWS/clients/Caching/URL_Locator.h19
-rw-r--r--apps/JAWS/clients/Caching/URL_Properties.cpp45
-rw-r--r--apps/JAWS/clients/Caching/URL_Properties.h68
-rw-r--r--apps/JAWS/clients/Caching/URL_Properties.i86
-rw-r--r--apps/JAWS/clients/Caching/test_URL.cpp31
14 files changed, 500 insertions, 243 deletions
diff --git a/apps/JAWS/clients/Caching/ID_Generator.cpp b/apps/JAWS/clients/Caching/ID_Generator.cpp
index fa3e1cbe4be..dc906c95a9e 100644
--- a/apps/JAWS/clients/Caching/ID_Generator.cpp
+++ b/apps/JAWS/clients/Caching/ID_Generator.cpp
@@ -3,8 +3,8 @@
#if !defined (ACE_ID_GENERATOR_C)
#define ACE_ID_GENERATOR_C
-#define ACE_BUILD_DLL
#include "ID_Generator.h"
+#include "ace/Object_Manager.h"
time_t ACE_ID_Generator::last_time_ = 0;
diff --git a/apps/JAWS/clients/Caching/ID_Generator.h b/apps/JAWS/clients/Caching/ID_Generator.h
index 556ce8dbfde..0d73f72625c 100644
--- a/apps/JAWS/clients/Caching/ID_Generator.h
+++ b/apps/JAWS/clients/Caching/ID_Generator.h
@@ -22,13 +22,16 @@
#define ACE_OFFER_ID_LENGTH 21
-class ACE_Export ACE_ID_Generator
-// Nanbor, please make sure you use the official ACE "= TITLE" syntax
-// here. Also, what is "beckry's algorithm?" Do you mean "Berkeley's
-// algorithm?"
-// Generate an offer ID according to current time and
-// avoid duplicate ID. Using a similar method like
-// beckry's algorithm.
+class ACE_ID_Generator
+ // = TITLE
+ // An unique ID generator.
+ //
+ // = DESCRIPTION
+
+ // Generate an offer ID according to current time and avoid
+ // duplicate ID. It guarantees ID uniqueness within a process,
+ // i.e. no two threads may get the same ID string. Using a
+ // similar method like the backery algorithm.
{
public:
static char *get_new_id (char *id);
diff --git a/apps/JAWS/clients/Caching/Local_Locator.cpp b/apps/JAWS/clients/Caching/Local_Locator.cpp
index 9799a4f21b3..66b0bab31a4 100644
--- a/apps/JAWS/clients/Caching/Local_Locator.cpp
+++ b/apps/JAWS/clients/Caching/Local_Locator.cpp
@@ -3,7 +3,6 @@
#if !defined (ACE_LOCAL_LOCATOR_C)
#define ACE_LOCAL_LOCATOR_C
-#define ACE_BUILD_DLL
#include "Local_Locator.h"
#if !defined (__ACE_INLINE__)
@@ -21,34 +20,48 @@ ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria
ACE_NEW_RETURN (offer, ACE_URL_Offer_Seq (how_many), -1);
+ if (how >= ACE_URL_Locator::INVALID_SELECTION)
+ {
+ errno = ACE_URL_Locator::INVALID_ARGUMENT;
+ return -1;
+ }
+
+ num_query = 0;
for (ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
iter.next (item) != 0;
iter.advance ())
{
- switch (how)
- {
- case ACE_URL_Locator::NONE:
- // Offers must not have any properties in <pseq>
- errno = ACE_URL_Locator::UNIMPLEMENTED;
- return -1;
- break;
- case ACE_URL_Locator::SOME:
- // Offers must have at least one property in <pseq>
- errno = ACE_URL_Locator::UNIMPLEMENTED;
- return -1;
- break;
- case ACE_URL_Locator::ALL:
- // Offers must have all the properties in <pseq>
- errno = ACE_URL_Locator::UNIMPLEMENTED;
- return -1;
- break;
- default:
- delete [] offer ;
- offer = 0;
- errno = ACE_URL_Locator::INVALID_ARGUMENT;
- return -1;
- }
- if (how_many == 0)
+ size_t i_query;
+ size_t i_db;
+ int found = 0;
+
+ // Now this is a stupid implementation. Perhaps we can implement this
+ // using Hash_Map. Better yet, I think we should put this in a database
+ // and put SQL query here.
+ for (i_query = 0; found == 0 && i_query < pseq->size (); i_query++)
+ for (i_db = 0; i_db < item->offer_->url_properties ().size (); i_db++)
+ {
+ if ((*pseq)[i_query].name () == item->offer_->url_properties ()[i_db].name ())
+ if (how == ACE_URL_Locator::SOME)
+ {
+
+
+ }
+
+ // if match and Some, copy to <offer>, inc <num_query>, advance iterator
+
+ // else if All, advance iterator
+
+ // else if None, check next property in <pseq>.
+
+ if (all properties checked and found and ALL)
+ copy to <offer>; inc <num_query>;
+ else if (all properties checked and not found and NONE)
+ copy to <offer>; inc <num_query>;
+ else
+ shouldn't happen, internal error
+
+ if (num_query == how_many)
break;
}
@@ -130,11 +143,106 @@ ACE_URL_Local_Locator::describe_offer (const ACE_WString &offer_id,
int
ACE_URL_Local_Locator::modify_offer (const ACE_WString &offer_id,
- const char *url,
+ const ACE_WString *url,
const ACE_URL_Property_Seq *del,
const ACE_URL_Property_Seq *modify)
{
- errno = ACE_URL_Locator::UNIMPLEMENTED;
+ ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
+ ACE_URL_Record *item = 0;
+ ACE_URL_Record *target = 0;
+
+ // Errno Checking
+
+ for (; iter.next (item) != 0; iter.advance ())
+ {
+ if (url != 0 && *url == item->offer_->url ())
+ {
+ errno = ACE_URL_Locator::OFFER_EXIST;
+ return -1;
+ }
+ if (offer_id == *item->id_)
+ target = item;
+ }
+
+ if (target != 0) // Aha, we found a target to work on
+ {
+ if (del != 0 && modify != 0)
+ {
+ // We need to make a copy of the original property sequence
+ // so if any error occurs, we can revert our change easily.
+
+ // First we need to calculate the maximum number of perperties.
+ int psize = target->offer_->url_properties ().size ();
+ if (del != 0)
+ if ((psize -= del->size ()) < 0)
+ {
+ // If you try to delete more properties than we have,
+ // you are doomed. No need to proceed.
+ errno = ACE_URL_Locator::INVALID_ARGUMENT;
+ return -1;
+ }
+ if (modify != 0)
+ // In the worst case, all properties in <modify> will be added.
+ psize += modify->size ();
+
+ // Now, create a temporary work space.
+ ACE_URL_Property_Seq working (psize);
+ size_t sz = 0;
+ for (; sz < item->offer_->url_properties ().size ())
+ working[sz] = item->offer_->url_properties() [sz];
+
+ if (del != 0)
+ {
+ // Argh, this is really a stupid design.
+ // Go thru every property we want to delete
+ for (size_t i = 0; i < del->size () && sz > 0; i++)
+ // For earch, go thru our property sequence and
+ // search for the property.
+ for (size_t j = 0; j < sz; j++)
+ if ((*del)[i].name () == working[j].name ())
+ {
+ sz -= 1;
+ working[j] = working[sz]; // pack the array.
+ break;
+ }
+ // Doesn't generate error when we want to delete an
+ // imaginary property. Is this appropriate?
+ }
+
+ if (modify != 0)
+ {
+ // This is also stupid.
+ // Go thru every property we want to modify/add
+ for (size_t i = 0; i < modify->size () && sz > 0; i++)
+ {
+ // For each property, go thru our property list
+ // and search for the matching property
+ for (size_t j = 0; j < sz; j++)
+ if ((*modify)[i].name () == working[j].name ())
+ {
+ // A match found.
+ working[j].value ((*modify)[i].value ().fast_rep ());
+ break;
+ }
+
+ // No matching property name were found,
+ // We want to add this property into the list.
+ if (j == sz)
+ working[sz++] = (*modify)[i];
+ }
+ }
+ }
+
+ // Yes, all operations passed. We can now copy the working version back.
+ item->offer_->url_properties (ACE_URL_Property_Seq (sz));
+ for (size_t i = 0; i < sz; i ++)
+ item->offer_->url_properties ()[i] = working[i];
+
+ if (url != 0)
+ item->offer_->url (url->fast_rep ()); // replace URL location.
+ return 0;
+ }
+ errno = ACE_URL_Locator::NO_SUCH_OFFER;
return -1;
}
diff --git a/apps/JAWS/clients/Caching/Local_Locator.h b/apps/JAWS/clients/Caching/Local_Locator.h
index bcc82cef566..aa6c73decf6 100644
--- a/apps/JAWS/clients/Caching/Local_Locator.h
+++ b/apps/JAWS/clients/Caching/Local_Locator.h
@@ -22,7 +22,7 @@
#include "ace/Containers.h"
#include "ID_Generator.h"
-class ACE_URL_Record
+class ACE_SVC_Export ACE_URL_Record
// = TITLE
// A URL Record.
//
@@ -63,7 +63,7 @@ private:
// Offer (and its properties).
};
-class ACE_Export ACE_URL_Local_Locator
+class ACE_SVC_Export ACE_URL_Local_Locator
// = TITLE
// A simple URL repository to store URL offer locally.
//
@@ -97,7 +97,7 @@ class ACE_Export ACE_URL_Local_Locator
// Query a specific offer.
virtual int modify_offer (const ACE_WString &offer_id,
- const char *url = 0,
+ const ACE_WString *url = 0,
const ACE_URL_Property_Seq *del = 0,
const ACE_URL_Property_Seq *modify = 0);
// Modify a previously registered offer.
diff --git a/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp b/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
index 0582c3e702c..9687a325557 100644
--- a/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
+++ b/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
@@ -5,7 +5,6 @@
#if !defined (ACE_LOCATOR_REQUEST_REPLY_C)
#define ACE_LOCATOR_REQUEST_REPLY_C
-#define ACE_BUILD_DLL
#include "Locator_Request_Reply.h"
#if !defined (__ACE_INLINE__)
@@ -15,6 +14,7 @@
#include "URL_Properties.h"
#include "URL_Array_Helper.h"
#include "URL_Locator.h"
+#include "ace/Auto_Ptr.h"
int
ACE_URL_Locator_Request::url_query (const int how,
@@ -94,7 +94,7 @@ ACE_URL_Locator_Request::encode (void)
{
ACE_TRACE ("ACE_URL_Locator_Request::encode");
- size_t buf_size = this->bsize ();
+ size_t buf_size = this->size ();
size_t total_length = 0;
ACE_NEW_RETURN (this->buffer_, char [buf_size], 0);
@@ -115,16 +115,22 @@ ACE_URL_Locator_Request::encode (void)
// Encode valide pointer flag.
if (this->seq1_ != 0)
- total_length += ace_array_encode (this->buffer_ + total_length, *this->seq1_);
+ {
+ ENCODE_UINT32 (this->buffer_, total_length, this->seq1_->size ());
+ total_length += ace_array_encode (this->buffer_ + total_length, *this->seq1_);
+ }
if (this->seq2_ != 0)
- total_length += ace_array_encode (this->buffer_ + total_length, *this->seq2_);
+ {
+ ENCODE_UINT32 (this->buffer_, total_length, this->seq2_->size ());
+ total_length += ace_array_encode (this->buffer_ + total_length, *this->seq2_);
+ }
if (this->offer_ != 0)
total_length += this->offer_->encode (this->buffer_ + total_length);
total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
- &this->id_);
+ this->id_);
total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
- &this->url_);
+ this->url_);
ACE_ASSERT (total_length == buf_size);
return total_length;
@@ -137,48 +143,52 @@ ACE_URL_Locator_Request::decode (void *buffer)
if (buffer == 0)
return 0;
- // Check if we have a buffer available.
- delete [] this->buffer_;
- this->buffer_ = (char*) buffer;
+ // Check if we have a valid buffer available.
+
+ char *cbuffer = (char *) buffer;
- size_t buf_size = 0;
+ size_t buf_size;
size_t total_length = 0;
- DECODE_UINT32 (this->buffer_, total_length, buf_size);
+ DECODE_UINT32 (cbuffer, total_length, buf_size);
// Decode length of buffer size first.
- DECODE_UINT32 (this->buffer_, total_length, this->code_);
+ DECODE_UINT32 (cbuffer, total_length, this->code_);
// Get the operation code.
- DECODE_UINT32 (this->buffer_, total_length, this->how_);
+ DECODE_UINT32 (cbuffer, total_length, this->how_);
// Decode selection criteria.
- DECODE_UINT32 (this->buffer_, total_length, this->how_many_);
+ DECODE_UINT32 (cbuffer, total_length, this->how_many_);
// Decode number of offers interested.
- DECODE_UINT32 (this->buffer_, total_length, this->valid_ptr_);
+ DECODE_UINT32 (cbuffer, total_length, this->valid_ptr_);
// Decode valide pointer flag.
- if (this->valid_ptr_ | VALID_SEQ1 != 0)
+ if ((this->valid_ptr_ & VALID_SEQ1) != 0)
{
- ACE_NEW_RETURN (this->seq1_, ACE_URL_Property_Seq (1), 0);
- total_length += ace_array_decode (this->buffer_ + total_length, *this->seq1_);
+ size_t n;
+ DECODE_UINT32 (cbuffer, total_length, n);
+ ACE_NEW_RETURN (this->seq1_, ACE_URL_Property_Seq (n), 0);
+ total_length += ace_array_decode (cbuffer + total_length, *this->seq1_);
}
- if (this->valid_ptr_ | VALID_SEQ2 != 0)
+ if ((this->valid_ptr_ & VALID_SEQ2) != 0)
{
- ACE_NEW_RETURN (this->seq2_, ACE_URL_Property_Seq (1), 0);
- total_length += ace_array_decode (this->buffer_ + total_length, *this->seq2_);
+ size_t n;
+ DECODE_UINT32 (cbuffer, total_length, n);
+ ACE_NEW_RETURN (this->seq2_, ACE_URL_Property_Seq (n), 0);
+ total_length += ace_array_decode (cbuffer + total_length, *this->seq2_);
}
- if (this->valid_ptr_ | VALID_OFFER != 0)
+ if ((this->valid_ptr_ & VALID_OFFER) != 0)
{
ACE_NEW_RETURN (this->offer_, ACE_URL_Offer, 0);
- total_length += this->offer_->decode (this->buffer_ + total_length);
+ total_length += this->offer_->decode (cbuffer + total_length);
}
- total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
- this->id_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
- total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
- this->url_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
+ this->id_ = ACE_WString ((ACE_USHORT16 *) (cbuffer + total_length));
+ total_length += ACE_WString_Helper::decode (cbuffer + total_length);
+ this->url_ = ACE_WString ((ACE_USHORT16 *) (cbuffer + total_length));
+ total_length += ACE_WString_Helper::decode (cbuffer + total_length);
ACE_ASSERT (total_length == buf_size);
return total_length;
@@ -186,9 +196,9 @@ ACE_URL_Locator_Request::decode (void *buffer)
size_t
-ACE_URL_Locator_Request::bsize (void)
+ACE_URL_Locator_Request::size (void)
{
- ACE_TRACE ("ACE_URL_Locator_Request::bsize");
+ ACE_TRACE ("ACE_URL_Locator_Request::size");
size_t total_length = 5 * sizeof (ACE_UINT32);
// There are 5 UINT32 variables at the beginning
@@ -201,21 +211,21 @@ ACE_URL_Locator_Request::bsize (void)
if (this->seq1_ != 0)
{
this->valid_ptr_ |= VALID_SEQ1;
- total_length += ace_array_bsize (*this->seq1_);
+ total_length += ace_array_size (*this->seq1_);
}
if (this->seq2_ != 0)
{
this->valid_ptr_ |= VALID_SEQ2;
- total_length += ace_array_bsize (*this->seq2_);
+ total_length += ace_array_size (*this->seq2_);
}
if (this->offer_ != 0)
{
this->valid_ptr_ |= VALID_OFFER;
- total_length += this->offer_->bsize ();
+ total_length += this->offer_->size ();
}
- total_length += ACE_WString_Helper::bsize (&this->id_);
- total_length += ACE_WString_Helper::bsize (&this->url_);
+ total_length += ACE_WString_Helper::size (this->id_);
+ total_length += ACE_WString_Helper::size (this->url_);
return total_length;
}
@@ -225,50 +235,49 @@ ACE_URL_Locator_Request::dump (void) const
{
//ACE_TRACE ("ACE_URL_Locator_Request::dump");
+ size_t i;
+
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
- size_t i;
-
- switch (this->code_)
- {
- case ACE_URL_Locator::QUERY:
- ACE_DEBUG ((LM_DEBUG, "Query Request:\nSelection: "));
- switch (this->how_)
- {
- case ACE_URL_Locator::NONE:
- ACE_DEBUG ((LM_DEBUG, "NONE.\n"));
- break;
- case ACE_URL_Locator::SOME:
- ACE_DEBUG ((LM_DEBUG, "SOME.\n"));
- break;
- case ACE_URL_Locator::ALL:
- ACE_DEBUG ((LM_DEBUG, "ALL.\n"));
- break;
- default:
- ACE_DEBUG ((LM_DEBUG, "Invalid Selection??\n"));
- break;
- }
- ACE_DEBUG ((LM_DEBUG, "At most %d reply.\n", this->how_many_));
- for (i = 0; i < this->seq1_->size (); i++)
+ if (this->code_ < ACE_URL_Locator::INVALID_OPERATION)
+ ACE_DEBUG ((LM_DEBUG, "%s Request:\n", ACE_URL_Locator::opname[this->code_]));
+ else
+ ACE_DEBUG ((LM_DEBUG, "Invalid Operation: %d\n", this->code_));
+
+ if (this->how_ < ACE_URL_Locator::INVALID_SELECTION)
+ ACE_DEBUG ((LM_DEBUG, "Select: %s\n", ACE_URL_Locator::selection_name[this->how_]));
+ else
+ ACE_DEBUG ((LM_DEBUG, "Invalid selection method: %d\n", this->how_));
+
+ ACE_DEBUG ((LM_DEBUG, "At most %d reply.\n", this->how_many_));
+
+ ACE_DEBUG ((LM_DEBUG, "Valid pointer pattern: %x\n", this->valid_ptr_));
+
+ ACE_DEBUG ((LM_DEBUG, "Property sequence 1: %x\n", this->seq1_));
+ if (this->seq1_ != 0)
+ for (i = 0; i < this->seq1_->size (); i++)
(*this->seq1_)[i].dump ();
- break;
- case ACE_URL_Locator::EXPORT:
- ACE_DEBUG ((LM_DEBUG, "Export Request:\n"));
- break;
- case ACE_URL_Locator::WITHDRAW:
- ACE_DEBUG ((LM_DEBUG, "Withdraw Request:\n"));
- break;
- case ACE_URL_Locator::DESCRIBE:
- ACE_DEBUG ((LM_DEBUG, "Describe Request:\n"));
- break;
- case ACE_URL_Locator::MODIFY:
- ACE_DEBUG ((LM_DEBUG, "Modify Request:\n"));
- break;
- default:
- // Invalid data encountered. Stop encoding now.
- ACE_DEBUG ((LM_DEBUG, "Invalid Request.\n"));
- break;
- }
+
+ ACE_DEBUG ((LM_DEBUG, "Property sequence 2: %x\n", this->seq2_));
+ if (this->seq2_ != 0)
+ for (i = 0; i < this->seq2_->size (); i++)
+ (*this->seq2_)[i].dump();
+
+ ACE_DEBUG ((LM_DEBUG, "Offer: %x\n", this->offer_));
+ if (this->offer_ != 0)
+ this->offer_->dump ();
+
+ if (this->id_.length () > 0)
+ ACE_DEBUG ((LM_DEBUG, "Offer ID: %s\n",
+ ACE_Auto_Basic_Array_Ptr<char> (this->id_.char_rep ()).get ()));
+ else
+ ACE_DEBUG ((LM_DEBUG, "Offer ID: \"\"\n"));
+
+ if (this->url_.length () > 0)
+ ACE_DEBUG ((LM_DEBUG, "URL: %s\n",
+ ACE_Auto_Basic_Array_Ptr<char> (this->url_.char_rep ()).get ()));
+ else
+ ACE_DEBUG ((LM_DEBUG, "URL: \"\"\n"));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
@@ -312,7 +321,7 @@ ACE_URL_Locator_Reply::encode (void)
{
ACE_TRACE ("ACE_URL_Locator_Reply::encode");
- size_t buf_size = this->bsize ();
+ size_t buf_size = this->size ();
size_t total_length = 0;
ACE_NEW_RETURN (this->buffer_, char [buf_size], 0);
@@ -332,8 +341,16 @@ ACE_URL_Locator_Reply::encode (void)
ENCODE_UINT32 (this->buffer_, total_length, this->valid_ptr_);
// Encode valid pointers mask.
- // Encode request for network communication. If succeed,
- // returns the size of the buffer, otherwise, return 0.
+ if (this->offer_ != 0)
+ total_length += this->offer_->encode (this->buffer_ + total_length);
+
+ if (this->offers_ != 0)
+ {
+ ENCODE_UINT32 (this->buffer_, total_length, this->offers_->size ());
+ total_length += ace_array_encode (this->buffer_ + total_length, *this->offers_);
+ }
+
+ ACE_ASSERT (total_length == buf_size);
return 0;
}
@@ -342,15 +359,52 @@ ACE_URL_Locator_Reply::decode (void *buffer)
{
ACE_TRACE ("ACE_URL_Locator_Reply::decode");
- // Restore from network data. Returns size of the buffer
- // if succeed, 0 otherwise.
+ if (buffer == 0)
+ return 0;
+ // Check if we have a buffer available.
+
+ char *cbuffer = (char *) buffer;
+
+ size_t buf_size;
+ size_t total_length = 0;
+
+ DECODE_UINT32 (cbuffer, total_length, buf_size);
+ // Get the length of the buffer first.
+
+ DECODE_UINT32 (cbuffer, total_length, this->code_);
+ // Decode Op code.
+
+ DECODE_UINT32 (cbuffer, total_length, this->status_);
+ // Decode Op result status.
+
+ DECODE_UINT32 (cbuffer, total_length, this->num_offers_);
+ // Decode number of offers in this->offers_.
+
+ DECODE_UINT32 (cbuffer, total_length, this->valid_ptr_);
+ // Decode valid pointers mask.
+
+ if ((this->valid_ptr_ & VALID_OFFER) != 0)
+ {
+ ACE_NEW_RETURN (this->offer_, ACE_URL_Offer, 0);
+ total_length += this->offer_->decode (cbuffer + total_length);
+ }
+
+ if ((this->valid_ptr_ & VALID_OFFERS) != 0)
+ {
+ size_t n;
+ DECODE_UINT32 (cbuffer, total_length, n);
+ ACE_NEW_RETURN (this->offers_, ACE_URL_Offer_Seq (n), 0);
+ total_length += ace_array_decode (cbuffer + total_length, *this->offers_);
+ }
+
+ ACE_ASSERT (total_length ==buf_size);
return 0;
}
size_t
-ACE_URL_Locator_Reply::bsize (void)
+ACE_URL_Locator_Reply::size (void)
{
- ACE_TRACE ("ACE_URL_Locator_Reply:bsize");
+ ACE_TRACE ("ACE_URL_Locator_Reply:size");
size_t total_length = 5 * sizeof (ACE_UINT32);
// size for 5 ACE_UINT32 objects: <buffer size>, <code_>,
@@ -360,12 +414,12 @@ ACE_URL_Locator_Reply::bsize (void)
if (this->offer_ != 0)
{
this->valid_ptr_ |= VALID_OFFER;
- total_length += this->offer_->bsize ();
+ total_length += this->offer_->size ();
}
if (this->offers_ != 0)
{
this->valid_ptr_ |= VALID_OFFERS;
- total_length += ace_array_bsize (this->offers_);
+ total_length += ace_array_size (*this->offers_);
}
return total_length;
}
@@ -375,5 +429,31 @@ ACE_URL_Locator_Reply::dump (void) const
{
//ACE_TRACE ("ACE_URL_Locator_Reply::dump");
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ if (this->code_ < ACE_URL_Locator::INVALID_OPERATION)
+ ACE_DEBUG ((LM_DEBUG, "Original request: %s\n", ACE_URL_Locator::opname[this->code_]));
+ else
+ ACE_DEBUG ((LM_DEBUG, "Invalid Original Request: %d\n", this->code_));
+
+ if (this->status_ < ACE_URL_Locator::MAX_URL_ERROR)
+ ACE_DEBUG ((LM_DEBUG, "Reply status: %s\n", ACE_URL_Locator::err_name[this->status_]));
+ else
+ ACE_DEBUG ((LM_DEBUG, "Invalid reply status: %d\n", this->status_));
+
+ ACE_DEBUG ((LM_DEBUG, "Number of offers: %d\n", this->num_offers_));
+
+ ACE_DEBUG ((LM_DEBUG, "Valid pointer pattern: %x\n", this->valid_ptr_));
+
+ ACE_DEBUG ((LM_DEBUG, "Offer: %x\n", this->offer_));
+ if (this->offer_ != 0)
+ this->offer_->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, "Offer sequence: %x\n", this->offers_));
+ if (this->offers_ != 0)
+ for (size_t i = 0; i < this->offers_->size (); i++)
+ (*this->offers_)[i].dump();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
#endif /* ACE_LOCATOR_REQUEST_REPLY_C */
diff --git a/apps/JAWS/clients/Caching/Locator_Request_Reply.h b/apps/JAWS/clients/Caching/Locator_Request_Reply.h
index 31f32c78a85..579ad82a5cd 100644
--- a/apps/JAWS/clients/Caching/Locator_Request_Reply.h
+++ b/apps/JAWS/clients/Caching/Locator_Request_Reply.h
@@ -20,7 +20,7 @@
#include "URL_Properties.h"
-class ACE_Export ACE_URL_Locator_Request
+class ACE_SVC_Export ACE_URL_Locator_Request
// = TITLE
// A URL request message formater/wrapper.
//
@@ -71,7 +71,9 @@ public:
size_t decode (void *buffer);
// Restore from network data. Returns size of the buffer
- // if succeed, 0 otherwise.
+ // if succeed, 0 otherwise. When passing in a buffer,
+ // caller must take the responsibility to delete the buffer
+ // afterward, if so needed.
const int how (void) const;
const int how_many (void) const;
@@ -89,7 +91,7 @@ public:
// Print out this object.
protected:
- size_t bsize (void);
+ size_t size (void);
// Return the size of the buffer required to encode
// this request.
@@ -131,7 +133,7 @@ protected:
// Buffer to store encoded data.
};
-class ACE_Export ACE_URL_Locator_Reply
+class ACE_SVC_Export ACE_URL_Locator_Reply
// = TITLE
// A URL reply message formater/wrapper.
//
@@ -140,6 +142,7 @@ class ACE_Export ACE_URL_Locator_Reply
// to transform reply messages to an object so that we can
// ship them across network.
{
+public:
ACE_URL_Locator_Reply (void);
// Default ctor.
@@ -163,7 +166,9 @@ class ACE_Export ACE_URL_Locator_Reply
size_t decode (void *buffer);
// Restore from network data. Returns size of the buffer
- // if succeed, 0 otherwise.
+ // if succeed, 0 otherwise. When passing in a buffer,
+ // caller must take the responsibility to delete the buffer
+ // afterward, if so needed.
// Accessor function.
const size_t num_offers (void) const;
@@ -177,7 +182,7 @@ class ACE_Export ACE_URL_Locator_Reply
// Print out this object.
protected:
- size_t bsize (void);
+ size_t size (void);
// Return the size of the buffer required to encode
// this request.
diff --git a/apps/JAWS/clients/Caching/URL_Array_Helper.cpp b/apps/JAWS/clients/Caching/URL_Array_Helper.cpp
index a2027d2b09b..0a0376e35af 100644
--- a/apps/JAWS/clients/Caching/URL_Array_Helper.cpp
+++ b/apps/JAWS/clients/Caching/URL_Array_Helper.cpp
@@ -4,17 +4,16 @@
#if !defined (ACE_URL_ARRAY_HELPER_C)
#define ACE_URL_ARRAY_HELPER_C
-#define ACE_BUILD_DLL
#include "URL_Array_Helper.h"
// Some helper functions for encoding/decoding
template <class T>
-size_t ace_array_bsize (const T &x)
+size_t ace_array_size (const T &x)
{
size_t sum = sizeof (ACE_UINT32);
for (size_t i = 0; i < x.size (); i++)
- sum += x[i].bsize ();
+ sum += x[i].size ();
return sum;
}
diff --git a/apps/JAWS/clients/Caching/URL_Array_Helper.h b/apps/JAWS/clients/Caching/URL_Array_Helper.h
index c59627c5721..08a261138fc 100644
--- a/apps/JAWS/clients/Caching/URL_Array_Helper.h
+++ b/apps/JAWS/clients/Caching/URL_Array_Helper.h
@@ -21,7 +21,7 @@
// You should find some way to avoid name space polution.
template <class T>
-size_t ace_array_bsize (const T &x);
+size_t ace_array_size (const T &x);
template <class T>
size_t ace_array_encode (void *buf, const T &x);
diff --git a/apps/JAWS/clients/Caching/URL_Locator.cpp b/apps/JAWS/clients/Caching/URL_Locator.cpp
index b7d00b104c1..1f25bd8bbab 100644
--- a/apps/JAWS/clients/Caching/URL_Locator.cpp
+++ b/apps/JAWS/clients/Caching/URL_Locator.cpp
@@ -5,18 +5,49 @@
#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
+const char * const
+ACE_URL_Locator::opname[] =
+// Human readable operation name
+{
+ "Query",
+ "Export",
+ "Withdraw",
+ "Describe",
+ "Modify",
+ "Invalid Operation"
+};
+
+const char * const
+ACE_URL_Locator::selection_name[] =
+{
+ "None",
+ "Some",
+ "All",
+ "Invalid Selection"
+};
+
+const char * const
+ACE_URL_Locator::err_name[] =
+{
+ "No error",
+ "Offer already exist",
+ "no such offer",
+ "invalid argument",
+ "function not implemented",
+ "unknown error"
+};
+
ACE_URL_Locator::~ACE_URL_Locator (void)
{
}
-char *
+const char *
ACE_URL_Locator::error_status (void)
{
return "Not implemented yet.";
diff --git a/apps/JAWS/clients/Caching/URL_Locator.h b/apps/JAWS/clients/Caching/URL_Locator.h
index 684829ebb4e..2b41cd5ed50 100644
--- a/apps/JAWS/clients/Caching/URL_Locator.h
+++ b/apps/JAWS/clients/Caching/URL_Locator.h
@@ -20,7 +20,7 @@
#include "URL_Properties.h"
-class ACE_Export ACE_URL_Locator
+class ACE_SVC_Export ACE_URL_Locator
// = TITLE
// Abstract Base class designates what interfaces a URL_Locator
// should provide.
@@ -36,7 +36,7 @@ public:
// Request type
enum ACE_URL_Locator_Op_Type
{
- QUERY,
+ QUERY = 0,
EXPORT,
WITHDRAW,
DESCRIBE,
@@ -44,18 +44,24 @@ public:
INVALID_OPERATION // LAST
};
+ static const char * const opname[];
+ // Human Readable operation name.
+
// = Specify how to select offers.
enum ACE_Selection_Criteria
{
- NONE, // URL that contains none of the properties.
+ NONE = 0, // URL that contains none of the properties.
SOME, // URL that contains some of the properties.
ALL, // URL that contains all of the properties.
INVALID_SELECTION // Invalid.
};
+ static const char * const selection_name[];
+
enum ACE_URL_Locator_Error
// errno will set to one of these value.
{
+ OK, // Everything is fine.
OFFER_EXIST, // trying to register an offer.
// that is already exist in repository.
NO_SUCH_OFFER, // No such offer in the repository.
@@ -64,7 +70,10 @@ public:
UNKNOWN, // Unknown error.
MAX_URL_ERROR
};
- // Possible error code of URL_Locator
+ // Possible error code of URL_Locator.
+
+ static const char * const err_name[];
+ // Human readable error status.
virtual ~ACE_URL_Locator (void) = 0;
// Default destructor.
@@ -91,7 +100,7 @@ public:
// Query a specific offer.
virtual int modify_offer (const ACE_WString &offer_id,
- const char *url = 0,
+ const ACE_WString *url = 0,
const ACE_URL_Property_Seq *del = 0,
const ACE_URL_Property_Seq *modify = 0) = 0;
// Modify a previously registered offer.
diff --git a/apps/JAWS/clients/Caching/URL_Properties.cpp b/apps/JAWS/clients/Caching/URL_Properties.cpp
index fa86934123e..afa650bee90 100644
--- a/apps/JAWS/clients/Caching/URL_Properties.cpp
+++ b/apps/JAWS/clients/Caching/URL_Properties.cpp
@@ -4,7 +4,6 @@
#if !defined (ACE_URL_PROPERTIES_C)
#define ACE_URL_PROPERTIES_C
-#define ACE_BUILD_DLL
#include "URL_Properties.h"
#if !defined (__ACE_INLINE__)
@@ -16,13 +15,13 @@
#include "URL_Array_Helper.h"
size_t
-ACE_WString_Helper::encode (void *buf, ACE_WString *wstr)
+ACE_WString_Helper::encode (void *buf, const ACE_WString &wstr)
{
ACE_USHORT16 *wptr = (ACE_USHORT16 *) buf;
size_t i;
- for (i= 0; i <= wstr->length (); i++)
- wptr[i] = htons ((*wstr)[i]);
+ for (i= 0; i <= wstr.length (); i++)
+ wptr[i] = htons (wstr[i]);
return i * sizeof (ACE_USHORT16);
}
@@ -39,12 +38,6 @@ ACE_WString_Helper::decode (void *buf)
return (i + 1) * sizeof (ACE_USHORT16);
}
-ACE_URL_Property::~ACE_URL_Property (void)
-{
- delete this->name_;
- delete this->value_;
-}
-
size_t
ACE_URL_Property::encode (void *buf) const
{
@@ -63,6 +56,7 @@ ACE_URL_Property::decode (void *buf)
cbuf += len;
len += ACE_WString_Helper::decode ((void *) cbuf);
+ this->value ((ACE_USHORT16 *) cbuf);
return len;
}
@@ -71,31 +65,26 @@ ACE_URL_Property::dump (void) const
{
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
- if (this->name_->length () > 0)
+ if (this->name_.length () > 0)
ACE_DEBUG ((LM_DEBUG, "\n name_: \"%s\"\n",
- ACE_Auto_Basic_Array_Ptr<char> (this->name_->char_rep ()).get ()));
+ ACE_Auto_Basic_Array_Ptr<char> (this->name_.char_rep ()).get ()));
else
ACE_DEBUG ((LM_DEBUG, "\n name_: \"\"\n"));
- if (this->value_->length () > 0)
+ if (this->value_.length () > 0)
ACE_DEBUG ((LM_DEBUG, " value_: \"%s\"\n",
- ACE_Auto_Basic_Array_Ptr<char> (this->value_->char_rep ()).get ()));
+ 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));
}
-ACE_URL_Offer::~ACE_URL_Offer (void)
-{
- delete this->url_;
-}
-
size_t
-ACE_URL_Offer::bsize (void) const
+ACE_URL_Offer::size (void) const
{
- size_t sum = (this->url_->length () + 1) * sizeof (ACE_USHORT16);
- sum += ::ace_array_bsize (this->prop_);
+ size_t sum = (this->url_.length () + 1) * sizeof (ACE_USHORT16);
+ sum += ::ace_array_size (this->prop_);
return sum;
}
@@ -135,9 +124,9 @@ ACE_URL_Offer::dump (void) const
{
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
- if (this->url_->length () > 0)
+ if (this->url_.length () > 0)
ACE_DEBUG ((LM_DEBUG, "\n url_: \"%s\"\n",
- ACE_Auto_Basic_Array_Ptr<char> (this->url_->char_rep ()).get ()));
+ ACE_Auto_Basic_Array_Ptr<char> (this->url_.char_rep ()).get ()));
else
ACE_DEBUG ((LM_DEBUG, "\n url_: \"\"\n"));
@@ -151,20 +140,20 @@ ACE_URL_Offer::dump (void) const
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 size_t ace_array_size (ACE_Array<ACE_URL_Property> &);
template size_t ace_array_encode (void *, ACE_Array<ACE_URL_Property> &);
template size_t ace_array_decode (void *, ACE_Array<ACE_URL_Property> &);
-template size_t ace_array_bsize (ACE_Array<ACE_URL_Offer> &);
+template size_t ace_array_size (ACE_Array<ACE_URL_Offer> &);
template size_t ace_array_encode (void *, ACE_Array<ACE_URL_Offer> &);
template size_t 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 size_t ace_array_size (ACE_Array<ACE_URL_Property> &)
#pragma instantiate size_t ace_array_encode (void *, ACE_Array<ACE_URL_Property> &)
#pragma instantiate size_t ace_array_decode (void *, ACE_Array<ACE_URL_Property> &)
-#pragma instantiate size_t ace_array_bsize (ACE_Array<ACE_URL_Offer> &)
+#pragma instantiate size_t ace_array_size (ACE_Array<ACE_URL_Offer> &)
#pragma instantiate size_t ace_array_encode (void *, ACE_Array<ACE_URL_Offer> &)
#pragma instantiate size_t ace_array_decode (void *, ACE_Array<ACE_URL_Offer> &)
#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/apps/JAWS/clients/Caching/URL_Properties.h b/apps/JAWS/clients/Caching/URL_Properties.h
index 6677222b3b3..ad490e5d285 100644
--- a/apps/JAWS/clients/Caching/URL_Properties.h
+++ b/apps/JAWS/clients/Caching/URL_Properties.h
@@ -21,7 +21,7 @@
#include "ace/SString.h"
#include "ace/Array.h"
-class ACE_Export ACE_WString_Helper
+class ACE_SVC_Export ACE_WString_Helper
// = TITLE
// Some helper functions for manipulate ACE_WString.
//
@@ -30,37 +30,39 @@ class ACE_Export ACE_WString_Helper
// ACE_WString objects for network communication.
{
public:
- static size_t bsize (const ACE_WString *wstr);
- // Returns the actual size required to contain the ACE_WString.
+ static size_t size (const ACE_WString &wstr);
+ // Returns the actual size (in bytes) required to contain the
+ // ACE_WString.
- static size_t encode (void *buf, ACE_WString *wstr);
+ static size_t encode (void *buf, const ACE_WString &wstr);
// Encode <wstr> into <buf> for network communication.
// Return total octets consumed.
static size_t decode (void *buf);
// This function doesn't relate to ACE_WString directly.
// It converts an ACE_USHORT16 string from network
- // byte order to host byte order. Returns bsize of the string.
+ // byte order to host byte order. Returns size of the string.
};
-class ACE_Export ACE_URL_Property
+class ACE_SVC_Export ACE_URL_Property
// = TITLE
// Defines a property of a URL.
//
// = DESCRIPTION
// A property contains a <name> and a <value>.
-// Nanbor, please add more description of what is typically *done* with a URL property.
+ // A URL may contain some properties and we can "locate"
+ // the URL's we are looking for by examming URL for certain
+ // properties that match our need.
{
public:
ACE_URL_Property (const char *name = 0,
const char *value=0);
- // Create a property.
+ // Create a new property.
ACE_URL_Property (const ACE_USHORT16 *name,
const ACE_USHORT16 *value);
- // Nanbor, please make sure that you comment these interfaces. In
- // particular, does this interface distinguish between UNICODE and
- // non-UNICODE?
+ // Create a new property using wchar strings. This is mostly used
+ // to support DBCS or UNICODE.
ACE_URL_Property (const ACE_URL_Property &p);
// Copy constructor.
@@ -78,25 +80,24 @@ public:
// Inequality operator.
// = Query property name.
- ACE_WString *name_rep (void);
- const ACE_WString *name (void) const;
+ ACE_WString &name_rep (void);
+ const ACE_WString &name (void) const;
// = Set property name.
void name (const ACE_USHORT16 *n);
void name (const char *n);
// = Query property value.
- ACE_WString *value_rep (void);
- const ACE_WString *value (void) const;
+ ACE_WString &value_rep (void);
+ const ACE_WString &value (void) const;
// = Set property value.
void value (const ACE_USHORT16 *v);
void value (const char *v);
// = Helper functions for encoding and decoding.
- size_t bsize (void) const;
- // Returns memory size required to encode this object.
- // Nanbor, can we make this <size> rather than <bsize>?
+ size_t size (void) const;
+ // Returns memory size (in bytes) required to encode this object.
size_t encode (void *buf) const;
// Encodes this object into buf for network transmission.
@@ -109,28 +110,25 @@ public:
// Dump out this object for debug.
protected:
- // Nanbor, is there a particular reason that you're using dynamic
- // memory allocation here? Can you just use instances of
- // ACE_WString that aren't allocated dynamically or is there some
- // reason why you need pointers?
- ACE_WString *name_;
+ ACE_WString name_;
// Property name pointer.
- ACE_WString *value_;
+ ACE_WString value_;
// Property value.
} ;
typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq;
-// type of URL_Property collection.
+// type of URL_Property collections.
-class ACE_Export ACE_URL_Offer
+class ACE_SVC_Export ACE_URL_Offer
// = TITLE
// Defines a URL offer.
//
// = DESCRIPTION
// A URL offer is defined by a <url> and an
- // <ACE_URL_Property_Seq>.
-// Nanbor, please explain how an offer is typically *used*.
+ // <ACE_URL_Property_Seq>. An offer is stored at server end
+ // thru registering or reported back to querying client from the
+ // sever.
{
public:
ACE_URL_Offer (const size_t size = 1, const char *url = 0);
@@ -152,8 +150,8 @@ public:
// Inequality operator.
// = Get URL string.
- ACE_WString *url_rep (void);
- const ACE_WString *url (void) const;
+ ACE_WString &url_rep (void);
+ const ACE_WString &url (void) const;
// = Set URL.
void url (const char *url);
@@ -167,9 +165,8 @@ public:
// copy of the passed in prop.
// = Helper functions for encoding and decoding.
- size_t bsize (void) const;
- // Returns memory size required to encode this object.
- // Nanbor, can you please make this <size>?
+ size_t size (void) const;
+ // Returns memory size (in bytes) required to encode this object.
size_t encode (void *buf) const;
// Encodes this object into buf for network transmission.
@@ -182,16 +179,15 @@ public:
// Dump this object for debug.
protected:
- ACE_WString *url_;
+ ACE_WString url_;
// URL of this offer.
ACE_URL_Property_Seq prop_;
// Properties associate with this offer.
};
-// Nanbor, please add a comment here.
-
typedef ACE_Array<ACE_URL_Offer> ACE_URL_Offer_Seq;
+// type of URL offer collections.
#if defined (__ACE_INLINE__)
#include "URL_Properties.i"
diff --git a/apps/JAWS/clients/Caching/URL_Properties.i b/apps/JAWS/clients/Caching/URL_Properties.i
index 63722c4e6f8..9e0cb59d03e 100644
--- a/apps/JAWS/clients/Caching/URL_Properties.i
+++ b/apps/JAWS/clients/Caching/URL_Properties.i
@@ -3,42 +3,45 @@
// $Id$
ACE_INLINE size_t
-ACE_WString_Helper::bsize (const ACE_WString *wstr)
+ACE_WString_Helper::size (const ACE_WString &wstr)
{
- return (wstr->length () + 1) * sizeof (ACE_USHORT16);
+ return (wstr.length () + 1) * sizeof (ACE_USHORT16);
}
ACE_INLINE
ACE_URL_Property::ACE_URL_Property (const char *name, const char *value)
+ : name_ (name),
+ value_ (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_ (name),
+ value_ (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_ (p.name_),
+ value_ (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)
+{
+}
+
ACE_INLINE ACE_URL_Property &
ACE_URL_Property::operator= (const ACE_URL_Property &rhs)
{
if (this != &rhs)
{
- delete this->name_;
- delete this->value_;
- ACE_NEW_RETURN (this->name_, ACE_WString(*rhs.name_), *this);
- ACE_NEW_RETURN (this->value_, ACE_WString(*rhs.value_), *this);
+ this->name_ = rhs.name_;
+ this->value_ = rhs.value_;
}
return *this;
}
@@ -46,8 +49,8 @@ ACE_URL_Property::operator= (const ACE_URL_Property &rhs)
ACE_INLINE int
ACE_URL_Property::operator== (const ACE_URL_Property &rhs) const
{
- if (this == &rhs || *this->name_ != *rhs.name_ ||
- *this->value_ != *rhs.value_)
+ if (this == &rhs || this->name_ != rhs.name_ ||
+ this->value_ != rhs.value_)
return 1;
else
return 0;
@@ -59,13 +62,13 @@ ACE_URL_Property::operator!= (const ACE_URL_Property &rhs) const
return !(*this == rhs);
}
-ACE_INLINE ACE_WString *
+ACE_INLINE ACE_WString &
ACE_URL_Property::name_rep (void)
{
return this->name_;
}
-ACE_INLINE const ACE_WString *
+ACE_INLINE const ACE_WString &
ACE_URL_Property::name (void) const
{
return this->name_;
@@ -74,24 +77,22 @@ ACE_URL_Property::name (void) const
ACE_INLINE void
ACE_URL_Property::name (const char *n)
{
- delete this->name_;
- ACE_NEW (this->name_, ACE_WString (n));
+ this->name_ = ACE_WString (n);
}
ACE_INLINE void
ACE_URL_Property::name (const ACE_USHORT16 *n)
{
- delete this->name_;
- ACE_NEW (this->name_, ACE_WString (n));
+ this->name_ = ACE_WString (n);
}
-ACE_INLINE ACE_WString *
+ACE_INLINE ACE_WString &
ACE_URL_Property::value_rep (void)
{
return this->value_;
}
-ACE_INLINE const ACE_WString *
+ACE_INLINE const ACE_WString &
ACE_URL_Property::value (void) const
{
return this->value_;
@@ -100,34 +101,41 @@ ACE_URL_Property::value (void) const
ACE_INLINE void
ACE_URL_Property::value (const char *v)
{
- delete this->value_;
- ACE_NEW (this->value_, ACE_WString (v));
+ this->value_ = ACE_WString (v);
}
ACE_INLINE void
ACE_URL_Property::value (const ACE_USHORT16 *v)
{
- delete this->value_;
- ACE_NEW (this->value_, ACE_WString (v));
+ this->value_ = ACE_WString (v);
}
ACE_INLINE size_t
-ACE_URL_Property::bsize (void) const
+ACE_URL_Property::size (void) const
{
size_t len = 2;
- if (this->name_ != 0)
- len += this->name_->length ();
- if (this->value_ != 0)
- len += this->value_->length ();
+ len += this->name_.length () + this->value_.length ();
return len * sizeof (ACE_USHORT16);
}
ACE_INLINE
ACE_URL_Offer::ACE_URL_Offer (const size_t size, const char *url)
- : prop_ (size)
+ : url_ (url),
+ prop_ (size)
+{
+}
+
+ACE_INLINE
+ACE_URL_Offer::ACE_URL_Offer (const ACE_URL_Offer &o)
+ : url_ (o.url_),
+ prop_ (o.prop_)
+{
+}
+
+ACE_INLINE
+ACE_URL_Offer::~ACE_URL_Offer (void)
{
- ACE_NEW (this->url_, ACE_WString (url));
}
ACE_INLINE ACE_URL_Offer &
@@ -135,7 +143,7 @@ ACE_URL_Offer::operator= (const ACE_URL_Offer &rhs)
{
if (this != &rhs)
{
- *this->url_ = *rhs.url_;
+ this->url_ = rhs.url_;
this->prop_ = rhs.prop_;
}
return *this;
@@ -158,13 +166,13 @@ ACE_URL_Offer::operator!= (const ACE_URL_Offer &rhs) const
return !(*this == rhs);
}
-ACE_INLINE ACE_WString *
+ACE_INLINE ACE_WString &
ACE_URL_Offer::url_rep (void)
{
return this->url_;
}
-ACE_INLINE const ACE_WString *
+ACE_INLINE const ACE_WString &
ACE_URL_Offer::url (void) const
{
return this->url_;
@@ -173,15 +181,13 @@ ACE_URL_Offer::url (void) const
ACE_INLINE void
ACE_URL_Offer::url (const ACE_USHORT16 *url)
{
- delete this->url_;
- ACE_NEW (this->url_, ACE_WString (url));
+ this->url_ = ACE_WString (url);
}
ACE_INLINE void
ACE_URL_Offer::url (const char *url)
{
- delete this->url_;
- ACE_NEW (this->url_, ACE_WString (url));
+ this->url_ = ACE_WString (url);
}
ACE_INLINE ACE_URL_Property_Seq &
diff --git a/apps/JAWS/clients/Caching/test_URL.cpp b/apps/JAWS/clients/Caching/test_URL.cpp
new file mode 100644
index 00000000000..2685a135eee
--- /dev/null
+++ b/apps/JAWS/clients/Caching/test_URL.cpp
@@ -0,0 +1,31 @@
+#include "ace/streams.h"
+#include "Locator_Request_Reply.h"
+
+int main (int argc, char *argv[])
+{
+ ACE_UNUSED_ARG (argc);
+ ACE_UNUSED_ARG (argv);
+
+ ACE_URL_Locator_Request original, derived;
+
+ ACE_URL_Property_Seq ouch1(3);
+ ouch1[0].name ("name 1");
+ ouch1[0].value ("value 1");
+ ouch1[1].name ("name 2");
+ ouch1[1].value ("value 2");
+ ouch1[2].name ("name 3");
+ ouch1[2].value ("value 3");
+
+ original.url_query (1, ouch1, 3);
+
+ original.dump ();
+ derived.dump ();
+
+ original.encode ();
+
+ derived.decode ((void*) original.buffer ());
+
+ derived.dump ();
+
+ return 0;
+}