1 /******************************************************************************* 2 3 copyright: Copyright (c) 2004 Kris Bell. All rights reserved 4 5 license: BSD style: $(LICENSE) 6 7 version: Initial release: April 2004 8 9 author: Kris 10 11 *******************************************************************************/ 12 13 module tango.net.model.UriView; 14 15 /******************************************************************************* 16 17 Implements an RFC 2396 compliant URI specification. See 18 <A HREF="http://ftp.ics.uci.edu/pub/ietf/uri/rfc2396.txt">this page</A> 19 for more information. 20 21 The implementation fails the spec on two counts: it doesn't insist 22 on a scheme being present in the UriView, and it doesn't implement the 23 "Relative References" support noted in section 5.2. 24 25 Note that IRI support can be implied by assuming each of userinfo, path, 26 query, and fragment are UTF-8 encoded 27 (see <A HREF="http://www.w3.org/2001/Talks/0912-IUC-IRI/paper.html"> 28 this page</A> for further details). 29 30 Use a Uri instead where you need to alter specific uri attributes. 31 32 *******************************************************************************/ 33 34 abstract class UriView 35 { 36 public alias port getPort; 37 public alias defaultPort getDefaultPort; 38 public alias scheme getScheme; 39 public alias host getHost; 40 public alias validPort getValidPort; 41 public alias userinfo getUserInfo; 42 public alias path getPath; 43 public alias query getQuery; 44 public alias fragment getFragment; 45 public alias port setPort; 46 public alias scheme setScheme; 47 public alias host setHost; 48 public alias userinfo setUserInfo; 49 public alias query setQuery; 50 public alias path setPath; 51 public alias fragment setFragment; 52 53 public enum {InvalidPort = -1} 54 55 /*********************************************************************** 56 57 Return the default port for the given scheme. InvalidPort 58 is returned if the scheme is unknown, or does not accept 59 a port. 60 61 ***********************************************************************/ 62 63 abstract const int defaultPort (const(char)[] scheme); 64 65 /*********************************************************************** 66 67 Return the parsed scheme, or null if the scheme was not 68 specified 69 70 ***********************************************************************/ 71 72 abstract const const(char)[] scheme(); 73 74 /*********************************************************************** 75 76 Return the parsed host, or null if the host was not 77 specified 78 79 ***********************************************************************/ 80 81 abstract const const(char)[] host(); 82 83 /*********************************************************************** 84 85 Return the parsed port number, or InvalidPort if the port 86 was not provided. 87 88 ***********************************************************************/ 89 90 abstract const int port(); 91 92 /*********************************************************************** 93 94 Return a valid port number by performing a lookup on the 95 known schemes if the port was not explicitly specified. 96 97 ***********************************************************************/ 98 99 abstract const int validPort(); 100 101 /*********************************************************************** 102 103 Return the parsed userinfo, or null if userinfo was not 104 provided. 105 106 ***********************************************************************/ 107 108 abstract const const(char)[] userinfo(); 109 110 /*********************************************************************** 111 112 Return the parsed path, or null if the path was not 113 provided. 114 115 ***********************************************************************/ 116 117 abstract const const(char)[] path(); 118 119 /*********************************************************************** 120 121 Return the parsed query, or null if a query was not 122 provided. 123 124 ***********************************************************************/ 125 126 abstract const const(char)[] query(); 127 128 /*********************************************************************** 129 130 Return the parsed fragment, or null if a fragment was not 131 provided. 132 133 ***********************************************************************/ 134 135 abstract const const(char)[] fragment(); 136 137 /*********************************************************************** 138 139 Return whether or not the UriView scheme is considered generic. 140 141 ***********************************************************************/ 142 143 abstract const bool isGeneric (); 144 145 /*********************************************************************** 146 147 Emit the content of this UriView. Output is constructed per 148 RFC 2396. 149 150 ***********************************************************************/ 151 152 //abstract immutable(char)[] toString (); 153 } 154