libzypp 17.34.0
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
17
18
20namespace zypp
21{
22
24 namespace url
25 {
26
27
28 // ---------------------------------------------------------------
40 {
184 ViewOption();
185
186
192 friend inline ViewOption
194 {
195 return ViewOption(l.opt | r.opt);
196 }
197
203 friend inline ViewOption
205 {
206 return ViewOption(l.opt & ~r.opt);
207 }
208
215 inline ViewOption &
217 {
218 opt = o.opt; return *this;
219 }
220
227 inline bool
228 has(const ViewOption &o) const
229 {
230 return o.opt & opt;
231 }
232
234 private:
235 ViewOption(int option);
236 int opt;
237 };
238
239
240 // ---------------------------------------------------------------
245
246
247 // ---------------------------------------------------------------
251 using UrlSchemes = std::vector<std::string>;
252
253
254 // ---------------------------------------------------------------
258 class UrlBaseData;
259
260
261 // ---------------------------------------------------------------
271 {
272 public:
273
274 virtual
275 ~UrlBase();
276
277 UrlBase();
278
283 UrlBase(const UrlBase &url);
284
299 UrlBase(const std::string &scheme,
300 const std::string &authority,
301 const std::string &pathdata,
302 const std::string &querystr,
303 const std::string &fragment);
304
305
306 // -----------------
310 virtual void
311 clear();
312
324 virtual UrlBase *
325 clone() const;
326
340 virtual void
341 init(const std::string &scheme,
342 const std::string &authority,
343 const std::string &pathdata,
344 const std::string &querystr,
345 const std::string &fragment);
346
347
348 // -----------------
366 virtual UrlSchemes
367 getKnownSchemes() const;
368
373 virtual bool
374 isKnownScheme(const std::string &scheme) const;
375
376
389 virtual bool
390 isValidScheme(const std::string &scheme) const;
391
401 virtual bool
402 isValid() const;
403
404
405 // -----------------
413 virtual std::string
414 asString() const;
415
428 virtual std::string
429 asString(const zypp::url::ViewOptions &opts) const;
430
431
432 // -----------------
437 virtual std::string
438 getScheme() const;
439
440
441 // -----------------
451 virtual std::string
452 getAuthority() const;
453
461 virtual std::string
463
471 virtual std::string
473
486 virtual std::string
487 getHost(EEncoding eflag) const;
488
493 virtual std::string
494 getPort() const;
495
496
497 // -----------------
507 virtual std::string
508 getPathData() const;
509
518 virtual std::string
520
525 virtual std::string
526 getPathParams() const;
527
540 virtual zypp::url::ParamVec
541 getPathParamsVec() const;
542
562 virtual zypp::url::ParamMap
564
581 virtual std::string
582 getPathParam(const std::string &param, EEncoding eflag) const;
583
584
585 // -----------------
595 virtual std::string
596 getQueryString() const;
597
599 virtual std::string
600 getQueryString( const ViewOptions & viewopts_r ) const;
601
615 virtual zypp::url::ParamVec
616 getQueryStringVec() const;
617
636 virtual zypp::url::ParamMap
638
655 virtual std::string
656 getQueryParam(const std::string &param, EEncoding eflag) const;
657
658
659 // -----------------
667 virtual std::string
669
670
671 // -----------------
678 virtual void
679 setScheme(const std::string &scheme);
680
681
682 // -----------------
696 virtual void
697 setAuthority(const std::string &authority);
698
708 virtual void
709 setUsername(const std::string &user,
711
721 virtual void
722 setPassword(const std::string &pass,
724
745 virtual void
746 setHost(const std::string &host);
747
755 virtual void
756 setPort(const std::string &port);
757
758
759 // -----------------
770 virtual void
771 setPathData(const std::string &pathdata);
772
780 virtual void
781 setPathName(const std::string &path,
783
790 virtual void
791 setPathParams(const std::string &params);
792
799 virtual void
801
808 virtual void
810
820 virtual void
821 setPathParam(const std::string &param, const std::string &value);
822
823
824 // -----------------
837 virtual void
838 setQueryString(const std::string &querystr);
839
846 virtual void
848
855 virtual void
857
867 virtual void
868 setQueryParam(const std::string &param, const std::string &value);
869
878 virtual void
879 delQueryParam(const std::string &param);
880
881
882 // -----------------
890 virtual void
891 setFragment(const std::string &fragment,
893
894
895 // -----------------
951 virtual void
952 configure();
953
954
965 std::string
966 config(const std::string &opt) const;
967
977 void
978 config(const std::string &opt, const std::string &val);
979
980
990 getViewOptions() const;
991
1000 void
1001 setViewOptions(const ViewOptions &vopts);
1002
1003 std::string asString1050625() const;
1004 protected:
1031 virtual std::string
1032 cleanupPathName(const std::string &path, bool authority) const;
1033
1044 virtual std::string
1045 cleanupPathName(const std::string &path) const;
1046
1068 virtual bool
1069 isValidHost(const std::string &host) const;
1070
1077 virtual bool
1078 isValidPort(const std::string &port) const;
1079
1080 private:
1082 };
1083
1084
1085 // ---------------------------------------------------------------
1090
1091
1093 } // namespace url
1095
1097} // namespace zypp
1099
1100#endif /* ZYPP_URL_URLBASE_H */
1101/*
1102** vim: set ts=2 sts=2 sw=2 ai et:
1103*/
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Internal data used by UrlBase.
Definition UrlBase.cc:180
Generic Url base class.
Definition UrlBase.h:271
virtual UrlBase * clone() const
Returns pointer to a copy of the current object.
Definition UrlBase.cc:408
virtual void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition UrlBase.cc:971
virtual std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition UrlBase.cc:698
virtual std::string getPort() const
Returns the port number from the URL authority.
Definition UrlBase.cc:755
virtual void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition UrlBase.cc:892
virtual void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition UrlBase.cc:1083
virtual zypp::url::ParamMap getPathParamsMap(EEncoding eflag) const
Returns a string map with path parameter keys and values.
Definition UrlBase.cc:803
virtual zypp::url::ParamVec getPathParamsVec() const
Returns a vector with encoded path parameter substrings.
Definition UrlBase.cc:782
virtual std::string getUsername(EEncoding eflag) const
Returns the username from the URL authority.
Definition UrlBase.cc:722
virtual UrlSchemes getKnownSchemes() const
Returns scheme names known by this object.
Definition UrlBase.cc:416
virtual std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition UrlBase.cc:661
virtual void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition UrlBase.cc:1324
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
Definition UrlBase.cc:368
virtual void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition UrlBase.cc:1245
virtual std::string getFragment(EEncoding eflag) const
Returns the encoded fragment component of the URL.
Definition UrlBase.cc:711
virtual std::string getPathParams() const
Returns the encoded path parameters from the URL.
Definition UrlBase.cc:774
virtual void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition UrlBase.cc:1303
virtual ~UrlBase()
Definition UrlBase.cc:258
UrlBaseData * m_data
Definition UrlBase.h:1081
virtual std::string getPassword(EEncoding eflag) const
Returns the password from the URL authority.
Definition UrlBase.cc:733
virtual std::string getScheme() const
Returns the scheme name of the URL.
Definition UrlBase.cc:653
virtual zypp::url::ParamMap getQueryStringMap(EEncoding eflag) const
Returns a string map with query parameter and their values.
Definition UrlBase.cc:858
virtual void setUsername(const std::string &user, EEncoding eflag)
Set the username in the URL authority.
Definition UrlBase.cc:1015
virtual std::string getPathParam(const std::string &param, EEncoding eflag) const
Return the value for the specified path parameter.
Definition UrlBase.cc:826
virtual void configure()
Configures behaviour of the instance.
Definition UrlBase.cc:315
virtual void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition UrlBase.cc:1258
virtual std::string cleanupPathName(const std::string &path, bool authority) const
Utility method to cleanup an encoded path name.
Definition UrlBase.cc:1351
virtual bool isValidHost(const std::string &host) const
Verifies specified host or IP.
Definition UrlBase.cc:1403
virtual std::string asString() const
Returns a default string representation of the Url object.
Definition UrlBase.cc:505
virtual bool isKnownScheme(const std::string &scheme) const
Returns if scheme name is known to this object.
Definition UrlBase.cc:424
virtual std::string getHost(EEncoding eflag) const
Returns the hostname or IP from the URL authority.
Definition UrlBase.cc:744
virtual void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition UrlBase.cc:946
virtual void setPathName(const std::string &path, EEncoding eflag)
Set the path name.
Definition UrlBase.cc:1168
virtual void setPort(const std::string &port)
Set the port number in the URL authority.
Definition UrlBase.cc:1136
virtual std::string getPathData() const
Returns the encoded path component of the URL.
Definition UrlBase.cc:688
virtual bool isValid() const
Verifies the Url.
Definition UrlBase.cc:473
virtual std::string getPathName(EEncoding eflag) const
Returns the path name from the URL.
Definition UrlBase.cc:763
virtual void setFragment(const std::string &fragment, EEncoding eflag)
Set the fragment string in the URL.
Definition UrlBase.cc:988
virtual void clear()
Clears all data in the object.
Definition UrlBase.cc:396
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
Definition UrlBase.cc:441
virtual zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition UrlBase.cc:837
virtual std::string getQueryParam(const std::string &param, EEncoding eflag) const
Return the value for the specified query parameter.
Definition UrlBase.cc:881
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition UrlBase.cc:388
virtual void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition UrlBase.cc:1290
virtual void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition UrlBase.cc:1333
virtual void setPassword(const std::string &pass, EEncoding eflag)
Set the password in the URL authority.
Definition UrlBase.cc:1049
virtual void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition UrlBase.cc:1280
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
virtual void setPathParams(const std::string &params)
Set the path parameters.
Definition UrlBase.cc:1228
std::string asString1050625() const
Definition UrlBase.cc:510
virtual void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition UrlBase.cc:916
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition UrlBase.cc:380
virtual bool isValidPort(const std::string &port) const
Verifies specified port number.
Definition UrlBase.cc:1432
std::vector< std::string > ParamVec
A parameter vector container.
Definition UrlUtils.h:40
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition UrlUtils.h:47
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition UrlBase.h:251
EEncoding
Encoding flags.
Definition UrlUtils.h:52
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
Url::asString() view options.
Definition UrlBase.h:40
static const ViewOption EMPTY_QUERY_STR ZYPP_API
Explicitely include the query string separator "?".
Definition UrlBase.h:154
static const ViewOption WITH_SCHEME ZYPP_API
Option to include scheme name in the URL string.
Definition UrlBase.h:51
static const ViewOption EMPTY_PATH_PARAMS ZYPP_API
Explicitely include the path parameters separator ";".
Definition UrlBase.h:143
bool has(const ViewOption &o) const
Check if specified option o is set in the current object.
Definition UrlBase.h:228
static const ViewOption DEFAULTS ZYPP_API
Default combination of view options.
Definition UrlBase.h:177
static const ViewOption EMPTY_FRAGMENT ZYPP_API
Explicitely include the fragment string separator "#".
Definition UrlBase.h:165
static const ViewOption WITH_PORT ZYPP_API
Option to include port number in the URL string.
Definition UrlBase.h:81
static const ViewOption WITH_USERNAME ZYPP_API
Option to include username in the URL string.
Definition UrlBase.h:58
static const ViewOption WITH_QUERY_STR ZYPP_API
Option to include query string in the URL string.
Definition UrlBase.h:101
static const ViewOption WITH_PASSWORD ZYPP_API
Option to include password in the URL string.
Definition UrlBase.h:67
static const ViewOption WITH_PATH_PARAMS ZYPP_API
Option to include path parameters in the URL string.
Definition UrlBase.h:95
static const ViewOption hotfix1050625
Definition UrlBase.h:233
static const ViewOption WITH_FRAGMENT ZYPP_API
Option to include fragment string in the URL string.
Definition UrlBase.h:107
static const ViewOption WITH_HOST ZYPP_API
Option to include hostname in the URL string.
Definition UrlBase.h:74
static const ViewOption WITH_PATH_NAME ZYPP_API
Option to include path name in the URL string.
Definition UrlBase.h:87
static const ViewOption EMPTY_AUTHORITY ZYPP_API
Explicitely include the URL authority separator "//".
Definition UrlBase.h:121
static const ViewOption EMPTY_PATH_NAME ZYPP_API
Explicitely include the "/" path character.
Definition UrlBase.h:133