libzypp: zypp-core/Url.h Source File

libzypp 17.38.14

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 <set>
16#include <zypp-core/url/UrlBase.h>
17#include <zypp-core/url/UrlUtils.h>
18
19
21namespace zypp
22{
23
24 class Url;
25 namespace hotfix1050625 {
26 std::string asString( const Url & url_r );
27 }
28 namespace filesystem {
29 class Pathname;
30 }
31 using filesystem::Pathname;
32
92 class ZYPP_API Url
93 {
94 public:
98 using EEncoding = zypp::url::EEncoding;
99
103 using ViewOptions = zypp::url::ViewOptions;
104
105
106 ~Url();
107 Url();
108
119 Url(const Url &url);
120
121
132 Url(zypp::url::UrlRef url);
133
134
148 Url(const std::string &encodedUrl);
149
150
154 Url(Url &&other) = default;
155
156
157 // -----------------
174 static url::UrlRef
175 parseUrl(const std::string &encodedUrl);
176
177
178 // -----------------
193 Url&
194 operator = (const std::string &encodedUrl);
195
196
207 Url&
208 operator = (const Url &url);
209
210
214 Url &operator=(Url &&other) = default;
215
216
217 // -----------------
225 static bool
226 registerScheme(const std::string &scheme,
227 url::UrlRef urlImpl);
228
233 static zypp::url::UrlSchemes
234 getRegisteredSchemes();
235
240 static bool
241 isRegisteredScheme(const std::string &scheme);
242
243
244 // -----------------
249 zypp::url::UrlSchemes
250 getKnownSchemes() const;
251
252
267 bool
268 isValidScheme(const std::string &scheme) const;
269
270
272 static bool schemeIsLocal( const std::string & scheme_r );
274 bool schemeIsLocal() const { return schemeIsLocal( getScheme() ); }
275
277 static bool schemeIsRemote( const std::string & scheme_r );
279 bool schemeIsRemote() const { return schemeIsRemote( getScheme() ); }
280
282 static bool schemeIsVolatile( const std::string & scheme_r );
284 bool schemeIsVolatile() const { return schemeIsVolatile( getScheme() ); }
285
287 static bool schemeIsDownloading( const std::string & scheme_r );
288 static bool schemeIsHttpLike( const std::string & scheme_r );
289 static bool schemeIsFtpLike( const std::string & scheme_r );
291 bool schemeIsDownloading() const { return schemeIsDownloading( getScheme() ); }
292 bool schemeIsHttpLike() const { return schemeIsHttpLike( getScheme() ); }
293 bool schemeIsFtpLike() const { return schemeIsFtpLike( getScheme() ); }
294
296 static bool schemeIsPlugin( const std::string & scheme_r );
298 bool schemeIsPlugin() const { return schemeIsPlugin( getScheme() ); }
299
309 bool
310 isValid() const;
311
312
313 // -----------------
321 std::string
322 asString() const;
323
336 std::string
337 asString(const ViewOptions &opts) const;
338
348 std::string
349 asCompleteString() const;
350
351
352 // -----------------
357 std::string
358 getScheme() const;
359
360
361 // -----------------
371 std::string
372 getAuthority() const;
373
381 std::string
382 getUsername(EEncoding eflag = zypp::url::E_DECODED) const;
383
391 std::string
392 getPassword(EEncoding eflag = zypp::url::E_DECODED) const;
393
397 bool hasCredentialsInAuthority() const
398 { return ! ( getUsername().empty() || getPassword().empty() ); }
399
412 std::string
413 getHost(EEncoding eflag = zypp::url::E_DECODED) const;
414
419 std::string
420 getPort() const;
421
422
423 // -----------------
433 std::string
434 getPathData() const;
435
444 std::string
445 getPathName(EEncoding eflag = zypp::url::E_DECODED) const;
446
451 std::string
452 getPathParams() const;
453
466 zypp::url::ParamVec
467 getPathParamsVec() const;
468
488 zypp::url::ParamMap
489 getPathParamsMap(EEncoding eflag = zypp::url::E_DECODED) const;
490
507 std::string
508 getPathParam(const std::string &param,
509 EEncoding eflag = zypp::url::E_DECODED) const;
510
511
512 // -----------------
522 std::string
523 getQueryString() const;
524
538 zypp::url::ParamVec
539 getQueryStringVec() const;
540
559 zypp::url::ParamMap
560 getQueryStringMap(EEncoding eflag = zypp::url::E_DECODED) const;
561
578 std::string
579 getQueryParam(const std::string &param,
580 EEncoding eflag = zypp::url::E_DECODED) const;
581
582
583 // -----------------
591 std::string
592 getFragment(EEncoding eflag = zypp::url::E_DECODED) const;
593
594
595 // -----------------
602 void
603 setScheme(const std::string &scheme);
604
605
606 // -----------------
620 void
621 setAuthority(const std::string &authority);
622
632 void
633 setUsername(const std::string &user,
634 EEncoding eflag = zypp::url::E_DECODED);
635
645 void
646 setPassword(const std::string &pass,
647 EEncoding eflag = zypp::url::E_DECODED);
648
669 void
670 setHost(const std::string &host);
671
679 void
680 setPort(const std::string &port);
681
682
683 // -----------------
694 void
695 setPathData(const std::string &pathdata);
696
704 void
705 setPathName(const std::string &path,
706 EEncoding eflag = zypp::url::E_DECODED);
708 void
709 setPathName(const Pathname &path,
710 EEncoding eflag = zypp::url::E_DECODED);
712 void
713 setPathName(const char *path,
714 EEncoding eflag = zypp::url::E_DECODED);
715
719 void appendPathName( const Pathname & path_r, EEncoding eflag_r = zypp::url::E_DECODED );
720
724 void pathNameSetTrailingSlash( bool apply_r = true );
725
732 void
733 setPathParams(const std::string &params);
734
741 void
742 setPathParamsVec(const zypp::url::ParamVec &pvec);
743
750 void
751 setPathParamsMap(const zypp::url::ParamMap &pmap);
752
762 void
763 setPathParam(const std::string &param, const std::string &value);
764
765
766 // -----------------
773 void
774 setQueryString(const std::string &querystr);
775
782 void
783 setQueryStringVec(const zypp::url::ParamVec &qvec);
784
791 void
792 setQueryStringMap(const zypp::url::ParamMap &qmap);
793
803 void
804 setQueryParam(const std::string &param, const std::string &value);
805
814 void
815 delQueryParam(const std::string &param);
816
818 void
819 delQueryParams(const std::set<std::string> &params);
820
821
822 // -----------------
830 void
831 setFragment(const std::string &fragment,
832 EEncoding eflag = zypp::url::E_DECODED);
833
834
835 // -----------------
844 ViewOptions
845 getViewOptions() const;
846
855 void
856 setViewOptions(const ViewOptions &vopts);
857
858 private:
859 friend std::string hotfix1050625::asString( const Url & url_r );
860 url::UrlRef m_impl;
861 };
862
863 std::ostream & operator<<( std::ostream & str, const Url & url ) ZYPP_API;
864
868 bool operator<( const Url &lhs, const Url &rhs ) ZYPP_API;
869
873 bool operator==( const Url &lhs, const Url &rhs ) ZYPP_API;
874
875
876 bool operator!=( const Url &lhs, const Url &rhs ) ZYPP_API;
877
879} // namespace zypp
881
882#endif /* ZYPP_URL_H */
883/*
884** vim: set ts=2 sts=2 sw=2 ai et:
885*/
UrlBase.h
UrlUtils.h
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::Url::schemeIsPlugin
bool schemeIsPlugin() const
Definition Url.h:298
zypp::Url::getScheme
std::string getScheme() const
Returns the scheme name of the URL.
Definition Url.cc:560
zypp::Url::ViewOptions
zypp::url::ViewOptions ViewOptions
View options.
Definition Url.h:103
zypp::Url::schemeIsRemote
bool schemeIsRemote() const
Definition Url.h:279
zypp::Url::getUsername
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition Url.cc:599
zypp::Url::isRegisteredScheme
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
Definition Url.cc:442
zypp::Url::Url
Url()
Definition Url.cc:306
zypp::Url::schemeIsDownloading
bool schemeIsDownloading() const
Definition Url.h:291
zypp::Url::m_impl
url::UrlRef m_impl
Definition Url.h:860
zypp::Url::schemeIsLocal
static bool schemeIsLocal(const std::string &scheme_r)
hd cd dvd dir file iso
Definition Url.cc:475
zypp::Url::parseUrl
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
Definition Url.cc:389
zypp::Url::schemeIsHttpLike
bool schemeIsHttpLike() const
Definition Url.h:292
zypp::Url::operator=
Url & operator=(Url &&other)=default
Moves the data from other into the current object.
zypp::Url::EEncoding
zypp::url::EEncoding EEncoding
Encoding flags.
Definition Url.h:98
zypp::Url::registerScheme
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
Definition Url.cc:379
zypp::Url::isValidScheme
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
Definition Url.cc:458
zypp::Url::getRegisteredSchemes
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
Definition Url.cc:433
zypp::Url::schemeIsLocal
bool schemeIsLocal() const
Definition Url.h:274
zypp::Url::getKnownSchemes
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
Definition Url.cc:450
zypp::Url::hasCredentialsInAuthority
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
Definition Url.h:397
zypp::Url::getPassword
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition Url.cc:607
zypp::Url::schemeIsVolatile
bool schemeIsVolatile() const
Definition Url.h:284
zypp::Url::schemeIsFtpLike
bool schemeIsFtpLike() const
Definition Url.h:293
zypp::Url::Url
Url(Url &&other)=default
Move construct a Url object.
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
str
String related utilities and Regular expression matching.
zypp::filesystem
Types and functions for filesystem operations.
Definition Glob.cc:24
zypp::hotfix1050625
Definition Url.cc:956
zypp::hotfix1050625::asString
std::string asString(const Url &url_r)
Definition Url.cc:957
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp::url::UrlRef
RWCOW_pointer< UrlBase > UrlRef
Copy-On-Write Url reference.
Definition UrlBase.h:1093
zypp::url::ParamVec
std::vector< std::string > ParamVec
A parameter vector container.
Definition UrlUtils.h:40
zypp::url::ViewOptions
ViewOption ViewOptions
ViewOptions is just an alias for ViewOption.
Definition UrlBase.h:245
zypp::url::ParamMap
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition UrlUtils.h:47
zypp::url::UrlSchemes
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition UrlBase.h:252
zypp::url::EEncoding
EEncoding
Encoding flags.
Definition UrlUtils.h:52
zypp::url::E_DECODED
@ E_DECODED
Flag to request decoded string(s).
Definition UrlUtils.h:54
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::operator<
bool operator<(const Capability &lhs, const Capability &rhs)
relates: Capability Arbitrary order.
Definition Capability.h:317
zypp::operator!=
bool operator!=(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition Capability.h:313
zypp::operator==
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition Capability.h:309
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65