1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
10 * \file zypp/url/UrlBase.h
12 #ifndef ZYPP_URL_URLBASE_H
13 #define ZYPP_URL_URLBASE_H
15 #include <zypp/url/UrlUtils.h>
16 #include <zypp/base/PtrTypes.h>
19 //////////////////////////////////////////////////////////////////////
21 { ////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////
25 { //////////////////////////////////////////////////////////////////
28 // ---------------------------------------------------------------
29 /** Url behaviour configuration container.
31 typedef std::map< std::string, std::string > UrlConfig;
34 // ---------------------------------------------------------------
35 /** Url toString() view options.
43 static const ViewOption WITH_SCHEME;
44 static const ViewOption WITH_USERNAME;
45 static const ViewOption WITH_PASSWORD;
46 static const ViewOption WITH_HOST;
47 static const ViewOption WITH_PORT;
48 static const ViewOption WITH_PATH_NAME;
49 static const ViewOption WITH_PATH_PARAMS;
50 static const ViewOption WITH_QUERY_STR;
51 static const ViewOption WITH_FRAGMENT;
58 static const ViewOption EMPTY_AUTHORITY;
59 static const ViewOption EMPTY_PATH_NAME;
60 static const ViewOption EMPTY_PATH_PARAMS;
61 static const ViewOption EMPTY_QUERY_STR;
62 static const ViewOption EMPTY_FRAGMENT;
65 /** Default combination of view options.
67 static const ViewOption DEFAULTS;
69 ViewOption(): opt(DEFAULTS.opt)
72 /** @return The result of a add of \p r from \p l.
74 friend inline ViewOption
75 operator + (const ViewOption &l, const ViewOption &r)
76 { return ViewOption(l.opt | r.opt); }
78 /** @return The result of a subtract of \p r from \p l.
80 friend inline ViewOption
81 operator - (const ViewOption &l, const ViewOption &r)
82 { return ViewOption(l.opt & ~r.opt); }
84 /** Check if option is set.
85 * \param o A view option.
86 * \return True, if the current options bitwise matches
90 has(const ViewOption &o) const
91 { return o.opt & opt; }
94 ViewOption(int o): opt(o) {}
99 // ---------------------------------------------------------------
100 typedef ViewOption ViewOptions;
103 // ---------------------------------------------------------------
119 UrlData(const UrlConfig &conf)
134 std::string pathname;
135 std::string pathparams;
136 std::string querystr;
137 std::string fragment;
141 // ---------------------------------------------------------------
151 typedef std::vector<std::string> Schemes;
161 UrlBase(const UrlBase &url);
166 UrlBase(const std::string &scheme,
167 const std::string &authority,
168 const std::string &pathdata,
169 const std::string &querystr,
170 const std::string &fragment);
193 init(const std::string &scheme,
194 const std::string &authority,
195 const std::string &pathdata,
196 const std::string &querystr,
197 const std::string &fragment);
202 virtual UrlBase::Schemes
203 getKnownSchemes() const;
209 isKnownScheme(const std::string &scheme) const;
215 isValidScheme(const std::string &scheme) const;
227 * TODO: hide pass, ...
233 toString(const zypp::url::ViewOptions &opts) const;
241 getAuthority() const;
247 getQueryString() const;
250 getFragment(EEncoding eflag) const;
255 getUsername(EEncoding eflag) const;
258 getPassword(EEncoding eflag) const;
261 getHost(EEncoding eflag) const;
267 getPathName(EEncoding eflag) const;
270 getPathParams() const;
274 virtual zypp::url::ParamVec
275 getPathParamsVec() const;
277 virtual zypp::url::ParamMap
278 getPathParamsMap(EEncoding eflag) const;
281 getPathParam(const std::string ¶m, EEncoding eflag) const;
284 virtual zypp::url::ParamVec
285 getQueryStringVec() const;
287 virtual zypp::url::ParamMap
288 getQueryStringMap(EEncoding eflag) const;
291 getQueryParam(const std::string ¶m, EEncoding eflag) const;
296 setScheme(const std::string &scheme);
299 setAuthority(const std::string &authority);
302 setPathData(const std::string &pathdata);
305 setQueryString(const std::string &querystr);
308 setFragment(const std::string &fragment);
313 setUsername(const std::string &user);
316 setPassword(const std::string &pass);
319 setHost(const std::string &host);
322 setPort(const std::string &port);
325 setPathName(const std::string &path);
328 setPathParams(const std::string ¶ms);
333 setPathParamsVec(const zypp::url::ParamVec &pvec);
336 setPathParamsMap(const zypp::url::ParamMap &pmap);
339 setPathParam(const std::string ¶m, const std::string &value);
342 setQueryStringVec(const zypp::url::ParamVec &pmap);
345 setQueryStringMap(const zypp::url::ParamMap &pmap);
348 setQueryParam(const std::string ¶m, const std::string &value);
356 config(const std::string &opt) const;
361 config(const std::string &opt, const std::string &val);
364 getViewOptions() const;
367 setViewOptions(const ViewOptions &vopts);
374 // ---------------------------------------------------------------
375 typedef RWCOW_pointer<UrlBase> UrlRef;
378 //////////////////////////////////////////////////////////////////
380 ////////////////////////////////////////////////////////////////////
382 ////////////////////////////////////////////////////////////////////
384 //////////////////////////////////////////////////////////////////////
386 #endif /* ZYPP_URL_URLBASE_H */
388 ** vim: set ts=2 sts=2 sw=2 ai et: