Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / apps / JAWS / clients / Caching / URL_Properties.h
blobad4ec19e919ab0557ed2260ca18e7d6decf74486
1 // -*- C++ -*-
4 //=============================================================================
5 /**
6 * @file URL_Properties.h
8 * @author Nanbor Wang
9 */
10 //=============================================================================
13 #ifndef ACE_URL_PROPERTIES_H
14 #define ACE_URL_PROPERTIES_H
16 #include "ace/SString.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/Containers.h"
24 /**
25 * @class ACE_WString_Helper
27 * @brief Some helper functions for manipulate ACE_WString.
29 * These functions simplify encoding/decoding of
30 * ACE_WString objects for network communication.
32 class ACE_Svc_Export ACE_WString_Helper
34 public:
35 /// Returns the actual size (in bytes) required to contain the
36 /// ACE_WString.
37 static size_t size (const ACE_WString &wstr);
39 /// Encode <wstr> into <buf> for network communication.
40 /// Return total octets consumed.
41 static size_t encode (void *buf, const ACE_WString &wstr);
43 /**
44 * This function doesn't relate to ACE_WString directly.
45 * It converts an ACE_UINT16 string from network
46 * byte order to host byte order. Returns size of the string.
48 static size_t decode (void *buf);
51 /**
52 * @class ACE_URL_Property
54 * @brief Defines a property of a URL.
56 * A property contains a <name> and a <value>.
57 * A URL may contain some properties and we can "locate"
58 * the URL's we are looking for by examming URL for certain
59 * properties that match our need.
61 class ACE_Svc_Export ACE_URL_Property
63 public:
64 /// Create a new property.
65 ACE_URL_Property (const char *name = 0,
66 const char *value=0);
68 /// Create a new property using wchar strings. This is mostly used
69 /// to support DBCS or UNICODE.
70 ACE_URL_Property (const ACE_UINT16 *name,
71 const ACE_UINT16 *value);
73 /// Copy constructor.
74 ACE_URL_Property (const ACE_URL_Property &p);
76 /// Destructor.
77 ~ACE_URL_Property ();
79 /// Assignment operator.
80 ACE_URL_Property &operator= (const ACE_URL_Property &rhs);
82 /// Equals operator.
83 bool operator== (const ACE_URL_Property &rhs) const;
85 /// Inequality operator.
86 bool operator!= (const ACE_URL_Property &rhs) const;
88 // = Query property name.
89 ACE_WString &name_rep ();
90 const ACE_WString &name () const;
92 // = Set property name.
93 void name (const ACE_UINT16 *n);
94 void name (const char *n);
96 // = Query property value.
97 ACE_WString &value_rep ();
98 const ACE_WString &value () const;
100 // = Set property value.
101 void value (const ACE_UINT16 *v);
102 void value (const char *v);
104 // = Helper functions for encoding and decoding.
105 /// Returns memory size (in bytes) required to encode this object.
106 size_t size () const;
108 /// Encodes this object into buf for network transmission.
109 size_t encode (void *buf) const;
111 /// Decodes buf and modifies this object, you should
112 /// probably create this with default ctor.
113 size_t decode (void *buf);
115 /// Dump out this object for debug.
116 void dump () const;
118 protected:
119 /// Property name pointer.
120 ACE_WString name_;
122 /// Property value.
123 ACE_WString value_;
126 typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq;
127 // type of URL_Property collections.
130 * @class ACE_URL_Offer
132 * @brief Defines a URL offer.
134 * A URL offer is defined by a <url> and an
135 * <ACE_URL_Property_Seq>. An offer is stored at server end
136 * thru registering or reported back to querying client from the
137 * sever.
139 class ACE_Svc_Export ACE_URL_Offer
141 public:
142 /// Create an offer.
143 ACE_URL_Offer (const size_t size = 1, const char *url = 0);
145 /// Copy ctor.
146 ACE_URL_Offer (const ACE_URL_Offer &o);
148 /// Default destructor.
149 ~ACE_URL_Offer ();
151 /// Assignment operator.
152 ACE_URL_Offer &operator= (const ACE_URL_Offer &rhs);
154 /// Equality operator.
155 bool operator== (const ACE_URL_Offer &rhs) const;
157 /// Inequality operator.
158 bool operator!= (const ACE_URL_Offer &rhs) const;
160 // = Get URL string.
161 ACE_WString &url_rep ();
162 const ACE_WString &url () const;
164 // = Set URL.
165 void url (const char *url);
166 void url (const ACE_UINT16 *url);
168 /// Get properties of this offer.
169 ACE_URL_Property_Seq &url_properties ();
171 /// Set properties of this offer. This operation virtually get a
172 /// copy of the passed in prop.
173 void url_properties (const ACE_URL_Property_Seq &prop);
175 // = Helper functions for encoding and decoding.
176 /// Returns memory size (in bytes) required to encode this object.
177 size_t size () const;
179 /// Encodes this object into buf for network transmission.
180 size_t encode (void *buf) const;
182 /// Decodes buf into current object, you better use
183 /// the default ctor.
184 size_t decode (void *buf);
186 /// Dump this object for debug.
187 void dump () const;
189 protected:
190 /// URL of this offer.
191 ACE_WString url_;
193 /// Properties associate with this offer.
194 ACE_URL_Property_Seq prop_;
197 typedef ACE_Array<ACE_URL_Offer> ACE_URL_Offer_Seq;
198 // type of URL offer collections.
200 #if defined (__ACE_INLINE__)
201 #include "URL_Properties.inl"
202 #endif /* __ACE_INLINE__ */
204 #endif /* ACE_WEB_PROPERTIES_H */