diff options
Diffstat (limited to 'src/url.cpp')
-rw-r--r-- | src/url.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/url.cpp b/src/url.cpp index 1f9f563..943b855 100644 --- a/src/url.cpp +++ b/src/url.cpp | |||
@@ -21,7 +21,7 @@ Bu::Url::Url() | |||
21 | { | 21 | { |
22 | } | 22 | } |
23 | 23 | ||
24 | Bu::Url::Url( const Bu::FString &sUrl ) | 24 | Bu::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 | ||
33 | void Bu::Url::parseUrl( const Bu::FString &sUrl ) | 33 | void 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 | ||
44 | Bu::FString Bu::Url::decode( const Bu::FString &sStr ) | 44 | Bu::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 | ||
70 | Bu::FString Bu::Url::encode( const Bu::FString &sStr ) | 70 | Bu::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 | ||
99 | void Bu::Url::parseProtocol( Bu::FString::const_iterator &i ) | 99 | void 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 | ||
109 | void Bu::Url::setProtocol( const Bu::FString &sNewProto, bool bAutoSetPort ) | 109 | void 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 | ||
124 | void Bu::Url::parseUserPass( Bu::FString::const_iterator &i ) | 124 | void 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 | ||
144 | void Bu::Url::parseHost( Bu::FString::const_iterator &i ) | 144 | void 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 | ||
164 | void Bu::Url::parsePath( const Bu::FString &sPath ) | 164 | void 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 | ||
170 | void Bu::Url::parsePath( Bu::FString::const_iterator &i ) | 170 | void 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 | ||
188 | void Bu::Url::parseParams( const Bu::FString &sQuery ) | 188 | void 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 | ||
194 | void Bu::Url::parseParams( Bu::FString::const_iterator &i ) | 194 | void 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 | ||
242 | void Bu::Url::addParam( const Bu::FString &n, const Bu::FString &v ) | 242 | void 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 | ||
257 | Bu::FString Bu::Url::getFullPath() const | 257 | Bu::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 | ||
280 | Bu::FString Bu::Url::getUrl() const | 280 | Bu::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 | ||