libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 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 00873 virtual void 00874 delQueryParam(const std::string ¶m); 00875 00876 00877 // ----------------- 00885 virtual void 00886 setFragment(const std::string &fragment, 00887 EEncoding eflag); 00888 00889 00890 // ----------------- 00946 virtual void 00947 configure(); 00948 00949 00960 std::string 00961 config(const std::string &opt) const; 00962 00972 void 00973 config(const std::string &opt, const std::string &val); 00974 00975 00984 ViewOptions 00985 getViewOptions() const; 00986 00995 void 00996 setViewOptions(const ViewOptions &vopts); 00997 00998 00999 protected: 01026 virtual std::string 01027 cleanupPathName(const std::string &path, bool authority) const; 01028 01039 virtual std::string 01040 cleanupPathName(const std::string &path) const; 01041 01063 virtual bool 01064 isValidHost(const std::string &host) const; 01065 01072 virtual bool 01073 isValidPort(const std::string &port) const; 01074 01075 private: 01076 UrlBaseData *m_data; 01077 }; 01078 01079 01080 // --------------------------------------------------------------- 01084 typedef RWCOW_pointer<UrlBase> UrlRef; 01085 01086 01088 } // namespace url 01090 01092 } // namespace zypp 01094 01095 #endif /* ZYPP_URL_URLBASE_H */ 01096 /* 01097 ** vim: set ts=2 sts=2 sw=2 ai et: 01098 */