libzypp  17.28.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-core/url/UrlBase.h>
16 #include <zypp-core/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 
279  static bool schemeIsPlugin( const std::string & scheme_r );
281  bool schemeIsPlugin() const { return schemeIsPlugin( getScheme() ); }
282 
292  bool
293  isValid() const;
294 
295 
296  // -----------------
304  std::string
305  asString() const;
306 
319  std::string
320  asString(const ViewOptions &opts) const;
321 
331  std::string
332  asCompleteString() const;
333 
334 
335  // -----------------
340  std::string
341  getScheme() const;
342 
343 
344  // -----------------
354  std::string
355  getAuthority() const;
356 
364  std::string
366 
374  std::string
376 
381  { return ! ( getUsername().empty() || getPassword().empty() ); }
382 
395  std::string
396  getHost(EEncoding eflag = zypp::url::E_DECODED) const;
397 
402  std::string
403  getPort() const;
404 
405 
406  // -----------------
416  std::string
417  getPathData() const;
418 
427  std::string
429 
434  std::string
435  getPathParams() const;
436 
450  getPathParamsVec() const;
451 
473 
490  std::string
491  getPathParam(const std::string &param,
492  EEncoding eflag = zypp::url::E_DECODED) const;
493 
494 
495  // -----------------
505  std::string
506  getQueryString() const;
507 
522  getQueryStringVec() const;
523 
544 
561  std::string
562  getQueryParam(const std::string &param,
563  EEncoding eflag = zypp::url::E_DECODED) const;
564 
565 
566  // -----------------
574  std::string
576 
577 
578  // -----------------
585  void
586  setScheme(const std::string &scheme);
587 
588 
589  // -----------------
603  void
604  setAuthority(const std::string &authority);
605 
615  void
616  setUsername(const std::string &user,
618 
628  void
629  setPassword(const std::string &pass,
631 
652  void
653  setHost(const std::string &host);
654 
662  void
663  setPort(const std::string &port);
664 
665 
666  // -----------------
677  void
678  setPathData(const std::string &pathdata);
679 
687  void
688  setPathName(const std::string &path,
691  void
692  setPathName(const Pathname &path,
695  void
696  setPathName(const char *path,
698 
702  void appendPathName( const Pathname & path_r, EEncoding eflag_r = zypp::url::E_DECODED );
703 
710  void
711  setPathParams(const std::string &params);
712 
719  void
721 
728  void
730 
740  void
741  setPathParam(const std::string &param, const std::string &value);
742 
743 
744  // -----------------
751  void
752  setQueryString(const std::string &querystr);
753 
760  void
762 
769  void
771 
781  void
782  setQueryParam(const std::string &param, const std::string &value);
783 
792  void
793  delQueryParam(const std::string &param);
794 
795 
796  // -----------------
804  void
805  setFragment(const std::string &fragment,
807 
808 
809  // -----------------
819  getViewOptions() const;
820 
829  void
830  setViewOptions(const ViewOptions &vopts);
831 
832  private:
833  friend std::string hotfix1050625::asString( const Url & url_r );
835  };
836 
837  std::ostream & operator<<( std::ostream & str, const Url & url );
838 
842  bool operator<( const Url &lhs, const Url &rhs );
843 
847  bool operator==( const Url &lhs, const Url &rhs );
848 
849 
850  bool operator!=( const Url &lhs, const Url &rhs );
851 
853 } // namespace zypp
855 
856 #endif /* ZYPP_URL_H */
857 /*
858 ** vim: set ts=2 sts=2 sw=2 ai et:
859 */
Url manipulation class.
Definition: Url.h:92
zypp::url::EEncoding EEncoding
Encoding flags.
Definition: Url.h:97
bool schemeIsPlugin() const
Definition: Url.h:281
zypp::url::ViewOptions ViewOptions
View options.
Definition: Url.h:102
std::string getScheme() const
Returns the scheme name of the URL.
Definition: Url.cc:533
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition: Url.cc:505
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition: Url.cc:859
void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition: Url.cc:698
zypp::url::ParamMap getPathParamsMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with path parameter keys and values.
Definition: Url.cc:628
zypp::url::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
Definition: Url.cc:620
void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition: Url.cc:714
bool schemeIsRemote() const
Definition: Url.h:266
std::string getPathParams() const
Returns the path parameters from the URL.
Definition: Url.cc:612
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:497
std::string getPathData() const
Returns the encoded path component of the URL.
Definition: Url.cc:548
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:636
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition: Url.cc:541
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition: Url.cc:572
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
Definition: Url.cc:424
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition: Url.cc:722
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition: Url.cc:604
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition: Url.cc:823
Url()
Definition: Url.cc:288
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:660
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition: Url.cc:764
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition: Url.cc:807
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition: Url.cc:852
bool schemeIsDownloading() const
Definition: Url.h:276
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition: Url.cc:706
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Definition: Url.cc:588
url::UrlRef m_impl
Definition: Url.h:834
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition: Url.cc:748
void setPort(const std::string &port)
Set the port number in the URL authority.
Definition: Url.cc:756
~Url()
Definition: Url.cc:282
void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition: Url.cc:845
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition: Url.cc:799
bool isValid() const
Verifies the Url.
Definition: Url.cc:489
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
Definition: Url.cc:564
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
Definition: Url.cc:371
void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition: Url.cc:815
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition: Url.cc:739
void setPathParams(const std::string &params)
Set the path parameters.
Definition: Url.cc:791
Url & operator=(const std::string &encodedUrl)
Assigns parsed percent-encoded URL string to the object.
Definition: Url.cc:335
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
Definition: Url.cc:361
std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition: Url.cc:556
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
Definition: Url.cc:440
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: Url.cc:838
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
Definition: Url.cc:415
zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition: Url.cc:644
bool schemeIsLocal() const
Definition: Url.h:261
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition: Url.cc:730
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
Definition: Url.cc:432
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
Definition: Url.h:380
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition: Url.cc:786
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition: Url.cc:668
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition: Url.cc:580
bool schemeIsVolatile() const
Definition: Url.h:271
zypp::url::ParamMap getQueryStringMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with query parameter and their values.
Definition: Url.cc:652
std::string getPort() const
Returns the port from the URL authority.
Definition: Url.cc:596
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition: Url.cc:831
String related utilities and Regular expression matching.
std::string asString(const Url &url_r)
Definition: Url.cc:886
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition: UrlBase.h:251
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition: UrlUtils.h:47
std::vector< std::string > ParamVec
A parameter vector container.
Definition: UrlUtils.h:40
EEncoding
Encoding flags.
Definition: UrlUtils.h:52
@ E_DECODED
Flag to request decoded string(s).
Definition: UrlUtils.h:54
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
Definition: StrMatcher.cc:335
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...
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...
std::ostream & operator<<(std::ostream &str, const InputStream &obj)
Definition: InputStream.cc:166
Url::asString() view options.
Definition: UrlBase.h:40