libzypp: zypp-core/url/UrlBase.h Source File

libzypp 17.38.11

UrlBase.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_URL_URLBASE_H
13#define ZYPP_URL_URLBASE_H
14
15#include <set>
16#include <zypp-core/url/UrlUtils.h>
17#include <zypp-core/base/PtrTypes.h>
18
19
21namespace zypp
22{
23
25 namespace url
26 {
27
28
29 // ---------------------------------------------------------------
40 struct ZYPP_API ViewOption
41 {
52 static const ViewOption WITH_SCHEME ZYPP_API;
59 static const ViewOption WITH_USERNAME ZYPP_API;
68 static const ViewOption WITH_PASSWORD ZYPP_API;
75 static const ViewOption WITH_HOST ZYPP_API;
82 static const ViewOption WITH_PORT ZYPP_API;
88 static const ViewOption WITH_PATH_NAME ZYPP_API;
96 static const ViewOption WITH_PATH_PARAMS ZYPP_API;
102 static const ViewOption WITH_QUERY_STR ZYPP_API;
108 static const ViewOption WITH_FRAGMENT ZYPP_API;
110
122 static const ViewOption EMPTY_AUTHORITY ZYPP_API;
134 static const ViewOption EMPTY_PATH_NAME ZYPP_API;
144 static const ViewOption EMPTY_PATH_PARAMS ZYPP_API;
155 static const ViewOption EMPTY_QUERY_STR ZYPP_API;
166 static const ViewOption EMPTY_FRAGMENT ZYPP_API;
168
178 static const ViewOption DEFAULTS ZYPP_API;
180
181
185 ViewOption();
186
187
193 friend inline ViewOption
194 operator + (const ViewOption &l, const ViewOption &r)
195 {
196 return ViewOption(l.opt | r.opt);
197 }
198
204 friend inline ViewOption
205 operator - (const ViewOption &l, const ViewOption &r)
206 {
207 return ViewOption(l.opt & ~r.opt);
208 }
209
216 inline ViewOption &
217 operator = (const ViewOption &o)
218 {
219 opt = o.opt; return *this;
220 }
221
228 inline bool
229 has(const ViewOption &o) const
230 {
231 return o.opt & opt;
232 }
233
234 static const ViewOption hotfix1050625;
235 private:
236 ViewOption(int option);
237 int opt;
238 };
239
240
241 // ---------------------------------------------------------------
245 using ViewOptions = ViewOption;
246
247
248 // ---------------------------------------------------------------
252 using UrlSchemes = std::vector<std::string>;
253
254
255 // ---------------------------------------------------------------
259 class UrlBaseData;
260
261
262 // ---------------------------------------------------------------
271 class UrlBase
272 {
273 public:
274
275 virtual
276 ~UrlBase();
277
278 UrlBase();
279
284 UrlBase(const UrlBase &url);
285
300 UrlBase(const std::string &scheme,
301 const std::string &authority,
302 const std::string &pathdata,
303 const std::string &querystr,
304 const std::string &fragment);
305
306
307 // -----------------
311 virtual void
312 clear();
313
325 virtual UrlBase *
326 clone() const;
327
341 virtual void
342 init(const std::string &scheme,
343 const std::string &authority,
344 const std::string &pathdata,
345 const std::string &querystr,
346 const std::string &fragment);
347
348
349 // -----------------
367 virtual UrlSchemes
368 getKnownSchemes() const;
369
374 virtual bool
375 isKnownScheme(const std::string &scheme) const;
376
377
390 virtual bool
391 isValidScheme(const std::string &scheme) const;
392
402 virtual bool
403 isValid() const;
404
405
406 // -----------------
414 virtual std::string
415 asString() const;
416
429 virtual std::string
430 asString(const zypp::url::ViewOptions &opts) const;
431
432
433 // -----------------
438 virtual std::string
439 getScheme() const;
440
441
442 // -----------------
452 virtual std::string
453 getAuthority() const;
454
462 virtual std::string
463 getUsername(EEncoding eflag) const;
464
472 virtual std::string
473 getPassword(EEncoding eflag) const;
474
487 virtual std::string
488 getHost(EEncoding eflag) const;
489
494 virtual std::string
495 getPort() const;
496
497
498 // -----------------
508 virtual std::string
509 getPathData() const;
510
519 virtual std::string
520 getPathName(EEncoding eflag) const;
521
526 virtual std::string
527 getPathParams() const;
528
541 virtual zypp::url::ParamVec
542 getPathParamsVec() const;
543
563 virtual zypp::url::ParamMap
564 getPathParamsMap(EEncoding eflag) const;
565
582 virtual std::string
583 getPathParam(const std::string &param, EEncoding eflag) const;
584
585
586 // -----------------
596 virtual std::string
597 getQueryString() const;
598
600 virtual std::string
601 getQueryString( const ViewOptions & viewopts_r ) const;
602
616 virtual zypp::url::ParamVec
617 getQueryStringVec() const;
618
637 virtual zypp::url::ParamMap
638 getQueryStringMap(EEncoding eflag) const;
639
656 virtual std::string
657 getQueryParam(const std::string &param, EEncoding eflag) const;
658
659
660 // -----------------
668 virtual std::string
669 getFragment(EEncoding eflag) const;
670
671
672 // -----------------
679 virtual void
680 setScheme(const std::string &scheme);
681
682
683 // -----------------
697 virtual void
698 setAuthority(const std::string &authority);
699
709 virtual void
710 setUsername(const std::string &user,
711 EEncoding eflag);
712
722 virtual void
723 setPassword(const std::string &pass,
724 EEncoding eflag);
725
746 virtual void
747 setHost(const std::string &host);
748
756 virtual void
757 setPort(const std::string &port);
758
759
760 // -----------------
771 virtual void
772 setPathData(const std::string &pathdata);
773
781 virtual void
782 setPathName(const std::string &path,
783 EEncoding eflag);
784
791 virtual void
792 setPathParams(const std::string &params);
793
800 virtual void
801 setPathParamsVec(const zypp::url::ParamVec &pvec);
802
809 virtual void
810 setPathParamsMap(const zypp::url::ParamMap &pmap);
811
821 virtual void
822 setPathParam(const std::string &param, const std::string &value);
823
824
825 // -----------------
838 virtual void
839 setQueryString(const std::string &querystr);
840
847 virtual void
848 setQueryStringVec(const zypp::url::ParamVec &qvec);
849
857 virtual void
858 setQueryStringMap(const zypp::url::ParamMap &qmap, EEncoding eflag);
859
869 virtual void
870 setQueryParam(const std::string &param, const std::string &value);
871
880 virtual void
881 delQueryParam(const std::string &param);
882
883 void
884 delQueryParams(const std::set<std::string> &params);
885
886 // -----------------
894 virtual void
895 setFragment(const std::string &fragment,
896 EEncoding eflag);
897
898
899 // -----------------
955 virtual void
956 configure();
957
958
969 std::string
970 config(const std::string &opt) const;
971
981 void
982 config(const std::string &opt, const std::string &val);
983
984
993 ViewOptions
994 getViewOptions() const;
995
1004 void
1005 setViewOptions(const ViewOptions &vopts);
1006
1007 std::string asString1050625() const;
1008 protected:
1035 virtual std::string
1036 cleanupPathName(const std::string &path, bool authority) const;
1037
1048 virtual std::string
1049 cleanupPathName(const std::string &path) const;
1050
1072 virtual bool
1073 isValidHost(const std::string &host) const;
1074
1081 virtual bool
1082 isValidPort(const std::string &port) const;
1083
1084 private:
1085 UrlBaseData *m_data;
1086 };
1087
1088
1089 // ---------------------------------------------------------------
1093 using UrlRef = RWCOW_pointer<UrlBase>;
1094
1095
1097 } // namespace url
1099
1101} // namespace zypp
1103
1104#endif /* ZYPP_URL_URLBASE_H */
1105/*
1106** vim: set ts=2 sts=2 sw=2 ai et:
1107*/
PtrTypes.h
UrlUtils.h
zypp::url::UrlBaseData
Internal data used by UrlBase.
Definition UrlBase.cc:180
zypp::url::UrlBase::clone
virtual UrlBase * clone() const
Returns pointer to a copy of the current object.
Definition UrlBase.cc:408
zypp::url::UrlBase::setQueryString
virtual void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition UrlBase.cc:969
zypp::url::UrlBase::getQueryString
virtual std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition UrlBase.cc:698
zypp::url::UrlBase::getPort
virtual std::string getPort() const
Returns the port number from the URL authority.
Definition UrlBase.cc:755
zypp::url::UrlBase::setScheme
virtual void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition UrlBase.cc:892
zypp::url::UrlBase::setHost
virtual void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition UrlBase.cc:1081
zypp::url::UrlBase::getPathParamsMap
virtual zypp::url::ParamMap getPathParamsMap(EEncoding eflag) const
Returns a string map with path parameter keys and values.
Definition UrlBase.cc:803
zypp::url::UrlBase::getPathParamsVec
virtual zypp::url::ParamVec getPathParamsVec() const
Returns a vector with encoded path parameter substrings.
Definition UrlBase.cc:782
zypp::url::UrlBase::getUsername
virtual std::string getUsername(EEncoding eflag) const
Returns the username from the URL authority.
Definition UrlBase.cc:722
zypp::url::UrlBase::getKnownSchemes
virtual UrlSchemes getKnownSchemes() const
Returns scheme names known by this object.
Definition UrlBase.cc:416
zypp::url::UrlBase::getAuthority
virtual std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition UrlBase.cc:661
zypp::url::UrlBase::setQueryParam
virtual void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition UrlBase.cc:1324
zypp::url::UrlBase::config
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
Definition UrlBase.cc:368
zypp::url::UrlBase::setPathParamsVec
virtual void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition UrlBase.cc:1243
zypp::url::UrlBase::getFragment
virtual std::string getFragment(EEncoding eflag) const
Returns the encoded fragment component of the URL.
Definition UrlBase.cc:711
zypp::url::UrlBase::getPathParams
virtual std::string getPathParams() const
Returns the encoded path parameters from the URL.
Definition UrlBase.cc:774
zypp::url::UrlBase::~UrlBase
virtual ~UrlBase()
Definition UrlBase.cc:258
zypp::url::UrlBase::m_data
UrlBaseData * m_data
Definition UrlBase.h:1085
zypp::url::UrlBase::getPassword
virtual std::string getPassword(EEncoding eflag) const
Returns the password from the URL authority.
Definition UrlBase.cc:733
zypp::url::UrlBase::getScheme
virtual std::string getScheme() const
Returns the scheme name of the URL.
Definition UrlBase.cc:653
zypp::url::UrlBase::getQueryStringMap
virtual zypp::url::ParamMap getQueryStringMap(EEncoding eflag) const
Returns a string map with query parameter and their values.
Definition UrlBase.cc:858
zypp::url::UrlBase::setUsername
virtual void setUsername(const std::string &user, EEncoding eflag)
Set the username in the URL authority.
Definition UrlBase.cc:1013
zypp::url::UrlBase::getPathParam
virtual std::string getPathParam(const std::string &param, EEncoding eflag) const
Return the value for the specified path parameter.
Definition UrlBase.cc:826
zypp::url::UrlBase::setQueryStringMap
virtual void setQueryStringMap(const zypp::url::ParamMap &qmap, EEncoding eflag)
Set the query parameters.
Definition UrlBase.cc:1302
zypp::url::UrlBase::configure
virtual void configure()
Configures behaviour of the instance.
Definition UrlBase.cc:315
zypp::url::UrlBase::setPathParamsMap
virtual void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition UrlBase.cc:1256
zypp::url::UrlBase::cleanupPathName
virtual std::string cleanupPathName(const std::string &path, bool authority) const
Utility method to cleanup an encoded path name.
Definition UrlBase.cc:1389
zypp::url::UrlBase::isValidHost
virtual bool isValidHost(const std::string &host) const
Verifies specified host or IP.
Definition UrlBase.cc:1441
zypp::url::UrlBase::asString
virtual std::string asString() const
Returns a default string representation of the Url object.
Definition UrlBase.cc:505
zypp::url::UrlBase::delQueryParams
void delQueryParams(const std::set< std::string > &params)
Definition UrlBase.cc:1364
zypp::url::UrlBase::isKnownScheme
virtual bool isKnownScheme(const std::string &scheme) const
Returns if scheme name is known to this object.
Definition UrlBase.cc:424
zypp::url::UrlBase::getHost
virtual std::string getHost(EEncoding eflag) const
Returns the hostname or IP from the URL authority.
Definition UrlBase.cc:744
zypp::url::UrlBase::setPathData
virtual void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition UrlBase.cc:944
zypp::url::UrlBase::setPathName
virtual void setPathName(const std::string &path, EEncoding eflag)
Set the path name.
Definition UrlBase.cc:1166
zypp::url::UrlBase::setPort
virtual void setPort(const std::string &port)
Set the port number in the URL authority.
Definition UrlBase.cc:1134
zypp::url::UrlBase::getPathData
virtual std::string getPathData() const
Returns the encoded path component of the URL.
Definition UrlBase.cc:688
zypp::url::UrlBase::isValid
virtual bool isValid() const
Verifies the Url.
Definition UrlBase.cc:473
zypp::url::UrlBase::getPathName
virtual std::string getPathName(EEncoding eflag) const
Returns the path name from the URL.
Definition UrlBase.cc:763
zypp::url::UrlBase::setFragment
virtual void setFragment(const std::string &fragment, EEncoding eflag)
Set the fragment string in the URL.
Definition UrlBase.cc:986
zypp::url::UrlBase::clear
virtual void clear()
Clears all data in the object.
Definition UrlBase.cc:396
zypp::url::UrlBase::isValidScheme
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
Definition UrlBase.cc:441
zypp::url::UrlBase::getQueryStringVec
virtual zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition UrlBase.cc:837
zypp::url::UrlBase::UrlBase
UrlBase()
Definition UrlBase.cc:266
zypp::url::UrlBase::getQueryParam
virtual std::string getQueryParam(const std::string &param, EEncoding eflag) const
Return the value for the specified query parameter.
Definition UrlBase.cc:881
zypp::url::UrlBase::setViewOptions
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition UrlBase.cc:388
zypp::url::UrlBase::setQueryStringVec
virtual void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition UrlBase.cc:1289
zypp::url::UrlBase::delQueryParam
virtual void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition UrlBase.cc:1348
zypp::url::UrlBase::setPassword
virtual void setPassword(const std::string &pass, EEncoding eflag)
Set the password in the URL authority.
Definition UrlBase.cc:1047
zypp::url::UrlBase::setPathParam
virtual void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition UrlBase.cc:1279
zypp::url::UrlBase::init
virtual void init(const std::string &scheme, const std::string &authority, const std::string &pathdata, const std::string &querystr, const std::string &fragment)
Initializes current object with new URL components.
Definition UrlBase.cc:295
zypp::url::UrlBase::setPathParams
virtual void setPathParams(const std::string &params)
Set the path parameters.
Definition UrlBase.cc:1226
zypp::url::UrlBase::asString1050625
std::string asString1050625() const
Definition UrlBase.cc:510
zypp::url::UrlBase::setAuthority
virtual void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition UrlBase.cc:916
zypp::url::UrlBase::getViewOptions
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition UrlBase.cc:380
zypp::url::UrlBase::isValidPort
virtual bool isValidPort(const std::string &port) const
Verifies specified port number.
Definition UrlBase.cc:1470
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
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
zypp::url::ViewOption
Url::asString() view options.
Definition UrlBase.h:41
zypp::url::ViewOption::ZYPP_API
static const ViewOption WITH_SCHEME ZYPP_API
Option to include scheme name in the URL string.
Definition UrlBase.h:52
zypp::url::ViewOption::opt
int opt
Definition UrlBase.h:237
zypp::url::ViewOption::has
bool has(const ViewOption &o) const
Check if specified option o is set in the current object.
Definition UrlBase.h:229
zypp::url::ViewOption::hotfix1050625
static const ViewOption hotfix1050625
Definition UrlBase.h:234
zypp::url::ViewOption::ViewOption
ViewOption()
Create instance with default combination of view options.
Definition UrlBase.cc:96