Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Web_Crawler / URL_Addr.h
blob2b27dd181dfc536771c53c6a6c6b1365d741cc4b
1 // -*- C++ -*-
4 //=============================================================================
5 /**
6 * @file URL_Addr.h
8 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 */
10 //=============================================================================
13 #ifndef ACE_URL_ADDR_H
14 #define ACE_URL_ADDR_H
16 #include "ace/INET_Addr.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/ACE.h"
24 /**
25 * @class ACE_URL_Addr
27 * @brief Defines a URL address family address format.
29 class ACE_URL_Addr : public ACE_INET_Addr
31 public:
32 /// Constructor.
33 ACE_URL_Addr ();
35 ACE_URL_Addr (const ACE_TCHAR *host_name,
36 const ACE_TCHAR *path_name,
37 u_short port = ACE_DEFAULT_HTTP_PORT);
39 /// Copy constructor.
40 ACE_URL_Addr (const ACE_URL_Addr &addr);
42 /// Essentially the copy constructor.
43 int set (const ACE_URL_Addr &addr);
45 /**
46 * Initializes an ACE_URL_Addr from the @a address, which can be
47 * "ip-number:port-number/path-name" (e.g.,
48 * "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name"
49 * (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in
50 * the @a address it is assumed to be an ip-number or ip-address
51 * number, with the port number ACE_DEFAULT_HTTP_PORT.
53 virtual int string_to_addr (const ACE_TCHAR *address,
54 int address_family = AF_UNSPEC);
56 /**
57 * Transform the current ACE_INET_Addr address into string format.
58 * If @a ipaddr_format is non-0 this produces
59 * "ip-number:port-number/path-name" (e.g.,
60 * "128.252.166.57:80/~schmidt/"), whereas if @a ipaddr_format is 0
61 * this produces "ip-name:port-number" (e.g.,
62 * "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the @a size of
63 * the <buffer> is too small, else 0.
65 virtual int addr_to_string (ACE_TCHAR *s,
66 size_t size,
67 int ipaddr_format = 1) const;
69 /**
70 * Transform the current <ACE_INET_Addr> address into string format.
71 * If <ipaddr_format> is non-0 this produces
72 * "ip-number:port-number/path-name" (e.g.,
73 * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0
74 * this produces "ip-name:port-number" (e.g.,
75 * "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which
76 * is allocated on demand and deallocated when the object is
77 * destroyed. Returns -1 if dynamic memory fails, else 0.
79 virtual const ACE_TCHAR *addr_to_string (int ipaddr_format = 1) const;
81 /// Assignment operator.
82 void operator= (const ACE_URL_Addr &addr);
84 /// Destructor.
85 ~ACE_URL_Addr ();
87 /**
88 * Compare two addresses for equality. The addresses are considered
89 * equal if they contain the same IP address, port number, and path
90 * name.
92 bool operator == (const ACE_URL_Addr &SAP) const;
94 /// Compare two addresses for inequality.
95 bool operator != (const ACE_URL_Addr &SAP) const;
97 /// Computes and returns hash value.
98 virtual u_long hash () const;
100 /// Return the path name.
101 const ACE_TCHAR *get_path_name () const;
103 /// Commit suicide.
104 int destroy ();
105 private:
106 /// Our path name.
107 ACE_TCHAR *path_name_;
109 /// The dynamically address string that's used for the
110 /// <addr_to_string> method.
111 ACE_TCHAR *addr_string_;
113 /// Current length of the <addr_string_>
114 size_t addr_string_len_;
117 #endif /* ACE_URL_ADDR_H */