00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024 #ifndef LIMAL_URLUTILS_HPP
00025 #define LIMAL_URLUTILS_HPP
00026
00027 #include <limal/config.h>
00028 #include <limal/ByteBuffer.hpp>
00029 #include "blocxx/Exception.hpp"
00030 #include <blocxx/String.hpp>
00031 #include <blocxx/Array.hpp>
00032 #include <blocxx/Map.hpp>
00033
00034
00035
00036 namespace LIMAL_NAMESPACE
00037 {
00038 namespace url
00039 {
00040
00041
00046 BLOCXX_DECLARE_EXCEPTION (Url);
00047
00048
00049
00054 BLOCXX_DECLARE_EXCEPTION2(UrlParsing, UrlException);
00055
00056
00057
00062 BLOCXX_DECLARE_EXCEPTION2(UrlDecoding, UrlException);
00063
00064
00065
00070 BLOCXX_DECLARE_EXCEPTION2(UrlBadComponent, UrlException);
00071
00072
00073
00078 BLOCXX_DECLARE_EXCEPTION2(UrlNotAllowed, UrlException);
00079
00080
00081
00087 BLOCXX_DECLARE_EXCEPTION2(UrlNotSupported, UrlException);
00088
00089
00090
00095 typedef blocxx::Map<blocxx::String,blocxx::String> ParamMap;
00096
00097
00098
00102 struct UrlComponents
00103 {
00104 blocxx::String scheme;
00105 blocxx::String authority;
00106 blocxx::String pathdata;
00107 blocxx::String querystr;
00108 blocxx::String fragment;
00109 bool has_scheme;
00110 bool has_authority;
00111 bool has_querystr;
00112 bool has_fragment;
00113 };
00114
00115
00116
00120 struct UrlAuthority
00121 {
00122 blocxx::String user;
00123 blocxx::String pass;
00124 blocxx::String host;
00125 blocxx::String port;
00126 bool has_user;
00127 bool has_pass;
00128 bool has_port;
00129 };
00130
00131
00132
00135 typedef enum {
00136 E_ENCODED,
00137 E_DECODED
00138 } EEncoding;
00139
00140
00141
00167 blocxx::String
00168 encode(const blocxx::String &str,
00169 const blocxx::String &safe = "",
00170 limal::url::EEncoding eflag = E_DECODED);
00171
00172
00173
00184 blocxx::String
00185 encode_buf(const limal::ByteBuffer &buf,
00186 const blocxx::String &safe = "",
00187 limal::url::EEncoding eflag = E_DECODED);
00188
00189
00190
00204 blocxx::String
00205 decode(const blocxx::String &str);
00206
00207
00208
00224 limal::ByteBuffer
00225 decode_buf(const blocxx::String &str, bool allowNUL);
00226
00227
00228
00238 blocxx::String
00239 encode_octet(const unsigned char c);
00240
00241
00242
00261 int
00262 decode_octet(const char *hex);
00263
00264
00265
00279 blocxx::StringArray
00280 split(const blocxx::String &pstr,
00281 const blocxx::String &psep);
00282
00283
00284
00312 limal::url::ParamMap
00313 split(const blocxx::String &pstr,
00314 const blocxx::String &psep,
00315 const blocxx::String &vsep,
00316 EEncoding eflag = E_ENCODED);
00317
00318
00319
00333 blocxx::String
00334 join(const blocxx::StringArray &parr,
00335 const blocxx::String &psep);
00336
00337
00338
00360 blocxx::String
00361 join(const limal::url::ParamMap &pmap,
00362 const blocxx::String &psep,
00363 const blocxx::String &vsep,
00364 const blocxx::String &safe);
00365
00366
00367
00368
00369
00370
00371
00372
00373 UrlComponents
00374 parse_url_string(const blocxx::String &url);
00375
00376
00377
00378
00379
00380
00381
00382
00383 UrlAuthority
00384 parse_url_authority(const blocxx::String &authority);
00385
00386
00387
00388 }
00389 }
00390 #endif // LIMAL_URLUTILS_HPP
00391