libzypp 17.25.7
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
20namespace 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
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 );
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
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*/
Url url
Definition: MediaCurl.cc:66
Url manipulation class.
Definition: Url.h:92
zypp::url::EEncoding EEncoding
Encoding flags.
Definition: Url.h:97
zypp::url::ViewOptions ViewOptions
View options.
Definition: Url.h:102
std::string getScheme() const
Returns the scheme name of the URL.
Definition: Url.cc:528
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition: Url.cc:500
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition: Url.cc:854
void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition: Url.cc:693
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::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
Definition: Url.cc:615
void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition: Url.cc:709
bool schemeIsRemote() const
Definition: Url.h:266
std::string getPathParams() const
Returns the path parameters from the URL.
Definition: Url.cc:607
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:492
std::string getPathData() const
Returns the encoded path component of the URL.
Definition: Url.cc:543
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
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition: Url.cc:536
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition: Url.cc:567
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:717
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition: Url.cc:599
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition: Url.cc:818
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:655
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition: Url.cc:759
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition: Url.cc:802
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition: Url.cc:847
bool schemeIsDownloading() const
Definition: Url.h:276
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition: Url.cc:701
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Definition: Url.cc:583
url::UrlRef m_impl
Definition: Url.h:829
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition: Url.cc:743
void setPort(const std::string &port)
Set the port number in the URL authority.
Definition: Url.cc:751
~Url()
Definition: Url.cc:282
void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition: Url.cc:840
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition: Url.cc:794
bool isValid() const
Verifies the Url.
Definition: Url.cc:484
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
Definition: Url.cc:559
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:810
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition: Url.cc:734
void setPathParams(const std::string &params)
Set the path parameters.
Definition: Url.cc:786
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:551
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:833
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:639
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:725
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:375
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition: Url.cc:781
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition: Url.cc:663
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition: Url.cc:575
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:647
std::string getPort() const
Returns the port from the URL authority.
Definition: Url.cc:591
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition: Url.cc:826
String related utilities and Regular expression matching.
std::string asString(const Url &url_r)
Definition: Url.cc:881
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
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
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...
Url::asString() view options.
Definition: UrlBase.h:40