Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

URL_Addr.h

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

Generated on Mon Jun 16 13:23:27 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002