UrlBase.h

Go to the documentation of this file.
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(): opt(DEFAULTS.opt)
00185       {}
00186 
00187 
00193       friend inline ViewOption
00194       operator + (const ViewOption &l, const ViewOption &r)
00195       {
00196         return ViewOption(l.opt |  r.opt);
00197       }
00198 
00204       friend inline ViewOption
00205       operator - (const ViewOption &l, const ViewOption &r)
00206       {
00207         return ViewOption(l.opt & ~r.opt);
00208       }
00209 
00216       inline ViewOption &
00217       operator = (const ViewOption &o)
00218       {
00219         opt = o.opt; return *this;
00220       }
00221 
00228       inline bool
00229       has(const ViewOption &o) const
00230       {
00231         return o.opt & opt;
00232       }
00233 
00234     private:
00235       ViewOption(int o): opt(o) {}
00236       int opt;
00237     };
00238 
00239 
00240     // ---------------------------------------------------------------
00244     typedef ViewOption                           ViewOptions;
00245 
00246 
00247     // ---------------------------------------------------------------
00251     typedef std::vector<std::string>             UrlSchemes;
00252 
00253 
00254     // ---------------------------------------------------------------
00258     class UrlBaseData;
00259 
00260 
00261     // ---------------------------------------------------------------
00270     class UrlBase
00271     {
00272     public:
00273 
00274       virtual
00275       ~UrlBase();
00276 
00277       UrlBase();
00278 
00283       UrlBase(const UrlBase &url);
00284 
00299       UrlBase(const std::string &scheme,
00300               const std::string &authority,
00301               const std::string &pathdata,
00302               const std::string &querystr,
00303               const std::string &fragment);
00304 
00305 
00306       // -----------------
00310       virtual void
00311       clear();
00312 
00324       virtual UrlBase *
00325       clone() const;
00326 
00340       virtual void
00341       init(const std::string &scheme,
00342            const std::string &authority,
00343            const std::string &pathdata,
00344            const std::string &querystr,
00345            const std::string &fragment);
00346 
00347 
00348       // -----------------
00366       virtual UrlSchemes
00367       getKnownSchemes() const;
00368 
00373       virtual bool
00374       isKnownScheme(const std::string &scheme) const;
00375 
00376 
00389       virtual bool
00390       isValidScheme(const std::string &scheme) const;
00391 
00401       virtual bool
00402       isValid() const;
00403 
00404 
00405       // -----------------
00413       virtual std::string
00414       asString() const;
00415 
00428       virtual std::string
00429       asString(const zypp::url::ViewOptions &opts) const;
00430 
00431 
00432       // -----------------
00437       virtual std::string
00438       getScheme() const;
00439 
00440 
00441       // -----------------
00451       virtual std::string
00452       getAuthority() const;
00453 
00461       virtual std::string
00462       getUsername(EEncoding eflag) const;
00463 
00471       virtual std::string
00472       getPassword(EEncoding eflag) const;
00473 
00486       virtual std::string
00487       getHost(EEncoding eflag) const;
00488 
00493       virtual std::string
00494       getPort() const;
00495 
00496 
00497       // -----------------
00507       virtual std::string
00508       getPathData() const;
00509 
00518       virtual std::string
00519       getPathName(EEncoding eflag) const;
00520 
00525       virtual std::string
00526       getPathParams() const;
00527 
00540       virtual zypp::url::ParamVec
00541       getPathParamsVec() const;
00542 
00562       virtual zypp::url::ParamMap
00563       getPathParamsMap(EEncoding eflag) const;
00564 
00581       virtual std::string
00582       getPathParam(const std::string &param, EEncoding eflag) const;
00583 
00584 
00585       // -----------------
00595       virtual std::string
00596       getQueryString() const;
00597 
00611       virtual zypp::url::ParamVec
00612       getQueryStringVec() const;
00613 
00632       virtual zypp::url::ParamMap
00633       getQueryStringMap(EEncoding eflag) const;
00634 
00651       virtual std::string
00652       getQueryParam(const std::string &param, EEncoding eflag) const;
00653 
00654 
00655       // -----------------
00663       virtual std::string
00664       getFragment(EEncoding eflag) const;
00665 
00666 
00667       // -----------------
00674       virtual void
00675       setScheme(const std::string &scheme);
00676 
00677 
00678       // -----------------
00692       virtual void
00693       setAuthority(const std::string &authority);
00694 
00704       virtual void
00705       setUsername(const std::string &user,
00706                   EEncoding         eflag);
00707 
00717       virtual void
00718       setPassword(const std::string &pass,
00719                   EEncoding         eflag);
00720 
00741       virtual void
00742       setHost(const std::string &host);
00743 
00751       virtual void
00752       setPort(const std::string &port);
00753 
00754 
00755       // -----------------
00766       virtual void
00767       setPathData(const std::string &pathdata);
00768 
00776       virtual void
00777       setPathName(const std::string &path,
00778                   EEncoding         eflag);
00779 
00786       virtual void
00787       setPathParams(const std::string &params);
00788 
00795       virtual void
00796       setPathParamsVec(const zypp::url::ParamVec &pvec);
00797 
00804       virtual void
00805       setPathParamsMap(const zypp::url::ParamMap &pmap);
00806 
00816       virtual void
00817       setPathParam(const std::string &param, const std::string &value);
00818 
00819 
00820       // -----------------
00833       virtual void
00834       setQueryString(const std::string &querystr);
00835 
00842       virtual void
00843       setQueryStringVec(const zypp::url::ParamVec &qvec);
00844 
00851       virtual void
00852       setQueryStringMap(const zypp::url::ParamMap &qmap);
00853 
00863       virtual void
00864       setQueryParam(const std::string &param, const std::string &value);
00865 
00866 
00867       // -----------------
00875       virtual void
00876       setFragment(const std::string &fragment,
00877                   EEncoding         eflag);
00878 
00879 
00880       // -----------------
00936       virtual void
00937       configure();
00938 
00939 
00950       std::string
00951       config(const std::string &opt) const;
00952 
00962       void
00963       config(const std::string &opt, const std::string &val);
00964 
00965 
00974       ViewOptions
00975       getViewOptions() const;
00976 
00985       void
00986       setViewOptions(const ViewOptions &vopts);
00987 
00988 
00989     protected:
01016       virtual std::string
01017       cleanupPathName(const std::string &path, bool authority) const;
01018 
01029       virtual std::string
01030       cleanupPathName(const std::string &path) const;
01031 
01053       virtual bool
01054       isValidHost(const std::string &host) const;
01055 
01062       virtual bool
01063       isValidPort(const std::string &port) const;
01064 
01065     private:
01066       UrlBaseData *m_data;
01067     };
01068 
01069 
01070     // ---------------------------------------------------------------
01074     typedef RWCOW_pointer<UrlBase>          UrlRef;
01075 
01076 
01078   } // namespace url
01080 
01082 } // namespace zypp
01084 
01085 #endif /* ZYPP_URL_URLBASE_H */
01086 /*
01087 ** vim: set ts=2 sts=2 sw=2 ai et:
01088 */

Generated on Thu Jul 6 00:07:29 2006 for zypp by  doxygen 1.4.6