UrlBase.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_URL_URLBASE_H
00013 #define ZYPP_URL_URLBASE_H
00014
00015 #include <zypp/url/UrlUtils.h>
00016 #include <zypp/base/PtrTypes.h>
00017
00018
00020 namespace zypp
00021 {
00022
00024 namespace url
00025 {
00026
00027
00028
00039 struct ViewOption
00040 {
00051 static const ViewOption WITH_SCHEME;
00058 static const ViewOption WITH_USERNAME;
00067 static const ViewOption WITH_PASSWORD;
00074 static const ViewOption WITH_HOST;
00081 static const ViewOption WITH_PORT;
00087 static const ViewOption WITH_PATH_NAME;
00095 static const ViewOption WITH_PATH_PARAMS;
00101 static const ViewOption WITH_QUERY_STR;
00107 static const ViewOption WITH_FRAGMENT;
00121 static const ViewOption EMPTY_AUTHORITY;
00133 static const ViewOption EMPTY_PATH_NAME;
00143 static const ViewOption EMPTY_PATH_PARAMS;
00154 static const ViewOption EMPTY_QUERY_STR;
00165 static const ViewOption EMPTY_FRAGMENT;
00177 static const ViewOption DEFAULTS;
00184 ViewOption();
00185
00186
00192 friend inline ViewOption
00193 operator + (const ViewOption &l, const ViewOption &r)
00194 {
00195 return ViewOption(l.opt | r.opt);
00196 }
00197
00203 friend inline ViewOption
00204 operator - (const ViewOption &l, const ViewOption &r)
00205 {
00206 return ViewOption(l.opt & ~r.opt);
00207 }
00208
00215 inline ViewOption &
00216 operator = (const ViewOption &o)
00217 {
00218 opt = o.opt; return *this;
00219 }
00220
00227 inline bool
00228 has(const ViewOption &o) const
00229 {
00230 return o.opt & opt;
00231 }
00232
00233 private:
00234 ViewOption(int option);
00235 int opt;
00236 };
00237
00238
00239
00243 typedef ViewOption ViewOptions;
00244
00245
00246
00250 typedef std::vector<std::string> UrlSchemes;
00251
00252
00253
00257 class UrlBaseData;
00258
00259
00260
00269 class UrlBase
00270 {
00271 public:
00272
00273 virtual
00274 ~UrlBase();
00275
00276 UrlBase();
00277
00282 UrlBase(const UrlBase &url);
00283
00298 UrlBase(const std::string &scheme,
00299 const std::string &authority,
00300 const std::string &pathdata,
00301 const std::string &querystr,
00302 const std::string &fragment);
00303
00304
00305
00309 virtual void
00310 clear();
00311
00323 virtual UrlBase *
00324 clone() const;
00325
00339 virtual void
00340 init(const std::string &scheme,
00341 const std::string &authority,
00342 const std::string &pathdata,
00343 const std::string &querystr,
00344 const std::string &fragment);
00345
00346
00347
00365 virtual UrlSchemes
00366 getKnownSchemes() const;
00367
00372 virtual bool
00373 isKnownScheme(const std::string &scheme) const;
00374
00375
00388 virtual bool
00389 isValidScheme(const std::string &scheme) const;
00390
00400 virtual bool
00401 isValid() const;
00402
00403
00404
00412 virtual std::string
00413 asString() const;
00414
00427 virtual std::string
00428 asString(const zypp::url::ViewOptions &opts) const;
00429
00430
00431
00436 virtual std::string
00437 getScheme() const;
00438
00439
00440
00450 virtual std::string
00451 getAuthority() const;
00452
00460 virtual std::string
00461 getUsername(EEncoding eflag) const;
00462
00470 virtual std::string
00471 getPassword(EEncoding eflag) const;
00472
00485 virtual std::string
00486 getHost(EEncoding eflag) const;
00487
00492 virtual std::string
00493 getPort() const;
00494
00495
00496
00506 virtual std::string
00507 getPathData() const;
00508
00517 virtual std::string
00518 getPathName(EEncoding eflag) const;
00519
00524 virtual std::string
00525 getPathParams() const;
00526
00539 virtual zypp::url::ParamVec
00540 getPathParamsVec() const;
00541
00561 virtual zypp::url::ParamMap
00562 getPathParamsMap(EEncoding eflag) const;
00563
00580 virtual std::string
00581 getPathParam(const std::string ¶m, EEncoding eflag) const;
00582
00583
00584
00594 virtual std::string
00595 getQueryString() const;
00596
00610 virtual zypp::url::ParamVec
00611 getQueryStringVec() const;
00612
00631 virtual zypp::url::ParamMap
00632 getQueryStringMap(EEncoding eflag) const;
00633
00650 virtual std::string
00651 getQueryParam(const std::string ¶m, EEncoding eflag) const;
00652
00653
00654
00662 virtual std::string
00663 getFragment(EEncoding eflag) const;
00664
00665
00666
00673 virtual void
00674 setScheme(const std::string &scheme);
00675
00676
00677
00691 virtual void
00692 setAuthority(const std::string &authority);
00693
00703 virtual void
00704 setUsername(const std::string &user,
00705 EEncoding eflag);
00706
00716 virtual void
00717 setPassword(const std::string &pass,
00718 EEncoding eflag);
00719
00740 virtual void
00741 setHost(const std::string &host);
00742
00750 virtual void
00751 setPort(const std::string &port);
00752
00753
00754
00765 virtual void
00766 setPathData(const std::string &pathdata);
00767
00775 virtual void
00776 setPathName(const std::string &path,
00777 EEncoding eflag);
00778
00785 virtual void
00786 setPathParams(const std::string ¶ms);
00787
00794 virtual void
00795 setPathParamsVec(const zypp::url::ParamVec &pvec);
00796
00803 virtual void
00804 setPathParamsMap(const zypp::url::ParamMap &pmap);
00805
00815 virtual void
00816 setPathParam(const std::string ¶m, const std::string &value);
00817
00818
00819
00832 virtual void
00833 setQueryString(const std::string &querystr);
00834
00841 virtual void
00842 setQueryStringVec(const zypp::url::ParamVec &qvec);
00843
00850 virtual void
00851 setQueryStringMap(const zypp::url::ParamMap &qmap);
00852
00862 virtual void
00863 setQueryParam(const std::string ¶m, const std::string &value);
00864
00865
00866
00874 virtual void
00875 setFragment(const std::string &fragment,
00876 EEncoding eflag);
00877
00878
00879
00935 virtual void
00936 configure();
00937
00938
00949 std::string
00950 config(const std::string &opt) const;
00951
00961 void
00962 config(const std::string &opt, const std::string &val);
00963
00964
00973 ViewOptions
00974 getViewOptions() const;
00975
00984 void
00985 setViewOptions(const ViewOptions &vopts);
00986
00987
00988 protected:
01015 virtual std::string
01016 cleanupPathName(const std::string &path, bool authority) const;
01017
01028 virtual std::string
01029 cleanupPathName(const std::string &path) const;
01030
01052 virtual bool
01053 isValidHost(const std::string &host) const;
01054
01061 virtual bool
01062 isValidPort(const std::string &port) const;
01063
01064 private:
01065 UrlBaseData *m_data;
01066 };
01067
01068
01069
01073 typedef RWCOW_pointer<UrlBase> UrlRef;
01074
01075
01077 }
01079
01081 }
01083
01084 #endif
01085
01086
01087