aboutsummaryrefslogtreecommitdiff
path: root/src/url.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
commit393f1b414746a7f1977971dd7659dd2b47092b11 (patch)
tree81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/url.cpp
parentc259f95bd0e58b247940a339bb9b4b401b4e9438 (diff)
parent7e25a863325dc3e9762397e700030969e093b087 (diff)
downloadlibbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically update your projects.
Diffstat (limited to '')
-rw-r--r--src/url.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/url.cpp b/src/url.cpp
index 1f9f563..7b4a48e 100644
--- a/src/url.cpp
+++ b/src/url.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2010 Xagasoft, All rights reserved. 2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 * 3 *
4 * This file is part of the libbu++ library and is released under the 4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
@@ -21,7 +21,7 @@ Bu::Url::Url()
21{ 21{
22} 22}
23 23
24Bu::Url::Url( const Bu::FString &sUrl ) 24Bu::Url::Url( const Bu::String &sUrl )
25{ 25{
26 parseUrl( sUrl ); 26 parseUrl( sUrl );
27} 27}
@@ -30,22 +30,22 @@ Bu::Url::~Url()
30{ 30{
31} 31}
32 32
33void Bu::Url::parseUrl( const Bu::FString &sUrl ) 33void Bu::Url::parseUrl( const Bu::String &sUrl )
34{ 34{
35 clear(); 35 clear();
36 36
37 Bu::FString::const_iterator i = sUrl.begin(); 37 Bu::String::const_iterator i = sUrl.begin();
38 parseProtocol( i ); 38 parseProtocol( i );
39 parseUserPass( i ); 39 parseUserPass( i );
40 parseHost( i ); 40 parseHost( i );
41 parsePath( i ); 41 parsePath( i );
42} 42}
43 43
44Bu::FString Bu::Url::decode( const Bu::FString &sStr ) 44Bu::String Bu::Url::decode( const Bu::String &sStr )
45{ 45{
46 Bu::FString sRet; 46 Bu::String sRet;
47 char buf[3] = {0, 0, 0}; 47 char buf[3] = {0, 0, 0};
48 for( Bu::FString::const_iterator i = sStr.begin(); i; i++ ) 48 for( Bu::String::const_iterator i = sStr.begin(); i; i++ )
49 { 49 {
50 if( *i == '+' ) 50 if( *i == '+' )
51 { 51 {
@@ -67,10 +67,10 @@ Bu::FString Bu::Url::decode( const Bu::FString &sStr )
67 return sRet; 67 return sRet;
68} 68}
69 69
70Bu::FString Bu::Url::encode( const Bu::FString &sStr ) 70Bu::String Bu::Url::encode( const Bu::String &sStr )
71{ 71{
72 Bu::FString sRet; 72 Bu::String sRet;
73 for( Bu::FString::const_iterator i = sStr.begin(); i; i++ ) 73 for( Bu::String::const_iterator i = sStr.begin(); i; i++ )
74 { 74 {
75 if( *i == ' ' ) 75 if( *i == ' ' )
76 { 76 {
@@ -96,17 +96,17 @@ Bu::FString Bu::Url::encode( const Bu::FString &sStr )
96 return sRet; 96 return sRet;
97} 97}
98 98
99void Bu::Url::parseProtocol( Bu::FString::const_iterator &i ) 99void Bu::Url::parseProtocol( Bu::String::const_iterator &i )
100{ 100{
101 Bu::FString::const_iterator s = i.find("://", 3); 101 Bu::String::const_iterator s = i.find("://", 3);
102 if( !s ) 102 if( !s )
103 throw Bu::ExceptionBase("No :// in url"); 103 throw Bu::ExceptionBase("No :// in url");
104 Bu::FString sTmp( i, s ); 104 Bu::String sTmp( i, s );
105 setProtocol( sTmp ); 105 setProtocol( sTmp );
106 i = s + 3; 106 i = s + 3;
107} 107}
108 108
109void Bu::Url::setProtocol( const Bu::FString &sNewProto, bool bAutoSetPort ) 109void Bu::Url::setProtocol( const Bu::String &sNewProto, bool bAutoSetPort )
110{ 110{
111 sProtocol = sNewProto; 111 sProtocol = sNewProto;
112#ifndef WIN32 112#ifndef WIN32
@@ -121,13 +121,13 @@ void Bu::Url::setProtocol( const Bu::FString &sNewProto, bool bAutoSetPort )
121#endif 121#endif
122} 122}
123 123
124void Bu::Url::parseUserPass( Bu::FString::const_iterator &i ) 124void Bu::Url::parseUserPass( Bu::String::const_iterator &i )
125{ 125{
126 Bu::FString::const_iterator s = i.find('@'); 126 Bu::String::const_iterator s = i.find('@');
127 if( !s ) 127 if( !s )
128 return; 128 return;
129 129
130 Bu::FString::const_iterator p = i.find(':'); 130 Bu::String::const_iterator p = i.find(':');
131 if( p ) 131 if( p )
132 { 132 {
133 sUser.set( i, p ); 133 sUser.set( i, p );
@@ -141,9 +141,9 @@ void Bu::Url::parseUserPass( Bu::FString::const_iterator &i )
141 i = s + 1; 141 i = s + 1;
142} 142}
143 143
144void Bu::Url::parseHost( Bu::FString::const_iterator &i ) 144void Bu::Url::parseHost( Bu::String::const_iterator &i )
145{ 145{
146 Bu::FString::const_iterator s = i; 146 Bu::String::const_iterator s = i;
147 for( ; s && *s != '/'; s++ ) 147 for( ; s && *s != '/'; s++ )
148 { 148 {
149 if( *s == ':' ) 149 if( *s == ':' )
@@ -151,7 +151,7 @@ void Bu::Url::parseHost( Bu::FString::const_iterator &i )
151 sHost.set( i, s ); 151 sHost.set( i, s );
152 i = s + 1; 152 i = s + 1;
153 s = i.find('/'); 153 s = i.find('/');
154 Bu::FString sPort( i, s ); 154 Bu::String sPort( i, s );
155 iPort = strtol( sPort.getStr(), NULL, 10 ); 155 iPort = strtol( sPort.getStr(), NULL, 10 );
156 i = s; 156 i = s;
157 return; 157 return;
@@ -161,17 +161,17 @@ void Bu::Url::parseHost( Bu::FString::const_iterator &i )
161 i = s; 161 i = s;
162} 162}
163 163
164void Bu::Url::parsePath( const Bu::FString &sPath ) 164void Bu::Url::parsePath( const Bu::String &sPath )
165{ 165{
166 Bu::FString::const_iterator i = sPath.begin(); 166 Bu::String::const_iterator i = sPath.begin();
167 parsePath( i ); 167 parsePath( i );
168} 168}
169 169
170void Bu::Url::parsePath( Bu::FString::const_iterator &i ) 170void Bu::Url::parsePath( Bu::String::const_iterator &i )
171{ 171{
172 if( i ) 172 if( i )
173 { 173 {
174 Bu::FString::const_iterator s = i.find('?'); 174 Bu::String::const_iterator s = i.find('?');
175 sPath.set( i, s ); 175 sPath.set( i, s );
176 i = s + 1; 176 i = s + 1;
177 if( s ) 177 if( s )
@@ -185,17 +185,17 @@ void Bu::Url::parsePath( Bu::FString::const_iterator &i )
185 } 185 }
186} 186}
187 187
188void Bu::Url::parseParams( const Bu::FString &sQuery ) 188void Bu::Url::parseParams( const Bu::String &sQuery )
189{ 189{
190 Bu::FString::const_iterator i = sQuery.begin(); 190 Bu::String::const_iterator i = sQuery.begin();
191 parseParams( i ); 191 parseParams( i );
192} 192}
193 193
194void Bu::Url::parseParams( Bu::FString::const_iterator &i ) 194void Bu::Url::parseParams( Bu::String::const_iterator &i )
195{ 195{
196 bool bName = true; 196 bool bName = true;
197 Bu::FString sName, sValue; 197 Bu::String sName, sValue;
198 for( Bu::FString::const_iterator s = i; s; s++ ) 198 for( Bu::String::const_iterator s = i; s; s++ )
199 { 199 {
200 if( bName ) 200 if( bName )
201 { 201 {
@@ -239,7 +239,7 @@ void Bu::Url::parseParams( Bu::FString::const_iterator &i )
239 } 239 }
240} 240}
241 241
242void Bu::Url::addParam( const Bu::FString &n, const Bu::FString &v ) 242void Bu::Url::addParam( const Bu::String &n, const Bu::String &v )
243{ 243{
244 lParam.append( Param( n, v ) ); 244 lParam.append( Param( n, v ) );
245} 245}
@@ -254,9 +254,9 @@ void Bu::Url::clear()
254 iPort.clear(); 254 iPort.clear();
255} 255}
256 256
257Bu::FString Bu::Url::getFullPath() const 257Bu::String Bu::Url::getFullPath() const
258{ 258{
259 Bu::FString sBuf = sPath; 259 Bu::String sBuf = sPath;
260 if( !lParam.isEmpty() ) 260 if( !lParam.isEmpty() )
261 { 261 {
262 for( ParamList::const_iterator i = lParam.begin(); i; i++ ) 262 for( ParamList::const_iterator i = lParam.begin(); i; i++ )
@@ -277,9 +277,9 @@ Bu::FString Bu::Url::getFullPath() const
277 return sBuf; 277 return sBuf;
278} 278}
279 279
280Bu::FString Bu::Url::getUrl() const 280Bu::String Bu::Url::getUrl() const
281{ 281{
282 Bu::FString sBuf = sProtocol + "://" + sHost + getFullPath(); 282 Bu::String sBuf = sProtocol + "://" + sHost + getFullPath();
283 return sBuf; 283 return sBuf;
284} 284}
285 285