summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/Caching/URL_Properties.h
blob: 6677222b3b307a732ba5fc34b6f3c36d3dfdcbf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* -*- C++ -*- */

// $Id$

// ============================================================================
//
// = LIBRARY
//    none
//
// = FILENAME
//    URL_Locator.h
//
// = AUTHOR
//    Nanbor Wang
//
// ============================================================================

#if !defined (ACE_URL_PROPERTIES_H)
#define ACE_URL_PROPERTIES_H

#include "ace/SString.h"
#include "ace/Array.h"

class ACE_Export ACE_WString_Helper
  // = TITLE
  //     Some helper functions for manipulate ACE_WString.
  //
  // = DESCRIPTION
  //     These functions simplify encoding/decoding of
  //     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 encode (void *buf, 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.
};

class ACE_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.
{
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);
  // Nanbor, please make sure that you comment these interfaces.  In
  // particular, does this interface distinguish between UNICODE and
  // non-UNICODE?

  ACE_URL_Property (const ACE_URL_Property &p);
  // Copy constructor.
  
  ~ACE_URL_Property (void);
  // Destructor.

  ACE_URL_Property &operator= (const ACE_URL_Property &rhs);
  // Assignment operator.

  int operator== (const ACE_URL_Property &rhs) const;
  // Equals operator.

  int operator!= (const ACE_URL_Property &rhs) const;
  // Inequality operator.

  // = Query property name.
  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;

  // = 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 encode (void *buf) const;
  // Encodes this object into buf for network transmission.

  size_t decode (void *buf);
  // Decodes buf and modifies this object, you should
  // probably create this with default ctor.  

  void dump (void) const;
  // 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_;
  // Property name pointer.
  
  ACE_WString *value_;
  // Property value.
} ;

typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq;
// type of URL_Property collection.

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>.
// Nanbor, please explain how an offer is typically *used*.
{
public:
  ACE_URL_Offer (const size_t size = 1, const char *url = 0);
  // Create an offer.

  ACE_URL_Offer (const ACE_URL_Offer &o);
  // Copy ctor.

  ~ACE_URL_Offer (void);
  // Default destructor.

  ACE_URL_Offer &operator= (const ACE_URL_Offer &rhs);
  // Assignment operator.

  int operator== (const ACE_URL_Offer &rhs) const;
  // Equality operator.

  int operator!= (const ACE_URL_Offer &rhs) const;
  // Inequality operator.

  // = Get URL string.
  ACE_WString *url_rep (void);
  const ACE_WString *url (void) const;

  // = Set URL.
  void url (const char *url);
  void url (const ACE_USHORT16 *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.  This operation virtually get a
  // 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 encode (void *buf) const;
  // Encodes this object into buf for network transmission.

  size_t decode (void *buf);
  // Decodes buf into current object, you better use
  // the default ctor.

  void dump (void) const;
  // Dump this object for debug.

protected:
  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;

#if defined (__ACE_INLINE__)
#include "URL_Properties.i"
#endif /* __ACE_INLINE__ */

#endif /* ACE_WEB_PROPERTIES_H */