aboutsummaryrefslogtreecommitdiff
path: root/src/url.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-02-08 00:44:10 +0000
committerMike Buland <eichlan@xagasoft.com>2009-02-08 00:44:10 +0000
commit366a8063730aa7ae696bcb9cf56eafd13d43dfc0 (patch)
tree42e3597edfde0c183506ad0d452f045cb7726137 /src/url.h
parent4f59dec6bad120b72f1bc075715d79bfbe881f7e (diff)
downloadlibbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.gz
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.bz2
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.xz
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.zip
So many updates. I recommend using the new FString iterators instead of direct
indexing. It is now many times faster, and requires less overhead. Also, more stuff iterator related in every class. More on that later.
Diffstat (limited to '')
-rw-r--r--src/url.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/url.h b/src/url.h
new file mode 100644
index 0000000..861bb9f
--- /dev/null
+++ b/src/url.h
@@ -0,0 +1,74 @@
1#ifndef BU_URL_H
2#define BU_URL_H
3
4#include "bu/fstring.h"
5#include "bu/atom.h"
6
7namespace Bu
8{
9 class Url
10 {
11 public:
12 typedef struct Param
13 {
14 Param() { }
15 Param( const Param &r ) : sName( r.sName ), sValue( r.sValue ) { }
16 Param( const Bu::FString &n, const Bu::FString &v ) :
17 sName( n ), sValue( v ) { }
18 Bu::FString sName;
19 Bu::FString sValue;
20 } Param;
21 typedef Bu::List<Param> ParamList;
22
23 public:
24 Url();
25 Url( const Bu::FString &sUrl );
26 virtual ~Url();
27
28 void parseUrl( const Bu::FString &sUrl );
29 void parseParams( Bu::FString::const_iterator &i );
30 void clear();
31
32 Bu::FString getUrl();
33
34 const Bu::FString &getProtocol() { return sProtocol; }
35 const Bu::FString &getUser() { return sUser; }
36 const Bu::FString &getPass() { return sPass; }
37 const Bu::FString &getHost() { return sHost; }
38 const Bu::FString &getPath() { return sPath; }
39 int getPort() { return iPort; }
40 ParamList::const_iterator getParamBegin() { return lParam.begin(); }
41
42 void setProtocol( const Bu::FString &sNewHost, bool bAutoSetPort=true );
43 void setUser( const Bu::FString &s ) { sUser = s; }
44 void setPass( const Bu::FString &s ) { sPass = s; }
45 void setHost( const Bu::FString &s ) { sHost = s; }
46 void setPath( const Bu::FString &s ) { sPath = s; }
47 void setPort( int i ) { iPort = i; }
48 void addParam( const Bu::FString &n, const Bu::FString &v );
49
50 bool hasPort() { return iPort.has(); }
51
52 static Bu::FString decode( const Bu::FString &sStr );
53 static Bu::FString encode( const Bu::FString &sStr );
54
55 private: // Parsing code
56 void parseProtocol( Bu::FString::const_iterator &i );
57 void parseUserPass( Bu::FString::const_iterator &i );
58 void parseHost( Bu::FString::const_iterator &i );
59 void parsePath( Bu::FString::const_iterator &i );
60
61 private:
62 Bu::FString sProtocol;
63 Bu::FString sUser;
64 Bu::FString sPass;
65 Bu::FString sHost;
66 Bu::FString sPath;
67 Bu::Atom<int> iPort;
68 ParamList lParam;
69
70 static char hexcode[16];
71 };
72};
73
74#endif