libzypp  16.15.3
Url.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_URL_H
13 #define ZYPP_URL_H
14 
15 #include "zypp/url/UrlBase.h"
16 #include "zypp/url/UrlUtils.h"
17 
18 
20 namespace zypp
21 {
22 
23  namespace filesystem {
24  class Pathname;
25  }
26  using filesystem::Pathname;
27 
87  class Url
88  {
89  public:
94 
99 
100 
101  ~Url();
102  Url();
103 
114  Url(const Url &url);
115 
116 
127  Url(const zypp::url::UrlRef &url);
128 
129 
143  Url(const std::string &encodedUrl);
144 
145 
146  // -----------------
163  static url::UrlRef
164  parseUrl(const std::string &encodedUrl);
165 
166 
167  // -----------------
182  Url&
183  operator = (const std::string &encodedUrl);
184 
185 
196  Url&
197  operator = (const Url &url);
198 
199 
200  // -----------------
208  static bool
209  registerScheme(const std::string &scheme,
210  url::UrlRef urlImpl);
211 
216  static zypp::url::UrlSchemes
217  getRegisteredSchemes();
218 
223  static bool
224  isRegisteredScheme(const std::string &scheme);
225 
226 
227  // -----------------
233  getKnownSchemes() const;
234 
235 
250  bool
251  isValidScheme(const std::string &scheme) const;
252 
253 
255  static bool schemeIsLocal( const std::string & scheme_r );
257  bool schemeIsLocal() const { return schemeIsLocal( getScheme() ); }
258 
260  static bool schemeIsRemote( const std::string & scheme_r );
262  bool schemeIsRemote() const { return schemeIsRemote( getScheme() ); }
263 
265  static bool schemeIsVolatile( const std::string & scheme_r );
267  bool schemeIsVolatile() const { return schemeIsVolatile( getScheme() ); }
268 
270  static bool schemeIsDownloading( const std::string & scheme_r );
272  bool schemeIsDownloading() const { return schemeIsDownloading( getScheme() ); }
273 
283  bool
284  isValid() const;
285 
286 
287  // -----------------
295  std::string
296  asString() const;
297 
310  std::string
311  asString(const ViewOptions &opts) const;
312 
322  std::string
323  asCompleteString() const;
324 
325 
326  // -----------------
331  std::string
332  getScheme() const;
333 
334 
335  // -----------------
345  std::string
346  getAuthority() const;
347 
355  std::string
356  getUsername(EEncoding eflag = zypp::url::E_DECODED) const;
357 
365  std::string
366  getPassword(EEncoding eflag = zypp::url::E_DECODED) const;
367 
372  { return ! ( getUsername().empty() || getPassword().empty() ); }
373 
386  std::string
387  getHost(EEncoding eflag = zypp::url::E_DECODED) const;
388 
393  std::string
394  getPort() const;
395 
396 
397  // -----------------
407  std::string
408  getPathData() const;
409 
418  std::string
419  getPathName(EEncoding eflag = zypp::url::E_DECODED) const;
420 
425  std::string
426  getPathParams() const;
427 
441  getPathParamsVec() const;
442 
463  getPathParamsMap(EEncoding eflag = zypp::url::E_DECODED) const;
464 
481  std::string
482  getPathParam(const std::string &param,
483  EEncoding eflag = zypp::url::E_DECODED) const;
484 
485 
486  // -----------------
496  std::string
497  getQueryString() const;
498 
513  getQueryStringVec() const;
514 
534  getQueryStringMap(EEncoding eflag = zypp::url::E_DECODED) const;
535 
552  std::string
553  getQueryParam(const std::string &param,
554  EEncoding eflag = zypp::url::E_DECODED) const;
555 
556 
557  // -----------------
565  std::string
566  getFragment(EEncoding eflag = zypp::url::E_DECODED) const;
567 
568 
569  // -----------------
576  void
577  setScheme(const std::string &scheme);
578 
579 
580  // -----------------
594  void
595  setAuthority(const std::string &authority);
596 
606  void
607  setUsername(const std::string &user,
608  EEncoding eflag = zypp::url::E_DECODED);
609 
619  void
620  setPassword(const std::string &pass,
621  EEncoding eflag = zypp::url::E_DECODED);
622 
643  void
644  setHost(const std::string &host);
645 
653  void
654  setPort(const std::string &port);
655 
656 
657  // -----------------
668  void
669  setPathData(const std::string &pathdata);
670 
678  void
679  setPathName(const std::string &path,
680  EEncoding eflag = zypp::url::E_DECODED);
682  void
683  setPathName(const Pathname &path,
684  EEncoding eflag = zypp::url::E_DECODED);
686  void
687  setPathName(const char *path,
688  EEncoding eflag = zypp::url::E_DECODED);
689 
696  void
697  setPathParams(const std::string &params);
698 
705  void
706  setPathParamsVec(const zypp::url::ParamVec &pvec);
707 
714  void
715  setPathParamsMap(const zypp::url::ParamMap &pmap);
716 
726  void
727  setPathParam(const std::string &param, const std::string &value);
728 
729 
730  // -----------------
737  void
738  setQueryString(const std::string &querystr);
739 
746  void
747  setQueryStringVec(const zypp::url::ParamVec &qvec);
748 
755  void
756  setQueryStringMap(const zypp::url::ParamMap &qmap);
757 
767  void
768  setQueryParam(const std::string &param, const std::string &value);
769 
778  void
779  delQueryParam(const std::string &param);
780 
781 
782  // -----------------
790  void
791  setFragment(const std::string &fragment,
792  EEncoding eflag = zypp::url::E_DECODED);
793 
794 
795  // -----------------
804  ViewOptions
805  getViewOptions() const;
806 
815  void
816  setViewOptions(const ViewOptions &vopts);
817 
818  private:
820  };
821 
822  std::ostream & operator<<( std::ostream & str, const Url & url );
823 
827  bool operator<( const Url &lhs, const Url &rhs );
828 
832  bool operator==( const Url &lhs, const Url &rhs );
833 
834 
835  bool operator!=( const Url &lhs, const Url &rhs );
836 
838 } // namespace zypp
840 
841 #endif /* ZYPP_URL_H */
842 /*
843 ** vim: set ts=2 sts=2 sw=2 ai et:
844 */
std::vector< std::string > ParamVec
A parameter vector container.
Definition: UrlUtils.h:40
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition: UrlUtils.h:47
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
bool schemeIsDownloading() const
Definition: Url.h:272
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition: UrlBase.h:250
bool schemeIsVolatile() const
Definition: Url.h:267
bool schemeIsRemote() const
Definition: Url.h:262
String related utilities and Regular expression matching.
Url url
Definition: MediaCurl.cc:196
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
Url::asString() view options.
Definition: UrlBase.h:39
zypp::url::EEncoding EEncoding
Encoding flags.
Definition: Url.h:93
bool schemeIsLocal() const
Definition: Url.h:257
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
zypp::url::ViewOptions ViewOptions
View options.
Definition: Url.h:98
url::UrlRef m_impl
Definition: Url.h:819
EEncoding
Encoding flags.
Definition: UrlUtils.h:52
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition: Glob.cc:53
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
Definition: StrMatcher.cc:335
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Url manipulation class.
Definition: Url.h:87
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
Definition: Url.h:371
Flag to request decoded string(s).
Definition: UrlUtils.h:54