libzypp  17.25.8
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  class Url;
24  namespace hotfix1050625 {
25  std::string asString( const Url & url_r );
26  }
27  namespace filesystem {
28  class Pathname;
29  }
30  using filesystem::Pathname;
31 
91  class Url
92  {
93  public:
98 
103 
104 
105  ~Url();
106  Url();
107 
118  Url(const Url &url);
119 
120 
131  Url(const zypp::url::UrlRef &url);
132 
133 
147  Url(const std::string &encodedUrl);
148 
149 
150  // -----------------
167  static url::UrlRef
168  parseUrl(const std::string &encodedUrl);
169 
170 
171  // -----------------
186  Url&
187  operator = (const std::string &encodedUrl);
188 
189 
200  Url&
201  operator = (const Url &url);
202 
203 
204  // -----------------
212  static bool
213  registerScheme(const std::string &scheme,
214  url::UrlRef urlImpl);
215 
220  static zypp::url::UrlSchemes
222 
227  static bool
228  isRegisteredScheme(const std::string &scheme);
229 
230 
231  // -----------------
237  getKnownSchemes() const;
238 
239 
254  bool
255  isValidScheme(const std::string &scheme) const;
256 
257 
259  static bool schemeIsLocal( const std::string & scheme_r );
261  bool schemeIsLocal() const { return schemeIsLocal( getScheme() ); }
262 
264  static bool schemeIsRemote( const std::string & scheme_r );
266  bool schemeIsRemote() const { return schemeIsRemote( getScheme() ); }
267 
269  static bool schemeIsVolatile( const std::string & scheme_r );
271  bool schemeIsVolatile() const { return schemeIsVolatile( getScheme() ); }
272 
274  static bool schemeIsDownloading( const std::string & scheme_r );
276  bool schemeIsDownloading() const { return schemeIsDownloading( getScheme() ); }
277 
287  bool
288  isValid() const;
289 
290 
291  // -----------------
299  std::string
300  asString() const;
301 
314  std::string
315  asString(const ViewOptions &opts) const;
316 
326  std::string
327  asCompleteString() const;
328 
329 
330  // -----------------
335  std::string
336  getScheme() const;
337 
338 
339  // -----------------
349  std::string
350  getAuthority() const;
351 
359  std::string
361 
369  std::string
371 
376  { return ! ( getUsername().empty() || getPassword().empty() ); }
377 
390  std::string
391  getHost(EEncoding eflag = zypp::url::E_DECODED) const;
392 
397  std::string
398  getPort() const;
399 
400 
401  // -----------------
411  std::string
412  getPathData() const;
413 
422  std::string
424 
429  std::string
430  getPathParams() const;
431 
445  getPathParamsVec() const;
446 
468 
485  std::string
486  getPathParam(const std::string &param,
487  EEncoding eflag = zypp::url::E_DECODED) const;
488 
489 
490  // -----------------
500  std::string
501  getQueryString() const;
502 
517  getQueryStringVec() const;
518 
539 
556  std::string
557  getQueryParam(const std::string &param,
558  EEncoding eflag = zypp::url::E_DECODED) const;
559 
560 
561  // -----------------
569  std::string
571 
572 
573  // -----------------
580  void
581  setScheme(const std::string &scheme);
582 
583 
584  // -----------------
598  void
599  setAuthority(const std::string &authority);
600 
610  void
611  setUsername(const std::string &user,
613 
623  void
624  setPassword(const std::string &pass,
626 
647  void
648  setHost(const std::string &host);
649 
657  void
658  setPort(const std::string &port);
659 
660 
661  // -----------------
672  void
673  setPathData(const std::string &pathdata);
674 
682  void
683  setPathName(const std::string &path,
686  void
687  setPathName(const Pathname &path,
690  void
691  setPathName(const char *path,
693 
697  void appendPathName( const Pathname & path_r, EEncoding eflag_r = zypp::url::E_DECODED );
698 
705  void
706  setPathParams(const std::string &params);
707 
714  void
716 
723  void
725 
735  void
736  setPathParam(const std::string &param, const std::string &value);
737 
738 
739  // -----------------
746  void
747  setQueryString(const std::string &querystr);
748 
755  void
757 
764  void
766 
776  void
777  setQueryParam(const std::string &param, const std::string &value);
778 
787  void
788  delQueryParam(const std::string &param);
789 
790 
791  // -----------------
799  void
800  setFragment(const std::string &fragment,
802 
803 
804  // -----------------
814  getViewOptions() const;
815 
824  void
825  setViewOptions(const ViewOptions &vopts);
826 
827  private:
828  friend std::string hotfix1050625::asString( const Url & url_r );
830  };
831 
832  std::ostream & operator<<( std::ostream & str, const Url & url );
833 
837  bool operator<( const Url &lhs, const Url &rhs );
838 
842  bool operator==( const Url &lhs, const Url &rhs );
843 
844 
845  bool operator!=( const Url &lhs, const Url &rhs );
846 
848 } // namespace zypp
850 
851 #endif /* ZYPP_URL_H */
852 /*
853 ** vim: set ts=2 sts=2 sw=2 ai et:
854 */
zypp::misc::testcase::TestcaseRepoType::Helix
@ Helix
zypp::Url::getScheme
std::string getScheme() const
Returns the scheme name of the URL.
Definition: Url.cc:528
zypp::Url::appendPathName
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition: Url.cc:781
zypp::Url::getRegisteredSchemes
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
Definition: Url.cc:415
zypp::Url::getQueryStringVec
zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition: Url.cc:639
zypp::operator<
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
Definition: StrMatcher.cc:335
zypp::Url::setViewOptions
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition: Url.cc:854
zypp::Url::getFragment
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
Definition: Url.cc:559
zypp::Url::setPathParam
void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition: Url.cc:810
zypp::hotfix1050625::asString
std::string asString(const Url &url_r)
Definition: Url.cc:881
UrlUtils.h
zypp::url::E_DECODED
@ E_DECODED
Flag to request decoded string(s).
Definition: UrlUtils.h:54
zypp::url::UrlSchemes
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition: UrlBase.h:251
zypp::Url::setQueryParam
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: Url.cc:833
zypp::Url::getPathParamsVec
zypp::url::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
Definition: Url.cc:615
zypp::Url::setAuthority
void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition: Url.cc:693
zypp::operator==
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SetRelationMixin.h:84
zypp::Url::setQueryStringVec
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition: Url.cc:818
zypp::ResolverNamespace::language
@ language
language support
zypp::Url::setPathParams
void setPathParams(const std::string &params)
Set the path parameters.
Definition: Url.cc:786
zypp::Url::hasCredentialsInAuthority
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
Definition: Url.h:375
zypp::Url::setPort
void setPort(const std::string &port)
Set the port number in the URL authority.
Definition: Url.cc:751
zypp::Url::setUsername
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition: Url.cc:725
zypp::Url::getQueryStringMap
zypp::url::ParamMap getQueryStringMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with query parameter and their values.
Definition: Url.cc:647
zypp::Url::setHost
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition: Url.cc:743
zypp::Url::registerScheme
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
Definition: Url.cc:361
zypp::Url::isRegisteredScheme
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
Definition: Url.cc:424
zypp::Url::getPathParams
std::string getPathParams() const
Returns the path parameters from the URL.
Definition: Url.cc:607
zypp::url::EEncoding
EEncoding
Encoding flags.
Definition: UrlUtils.h:52
zypp::Url::getKnownSchemes
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
Definition: Url.cc:432
zypp::Url::getViewOptions
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition: Url.cc:847
zypp::Url::setFragment
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition: Url.cc:717
zypp::Url::getQueryParam
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition: Url.cc:655
zypp::Url::setScheme
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition: Url.cc:663
zypp::Url::EEncoding
zypp::url::EEncoding EEncoding
Encoding flags.
Definition: Url.h:97
zypp::Url::parseUrl
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
Definition: Url.cc:371
zypp::Url::asString
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:492
zypp::Url::setPathName
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition: Url.cc:759
zypp::Url::getPathData
std::string getPathData() const
Returns the encoded path component of the URL.
Definition: Url.cc:543
zypp::Url::getPort
std::string getPort() const
Returns the port from the URL authority.
Definition: Url.cc:591
zypp::Url::operator=
Url & operator=(const std::string &encodedUrl)
Assigns parsed percent-encoded URL string to the object.
Definition: Url.cc:335
zypp::Url::getPathParamsMap
zypp::url::ParamMap getPathParamsMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with path parameter keys and values.
Definition: Url.cc:623
zypp::Url::Url
Url()
Definition: Url.cc:288
zypp::Url::isValid
bool isValid() const
Verifies the Url.
Definition: Url.cc:484
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::Url::setPathData
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition: Url.cc:701
zypp::Url::asCompleteString
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition: Url.cc:500
zypp::Url::schemeIsVolatile
bool schemeIsVolatile() const
Definition: Url.h:271
zypp::url::ParamMap
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition: UrlUtils.h:47
zypp::Url::ViewOptions
zypp::url::ViewOptions ViewOptions
View options.
Definition: Url.h:102
zypp::Url::getAuthority
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition: Url.cc:536
zypp::Url::setQueryString
void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition: Url.cc:709
zypp::url::ParamVec
std::vector< std::string > ParamVec
A parameter vector container.
Definition: UrlUtils.h:40
zypp::Url::isValidScheme
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
Definition: Url.cc:440
zypp::operator!=
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SetRelationMixin.h:109
zypp::Url::getPathName
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition: Url.cc:599
zypp::Url::~Url
~Url()
Definition: Url.cc:282
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::Url::schemeIsDownloading
bool schemeIsDownloading() const
Definition: Url.h:276
zypp::Url::schemeIsRemote
bool schemeIsRemote() const
Definition: Url.h:266
zypp::Url::m_impl
url::UrlRef m_impl
Definition: Url.h:829
UrlBase.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::Url::getHost
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Definition: Url.cc:583
zypp::RWCOW_pointer< UrlBase >
str
String related utilities and Regular expression matching.
zypp::Url::getPassword
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition: Url.cc:575
zypp::url::ViewOption
Url::asString() view options.
Definition: UrlBase.h:40
zypp::Url::getQueryString
std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition: Url.cc:551
url
Url url
Definition: MediaCurl.cc:66
zypp::Url::getPathParam
std::string getPathParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified path parameter.
Definition: Url.cc:631
zypp::Url
Url manipulation class.
Definition: Url.h:92
zypp::Url::setQueryStringMap
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition: Url.cc:826
zypp::Url::setPassword
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition: Url.cc:734
zypp::Url::getUsername
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition: Url.cc:567
zypp::Url::delQueryParam
void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition: Url.cc:840
zypp::Url::setPathParamsMap
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition: Url.cc:802
zypp::Url::setPathParamsVec
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition: Url.cc:794
zypp::Url::schemeIsLocal
bool schemeIsLocal() const
Definition: Url.h:261