5 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
6 * @author Krishnakumar B <kitty@cs.wustl.edu>
9 #ifndef _ACEXML_URL_ADDR_H
10 #define _ACEXML_URL_ADDR_H
12 #include /**/ "ace/pre.h"
13 #include "ACEXML/common/ACEXML_Export.h"
15 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 #endif /* ACE_LACKS_PRAGMA_ONCE */
19 #include "ace/Default_Constants.h"
20 #include "ace/INET_Addr.h"
21 #include "ACEXML/common/XML_Types.h"
22 #include "ACEXML/common/ACEXML_Export.h"
25 * @class ACEXML_URL_Addr
27 * Defines a URL address family address format.
29 class ACEXML_Export ACEXML_URL_Addr
: public ACE_INET_Addr
32 /// Initialization and termination methods.
36 ACEXML_URL_Addr (const ACEXML_Char
*host_name
,
37 const ACEXML_Char
*path_name
,
38 unsigned short port
= ACE_DEFAULT_HTTP_PORT
);
41 ACEXML_URL_Addr (const ACEXML_URL_Addr
&addr
);
43 /// Essentially the copy constructor.
44 int set (const ACEXML_URL_Addr
&addr
);
47 * Initializes an <ACEXML_URL_Addr> from the <address>, which can be
48 * "ip-number:port-number/path-name" (e.g.,
49 * "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name"
50 * (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in the
51 * <address> it is assumed to be an ip-number or ip-address number, with
52 * the port number <ACE_DEFAULT_HTTP_PORT>.
54 virtual int string_to_addr (const ACEXML_Char
* address
,
55 int address_family
= AF_UNSPEC
);
57 // Function to shut up Borland C++
58 #if defined (ACE_USES_WCHAR)
59 virtual int string_to_addr (const char* addresss
,
60 int address_family
= AF_UNSPEC
);
64 * Transform the current <ACE_INET_Addr> address into string format. If
65 * <ipaddr_format> is non-0 this produces
66 * "ip-number:port-number/path-name" (e.g.,
67 * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
68 * produces "ip-name:port-number" (e.g.,
69 * "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the <size> of the
70 * <buffer> is too small, else 0.
72 virtual int addr_to_string (ACEXML_Char
*s
,
74 int ipaddr_format
= 1) const;
77 * Transform the current ACE_INET_Addr address into string format. If
78 * @a ipaddr_format is non-0 this produces
79 * "ip-number:port-number/path-name" (e.g.,
80 * "128.252.166.57:80/~schmidt/"), whereas if @a ipaddr_format is 0 this
81 * produces "ip-name:port-number" (e.g.,
82 * "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which is
83 * allocated on demand and deallocated when the object is destroyed.
84 * Returns -1 if dynamic memory fails, else 0.
86 virtual const ACEXML_Char
*addr_to_string (int ipaddr_format
= 1);
88 /// Assignment operator.
89 void operator= (const ACEXML_URL_Addr
&addr
);
95 * Compare two addresses for equality. The addresses are considered
96 * equal if they contain the same IP address, port number, and path name.
98 bool operator == (const ACEXML_URL_Addr
&SAP
) const;
100 /// Compare two addresses for inequality.
101 bool operator != (const ACEXML_URL_Addr
&SAP
) const;
103 /// Computes and returns hash value.
104 virtual u_long
hash () const;
106 /// Return the path name.
107 const ACEXML_Char
*get_path_name () const;
113 /// Calculate the maximum length of the address string
114 size_t calculate_length (int ipaddr_format
) const;
117 ACEXML_Char
*path_name_
;
119 /// The dynamically created address string that's used for the
120 /// <addr_to_string> method.
121 ACEXML_Char
*addr_string_
;
123 /// Current length of the <addr_string_>
124 size_t addr_string_len_
;
127 #if defined (__ACEXML_INLINE__)
128 # include "ACEXML/common/URL_Addr.inl"
129 #endif /* __ACEXML_INLINE__ */
131 #include /**/ "ace/post.h"
133 #endif /* _ACEXML_URL_ADDR_H */