URL_Addr.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /** @file   URL_Addr.h
00004  *
00005  *  $Id: URL_Addr.h 78637 2007-06-28 16:15:15Z mesnier_p $
00006  *
00007  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00008  *  @author Krishnakumar B <kitty@cs.wustl.edu>
00009  *
00010  */
00011 
00012 #ifndef _ACEXML_URL_ADDR_H
00013 #define _ACEXML_URL_ADDR_H
00014 
00015 #include /**/ "ace/pre.h"
00016 #include "ACEXML/common/ACEXML_Export.h"
00017 
00018 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00019 #pragma once
00020 #endif /* ACE_LACKS_PRAGMA_ONCE */
00021 
00022 #include "ace/Default_Constants.h"
00023 #include "ace/INET_Addr.h"
00024 #include "ACEXML/common/XML_Types.h"
00025 #include "ACEXML/common/ACEXML_Export.h"
00026 
00027 /**
00028  *  @class ACEXML_URL_Addr URL_Addr.h "ACEXML/common/URL_Addr.h"
00029  *
00030  *  Defines a URL address family address format.
00031  */
00032 class ACEXML_Export ACEXML_URL_Addr : public ACE_INET_Addr
00033 {
00034 public:
00035   /// Initialization and termination methods.
00036   ACEXML_URL_Addr (void);
00037 
00038   /// Constructor.
00039   ACEXML_URL_Addr (const ACEXML_Char *host_name,
00040                    const ACEXML_Char *path_name,
00041                    unsigned short port = ACE_DEFAULT_HTTP_PORT);
00042 
00043   /// Copy constructor.
00044   ACEXML_URL_Addr (const ACEXML_URL_Addr &addr);
00045 
00046   /// Essentially the copy constructor.
00047   int set (const ACEXML_URL_Addr &addr);
00048 
00049   /**
00050    *  Initializes an <ACEXML_URL_Addr> from the <address>, which can be
00051    *  "ip-number:port-number/path-name" (e.g.,
00052    *  "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name"
00053    *  (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in the
00054    *  <address> it is assumed to be an ip-number or ip-address number, with
00055    *  the port number <ACE_DEFAULT_HTTP_PORT>.
00056    */
00057   virtual int string_to_addr (const ACEXML_Char* address,
00058                               int address_family = AF_UNSPEC);
00059 
00060   //  Function to shut up Borland C++
00061 #if defined (ACE_USES_WCHAR)
00062   virtual int string_to_addr (const char* addresss,
00063                               int address_family = AF_UNSPEC);
00064 #endif
00065 
00066   /**
00067    *  Transform the current <ACE_INET_Addr> address into string format. If
00068    *  <ipaddr_format> is non-0 this produces
00069    *  "ip-number:port-number/path-name" (e.g.,
00070    *  "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
00071    *  produces "ip-name:port-number" (e.g.,
00072    *  "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the <size> of the
00073    *  <buffer> is too small, else 0.
00074    */
00075   virtual int addr_to_string (ACEXML_Char *s,
00076                               size_t size,
00077                               int ipaddr_format = 1) const;
00078 
00079   /**
00080    *  Transform the current <ACE_INET_Addr> address into string format. If
00081    *  <ipaddr_format> is non-0 this produces
00082    *  "ip-number:port-number/path-name" (e.g.,
00083    *  "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
00084    *  produces "ip-name:port-number" (e.g.,
00085    *  "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which is
00086    *  allocated on demand and deallocated when the object is destroyed.
00087    *  Returns -1 if dynamic memory fails, else 0.
00088    */
00089   virtual const ACEXML_Char *addr_to_string (int ipaddr_format = 1);
00090 
00091   /// Assignment operator.
00092   void operator= (const ACEXML_URL_Addr &addr);
00093 
00094   /// Destructor.
00095   ~ACEXML_URL_Addr (void);
00096 
00097   /**
00098    *  Compare two addresses for equality.  The addresses are considered
00099    *  equal if they contain the same IP address, port number, and path name.
00100    */
00101   bool operator == (const ACEXML_URL_Addr &SAP) const;
00102 
00103   /// Compare two addresses for inequality.
00104   bool operator != (const ACEXML_URL_Addr &SAP) const;
00105 
00106   /// Computes and returns hash value.
00107   virtual u_long hash (void) const;
00108 
00109   /// Return the path name.
00110   const ACEXML_Char *get_path_name (void) const;
00111 
00112   /// Commit suicide.
00113   int destroy (void);
00114 
00115 private:
00116 
00117   /// Calculate the maximum length of the address string
00118   size_t calculate_length (int ipaddr_format) const;
00119 
00120   /// Our path name.
00121   ACEXML_Char *path_name_;
00122 
00123   /// The dynamically created address string that's used for the
00124   /// <addr_to_string> method.
00125   ACEXML_Char *addr_string_;
00126 
00127   /// Current length of the <addr_string_>
00128   size_t addr_string_len_;
00129 };
00130 
00131 #if defined (__ACEXML_INLINE__)
00132 # include "ACEXML/common/URL_Addr.inl"
00133 #endif /* __ACEXML_INLINE__ */
00134 
00135 #include /**/ "ace/post.h"
00136 
00137 #endif /* _ACEXML_URL_ADDR_H */

Generated on Sun Jan 27 13:04:15 2008 for ACEXML by doxygen 1.3.6