Check-in [89c6ae7ab9]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:89c6ae7ab9d9785ab8faf48f9b13c31fac3038a9
Date: 2008-09-18 13:24:17
User: stephan
Comment:removed debug code from url parser
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to parsepp_url.hpp

Old (89f8cbcef8071b5b) New (bc0b98e5ccc094d8)
1 #ifndef S11N_NET_PARSEPP_URL_H_INCLUDED 1 #ifndef S11N_NET_PARSEPP_URL_H_INCLUDED
2 #define S11N_NET_PARSEPP_URL_H_INCLUDED 1 2 #define S11N_NET_PARSEPP_URL_H_INCLUDED 1
3 3
4 #include "parsepp.hpp" 4 #include "parsepp.hpp"
5 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " <
9 #define COUT std::cout << __FILE__ << ":" << std::dec << __LINE__ << " : " <
10 #define DOUT if(0) COUT <
11 <
12 namespace Ps { 8 namespace Ps {
13 9
14 /** 10 /**
15 Ps::url encapsulates a parser for URLs. It does no escaping at all - that is 11 Ps::url encapsulates a parser for URLs. It does no escaping at all - that is
16 up to client code. 12 up to client code.
24 hidden lines
41 */ 37 */
42 struct a_kvp_set_key 38 struct a_kvp_set_key
43 { 39 {
44 static void matched( Ps::parser_state &, const std::string & m, url_state & s ) 40 static void matched( Ps::parser_state &, const std::string & m, url_state & s )
45 { 41 {
46 //DOUT << "set_key: " << m << '\n'; | 42 //COUT << "set_key: " << m << '\n';
47 s.params[s.key = m] = ""; // ensure an empty value in case the val field is empty. 43 s.params[s.key = m] = ""; // ensure an empty value in case the val field is empty.
48 } 44 }
49 }; 45 };
50 46
51 /** Action to set a value. Uses the last-read key as the lookup key. */ 47 /** Action to set a value. Uses the last-read key as the lookup key. */
52 struct a_kvp_set_val 48 struct a_kvp_set_val
53 { 49 {
54 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 50 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
55 { 51 {
56 //DOUT << "set_val: " << s.key << '='<<v << '\n'; | 52 //COUT << "set_val: " << s.key << '='<<v << '\n';
57 s.params[s.key] = v; 53 s.params[s.key] = v;
58 s.key = ""; 54 s.key = "";
59 } 55 }
60 }; 56 };
61 57
24 hidden lines
86 82
87 struct a_port 83 struct a_port
88 { 84 {
89 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 85 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
90 { 86 {
91 DOUT << "port=" << v <<'\n'; | 87 //COUT << "port=" << v <<'\n';
92 s.parts["port"] = v; 88 s.parts["port"] = v;
93 } 89 }
94 }; 90 };
95 91
96 struct r_port 92 struct r_port
2 hidden lines
99 95
100 struct a_host 96 struct a_host
101 { 97 {
102 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 98 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
103 { 99 {
104 DOUT << "host=" << v <<'\n'; | 100 //COUT << "host=" << v <<'\n';
105 s.parts["host"] = v; 101 s.parts["host"] = v;
106 } 102 }
107 }; 103 };
108 104
109 struct r_hostname 105 struct r_hostname
11 hidden lines
121 struct a_scheme 117 struct a_scheme
122 { 118 {
123 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 119 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
124 { 120 {
125 std::string val = v.substr( 0, v.find(':') ); 121 std::string val = v.substr( 0, v.find(':') );
126 DOUT << "scheme=" << val <<'\n'; | 122 //COUT << "scheme=" << val <<'\n';
127 s.parts["scheme"] = val; 123 s.parts["scheme"] = val;
128 } 124 }
129 }; 125 };
130 126
131 struct r_scheme 127 struct r_scheme
3 hidden lines
135 131
136 struct a_path 132 struct a_path
137 { 133 {
138 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 134 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
139 { 135 {
140 DOUT << "path=" << v <<'\n'; | 136 //COUT << "path=" << v <<'\n';
141 s.parts["path"] = v; 137 s.parts["path"] = v;
142 } 138 }
143 }; 139 };
144 140
145 struct r_params 141 struct r_params
6 hidden lines
152 148
153 struct a_username 149 struct a_username
154 { 150 {
155 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 151 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
156 { 152 {
157 DOUT << "user=" << v <<'\n'; | 153 //COUT << "user=" << v <<'\n';
158 s.parts["user"] = v; 154 s.parts["user"] = v;
159 } 155 }
160 }; 156 };
161 157
162 struct r_user 158 struct r_user
2 hidden lines
165 161
166 struct a_password 162 struct a_password
167 { 163 {
168 static void matched( Ps::parser_state &, const std::string & v, url_state & s ) 164 static void matched( Ps::parser_state &, const std::string & v, url_state & s )
169 { 165 {
170 DOUT << "password=" << v <<'\n'; | 166 //COUT << "password=" << v <<'\n';
171 s.parts["password"] = v; 167 s.parts["password"] = v;
172 } 168 }
173 }; 169 };
174 170
175 struct r_password 171 struct r_password
12 hidden lines
188 184
189 if( pos != std::string::npos ) 185 if( pos != std::string::npos )
190 { 186 {
191 s.parts["user"] = val.substr( 0, pos ); 187 s.parts["user"] = val.substr( 0, pos );
192 s.parts["password"] = val.substr( pos+1 ); 188 s.parts["password"] = val.substr( pos+1 );
193 DOUT << "user=" << s.parts["user"] <<'\n'; | 189 //COUT << "user=" << s.parts["user"] <<'\n';
194 DOUT << "password=" << s.parts["password"] <<'\n'; | 190 //COUT << "password=" << s.parts["password"] <<'\n';
195 } 191 }
196 else 192 else
197 { 193 {
198 s.parts["user"] = val; 194 s.parts["user"] = val;
199 DOUT << "user=" << val <<'\n'; | 195 //COUT << "user=" << val <<'\n';
200 } 196 }
201 } 197 }
202 }; 198 };
203 199
204 /** 200 /**
69 hidden lines
274 } 270 }
275 271
276 }} // namespaces 272 }} // namespaces
277 273
278 #endif // S11N_NET_PARSEPP_URL_H_INCLUDED 274 #endif // S11N_NET_PARSEPP_URL_H_INCLUDED