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