libzypp 17.31.23
Url.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13#include <zypp-core/Url.h>
14#include <zypp-core/Pathname.h>
15#include <zypp-core/base/Gettext.h>
16#include <zypp-core/base/String.h>
17#include <zypp-core/base/Regex.h>
18#include <stdexcept>
19#include <iostream>
20
21
23namespace zypp
24{
25
26
27 using namespace zypp::url;
28
29
30 // -----------------------------------------------------------------
31 /*
32 * url = [scheme:] [//authority] /path [?query] [#fragment]
33 */
34 #define RX_SPLIT_URL "^([^:/?#]+:|)" \
35 "(//[^/?#]*|)" \
36 "([^?#]*)" \
37 "([?][^#]*|)" \
38 "(#.*|)"
39
40
42 namespace
43 {
44
45
46 // ---------------------------------------------------------------
47 class LDAPUrl: public UrlBase
48 {
49 public:
50 LDAPUrl(): UrlBase()
51 {
52 configure();
53 }
54
55 LDAPUrl(const LDAPUrl &url): UrlBase(url)
56 {}
57
58 virtual UrlBase *
59 clone() const
60 {
61 return new LDAPUrl(*this);
62 }
63
64 virtual UrlSchemes
65 getKnownSchemes() const
66 {
67 UrlSchemes schemes(2);
68 schemes[0] = "ldap";
69 schemes[1] = "ldaps";
70 return schemes;
71 }
72
73 virtual void
74 configure()
75 {
76 config("sep_pathparams", "");
77
78 config("psep_querystr", "?");
79 config("vsep_querystr", "");
80
81 // host is required (isValid=>false)
82 // but not mandatory (see RFC 2255),
83 // that is, accept empty host.
84 config("require_host", "y");
85
86 // not allowed here
87 config("rx_username", "");
88 config("rx_password", "");
89 config("rx_fragment", "");
90 config("rx_pathparams", "");
91 }
92
94 getQueryStringMap(zypp::url::EEncoding eflag) const
95 {
96 static const char * const keys[] = {
97 "attrs", "scope", "filter", "exts", NULL
98 };
100 zypp::url::ParamVec pvec( getQueryStringVec());
101 if( pvec.size() <= 4)
102 {
103 for(size_t i=0; i<pvec.size(); i++)
104 {
105 if(eflag == zypp::url::E_ENCODED)
106 pmap[keys[i]] = pvec[i];
107 else
108 pmap[keys[i]] = zypp::url::decode( pvec[i]);
109 }
110 }
111 else
112 {
114 _("Invalid LDAP URL query string")
115 ));
116 }
117 return pmap;
118 }
119
120 virtual void
121 setQueryStringMap(const zypp::url::ParamMap &pmap)
122 {
123 static const char * const keys[] = {
124 "attrs", "scope", "filter", "exts", NULL
125 };
126
127 // remove psep ("?") from safe chars
128 std::string join_safe;
129 std::string safe(config("safe_querystr"));
130 std::string psep(config("psep_querystr"));
131 for(std::string::size_type i=0; i<safe.size(); i++)
132 {
133 if( psep.find(safe[i]) == std::string::npos)
134 join_safe.append(1, safe[i]);
135 }
136
137 zypp::url::ParamVec pvec(4);
138 zypp::url::ParamMap::const_iterator p;
139 for(p=pmap.begin(); p!=pmap.end(); ++p)
140 {
141 bool found=false;
142 for(size_t i=0; i<4; i++)
143 {
144 if(p->first == keys[i])
145 {
146 found=true;
147 pvec[i] = zypp::url::encode(p->second, join_safe);
148 }
149 }
150 if( !found)
151 {
153 str::form(_("Invalid LDAP URL query parameter '%s'"),
154 p->first.c_str())
155 ));
156 }
157 }
158 setQueryStringVec(pvec);
159 }
160 };
161
162
163 // ---------------------------------------------------------------
164 // FIXME: hmm..
165 class UrlByScheme
166 {
167 private:
168 typedef std::map<std::string,UrlRef> UrlBySchemeMap;
169 UrlBySchemeMap urlByScheme;
170
171 public:
172 UrlByScheme()
173 {
174 UrlRef ref;
175
176 // =====================================
177 ref.reset( new LDAPUrl());
178 addUrlByScheme("ldap", ref);
179 addUrlByScheme("ldaps", ref);
180
181
182 // =====================================
183 ref.reset( new UrlBase());
184 // don't show empty authority
187
188 ref->config("with_authority", "n"); // disallow host,...
189 ref->config("require_pathname", "m"); // path is mandatory
190 addUrlByScheme("hd", ref);
191 addUrlByScheme("cd", ref);
192 addUrlByScheme("dvd", ref);
193 addUrlByScheme("dir", ref);
194 addUrlByScheme("iso", ref);
195
196 addUrlByScheme("mailto", ref);
197 addUrlByScheme("urn", ref);
198 addUrlByScheme("plugin", ref); // zypp plugable media handler:
199
200 // RFC1738, 3.10: may contain a host
201 ref->config("with_authority", "y"); // allow host,
202 ref->config("with_port", "n"); // but no port,
203 ref->config("rx_username", ""); // username or
204 ref->config("rx_password", ""); // password ...
205 addUrlByScheme("file", ref);
206
207 // =====================================
208 ref.reset( new UrlBase());
209 ref->config("require_host", "m"); // host is mandatory
210 addUrlByScheme("nfs", ref);
211 addUrlByScheme("nfs4", ref);
212 addUrlByScheme("smb", ref);
213 addUrlByScheme("cifs", ref);
214 addUrlByScheme("http", ref);
215 addUrlByScheme("https", ref);
216 ref->config("path_encode_slash2", "y"); // always encode 2. slash
217 addUrlByScheme("ftp", ref);
218 addUrlByScheme("sftp", ref);
219 addUrlByScheme("tftp", ref);
220 }
221
222 bool
223 addUrlByScheme(const std::string &scheme,
224 UrlRef urlImpl)
225 {
226 if( urlImpl && urlImpl->isValidScheme(scheme))
227 {
228 UrlRef ref(urlImpl);
229 ref->clear();
230 urlByScheme[str::toLower(scheme)] = ref;
231 return true;
232 }
233 return false;
234 }
235
236 UrlRef
237 getUrlByScheme(const std::string &scheme) const
238 {
239 UrlBySchemeMap::const_iterator i(urlByScheme.find(str::toLower(scheme)));
240 if( i != urlByScheme.end())
241 {
242 return i->second;
243 }
244 return UrlRef();
245 }
246
247 bool
248 isRegisteredScheme(const std::string &scheme) const
249 {
250 return urlByScheme.find(str::toLower(scheme)) != urlByScheme.end();
251 }
252
254 getRegisteredSchemes() const
255 {
256 UrlBySchemeMap::const_iterator i(urlByScheme.begin());
257 UrlSchemes schemes;
258
259 schemes.reserve(urlByScheme.size());
260 for( ; i != urlByScheme.end(); ++i)
261 {
262 schemes.push_back(i->first);
263 }
264 return schemes;
265 }
266 };
267
268
269 // ---------------------------------------------------------------
270 UrlByScheme & g_urlSchemeRepository()
271 {
272 static UrlByScheme _v;
273 return _v;
274 }
275
277 } // anonymous namespace
279
280
281 // -----------------------------------------------------------------
283 {
284 }
285
286
287 // -----------------------------------------------------------------
289 : m_impl( new UrlBase())
290 {
291 }
292
293
294 // -----------------------------------------------------------------
295 Url::Url(const Url &url)
296 : m_impl( url.m_impl)
297 {
298 if( !m_impl)
299 {
301 _("Unable to clone Url object")
302 ));
303 }
304 }
305
306
307 // -----------------------------------------------------------------
309 : m_impl( url)
310 {
311 if( !m_impl)
312 {
314 _("Invalid empty Url object reference")
315 ));
316 }
317 }
318
319
320 // -----------------------------------------------------------------
321 Url::Url(const std::string &encodedUrl)
322 : m_impl( parseUrl(encodedUrl))
323 {
324 if( !m_impl)
325 {
327 _("Unable to parse Url components")
328 ));
329 }
330 }
331
332
333 // -----------------------------------------------------------------
334 Url&
335 Url::operator = (const std::string &encodedUrl)
336 {
337 UrlRef url( parseUrl(encodedUrl));
338 if( !url)
339 {
341 _("Unable to parse Url components")
342 ));
343 }
344 m_impl = url;
345 return *this;
346 }
347
348
349 // -----------------------------------------------------------------
350 Url&
352 {
353 m_impl = url.m_impl;
354 return *this;
355 }
356
357
358 // -----------------------------------------------------------------
359 // static
360 bool
361 Url::registerScheme(const std::string &scheme,
362 UrlRef urlImpl)
363 {
364 return g_urlSchemeRepository().addUrlByScheme(scheme, urlImpl);
365 }
366
367
368 // -----------------------------------------------------------------
369 // static
370 UrlRef
371 Url::parseUrl(const std::string &encodedUrl)
372 {
373 UrlRef url;
374 str::smatch out;
375 bool ret = false;
376
377 try
378 {
380 ret = str::regex_match(encodedUrl, out, rex);
381 }
382 catch( ... )
383 {}
384
385 if(ret && out.size() == 6)
386 {
387 std::string scheme = out[1];
388 if (scheme.size() > 1)
389 scheme = scheme.substr(0, scheme.size()-1);
390 std::string authority = out[2];
391 if (authority.size() >= 2)
392 authority = authority.substr(2);
393 std::string query = out[4];
394 if (query.size() > 1)
395 query = query.substr(1);
396 std::string fragment = out[5];
397 if (fragment.size() > 1)
398 fragment = fragment.substr(1);
399
400 url = g_urlSchemeRepository().getUrlByScheme(scheme);
401 if( !url)
402 {
403 url.reset( new UrlBase());
404 }
405 url->init(scheme, authority, out[3],
406 query, fragment);
407 }
408 return url;
409 }
410
411
412 // -----------------------------------------------------------------
413 // static
416 {
417 return g_urlSchemeRepository().getRegisteredSchemes();
418 }
419
420
421 // -----------------------------------------------------------------
422 // static
423 bool
424 Url::isRegisteredScheme(const std::string &scheme)
425 {
426 return g_urlSchemeRepository().isRegisteredScheme(scheme);
427 }
428
429
430 // -----------------------------------------------------------------
433 {
434 return m_impl->getKnownSchemes();
435 }
436
437
438 // -----------------------------------------------------------------
439 bool
440 Url::isValidScheme(const std::string &scheme) const
441 {
442 return m_impl->isValidScheme(scheme);
443 }
444
445
447 namespace
448 {
449 inline bool isInList( const char ** begin_r, const char ** end_r, const std::string & scheme_r )
450 {
451 for ( ; begin_r != end_r; ++begin_r )
452 if ( scheme_r == *begin_r )
453 return true;
454 return false;
455 }
456 }
457 bool Url::schemeIsLocal( const std::string & scheme_r )
458 {
459 static const char * val[] = { "cd", "dvd", "dir", "hd", "iso", "file" };
460 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
461 }
462
463 bool Url::schemeIsRemote( const std::string & scheme_r )
464 {
465 static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp", "tftp" };
466 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
467 }
468
469 bool Url::schemeIsVolatile( const std::string & scheme_r )
470 {
471 static const char * val[] = { "cd", "dvd" };
472 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
473 }
474
475 bool Url::schemeIsDownloading( const std::string & scheme_r )
476 {
477 static const char * val[] = { "http", "https", "ftp", "sftp", "tftp" };
478 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
479 }
480
481 bool Url::schemeIsPlugin( const std::string & scheme_r )
482 {
483 return scheme_r == "plugin";
484 }
486
487 // -----------------------------------------------------------------
488 bool
490 {
491 return m_impl->isValid();
492 }
493
494
495 // -----------------------------------------------------------------
496 std::string
498 {
499 return m_impl->asString();
500 }
501
502
503 // -----------------------------------------------------------------
504 std::string
506 {
507 // make sure, all url components are included;
508 // regardless of the current configuration...
519 return m_impl->asString(opts);
520 }
521
522
523 // -----------------------------------------------------------------
524 std::string
525 Url::asString(const ViewOptions &opts) const
526 {
527 return m_impl->asString(opts);
528 }
529
530
531 // -----------------------------------------------------------------
532 std::string
534 {
535 return m_impl->getScheme();
536 }
537
538
539 // -----------------------------------------------------------------
540 std::string
542 {
543 return m_impl->getAuthority();
544 }
545
546 // -----------------------------------------------------------------
547 std::string
549 {
550 return m_impl->getPathData();
551 }
552
553
554 // -----------------------------------------------------------------
555 std::string
557 {
558 return m_impl->getQueryString();
559 }
560
561
562 // -----------------------------------------------------------------
563 std::string
565 {
566 return m_impl->getFragment(eflag);
567 }
568
569
570 // -----------------------------------------------------------------
571 std::string
573 {
574 return m_impl->getUsername(eflag);
575 }
576
577
578 // -----------------------------------------------------------------
579 std::string
581 {
582 return m_impl->getPassword(eflag);
583 }
584
585
586 // -----------------------------------------------------------------
587 std::string
589 {
590 return m_impl->getHost(eflag);
591 }
592
593
594 // -----------------------------------------------------------------
595 std::string
597 {
598 return m_impl->getPort();
599 }
600
601
602 // -----------------------------------------------------------------
603 std::string
605 {
606 return m_impl->getPathName(eflag);
607 }
608
609
610 // -----------------------------------------------------------------
611 std::string
613 {
614 return m_impl->getPathParams();
615 }
616
617
618 // -----------------------------------------------------------------
621 {
622 return m_impl->getPathParamsVec();
623 }
624
625
626 // -----------------------------------------------------------------
629 {
630 return m_impl->getPathParamsMap(eflag);
631 }
632
633
634 // -----------------------------------------------------------------
635 std::string
636 Url::getPathParam(const std::string &param, EEncoding eflag) const
637 {
638 return m_impl->getPathParam(param, eflag);
639 }
640
641
642 // -----------------------------------------------------------------
645 {
646 return m_impl->getQueryStringVec();
647 }
648
649
650 // -----------------------------------------------------------------
653 {
654 return m_impl->getQueryStringMap(eflag);
655 }
656
657
658 // -----------------------------------------------------------------
659 std::string
660 Url::getQueryParam(const std::string &param, EEncoding eflag) const
661 {
662 return m_impl->getQueryParam(param, eflag);
663 }
664
665
666 // -----------------------------------------------------------------
667 void
668 Url::setScheme(const std::string &scheme)
669 {
670 if(scheme == m_impl->getScheme())
671 {
672 return;
673 }
674 if( m_impl->isKnownScheme(scheme))
675 {
676 m_impl->setScheme(scheme);
677 return;
678 }
679
680 UrlRef url = g_urlSchemeRepository().getUrlByScheme(scheme);
681 if( !url)
682 {
683 url.reset( new UrlBase());
684 }
685 url->init(
686 scheme,
691 );
692 m_impl = url;
693 }
694
695
696 // -----------------------------------------------------------------
697 void
698 Url::setAuthority(const std::string &authority)
699 {
700 m_impl->setAuthority(authority);
701 }
702
703
704 // -----------------------------------------------------------------
705 void
706 Url::setPathData(const std::string &pathdata)
707 {
708 m_impl->setPathData(pathdata);
709 }
710
711
712 // -----------------------------------------------------------------
713 void
714 Url::setQueryString(const std::string &querystr)
715 {
716 m_impl->setQueryString(querystr);
717 }
718
719
720 // -----------------------------------------------------------------
721 void
722 Url::setFragment(const std::string &fragment, EEncoding eflag)
723 {
724 m_impl->setFragment(fragment, eflag);
725 }
726
727
728 // -----------------------------------------------------------------
729 void
730 Url::setUsername(const std::string &user,
731 EEncoding eflag)
732 {
733 m_impl->setUsername(user, eflag);
734 }
735
736
737 // -----------------------------------------------------------------
738 void
739 Url::setPassword(const std::string &pass,
740 EEncoding eflag)
741 {
742 m_impl->setPassword(pass, eflag);
743 }
744
745
746 // -----------------------------------------------------------------
747 void
748 Url::setHost(const std::string &host)
749 {
750 m_impl->setHost(host);
751 }
752
753
754 // -----------------------------------------------------------------
755 void
756 Url::setPort(const std::string &port)
757 {
758 m_impl->setPort(port);
759 }
760
761
762 // -----------------------------------------------------------------
763 void
764 Url::setPathName(const std::string &path,
765 EEncoding eflag)
766 {
767 m_impl->setPathName(path, eflag);
768 }
769
770 void
772 EEncoding eflag)
773 {
774 m_impl->setPathName(path.asString(), eflag);
775 }
776
777 void
778 Url::setPathName(const char *path,
779 EEncoding eflag)
780 {
781 m_impl->setPathName(path, eflag);
782 }
783
784 // -----------------------------------------------------------------
785
786 void Url::appendPathName( const Pathname & path_r, EEncoding eflag_r )
787 { if ( ! path_r.emptyOrRoot() ) setPathName( Pathname(getPathName( eflag_r )) / path_r, eflag_r ); }
788
789 // -----------------------------------------------------------------
790 void
791 Url::setPathParams(const std::string &params)
792 {
793 m_impl->setPathParams(params);
794 }
795
796
797 // -----------------------------------------------------------------
798 void
800 {
802 }
803
804
805 // -----------------------------------------------------------------
806 void
808 {
810 }
811
812
813 // -----------------------------------------------------------------
814 void
815 Url::setPathParam(const std::string &param, const std::string &value)
816 {
817 m_impl->setPathParam(param, value);
818 }
819
820
821 // -----------------------------------------------------------------
822 void
824 {
826 }
827
828
829 // -----------------------------------------------------------------
830 void
832 {
834 }
835
836 // -----------------------------------------------------------------
837 void
838 Url::setQueryParam(const std::string &param, const std::string &value)
839 {
840 m_impl->setQueryParam(param, value);
841 }
842
843 // -----------------------------------------------------------------
844 void
845 Url::delQueryParam(const std::string &param)
846 {
847 m_impl->delQueryParam(param);
848 }
849
850 // -----------------------------------------------------------------
853 {
854 return m_impl->getViewOptions();
855 }
856
857 // -----------------------------------------------------------------
858 void
860 {
861 m_impl->setViewOptions(vopts);
862 }
863
864 // -----------------------------------------------------------------
865 std::ostream & operator<<( std::ostream & str, const Url & url )
866 {
867 return str << url.asString();
868 }
869
870 bool operator<( const Url &lhs, const Url &rhs )
871 {
872 return (lhs.asCompleteString() < rhs.asCompleteString());
873 }
874
875 bool operator==( const Url &lhs, const Url &rhs )
876 {
877 return (lhs.asCompleteString() == rhs.asCompleteString());
878 }
879
880 bool operator!=( const Url &lhs, const Url &rhs )
881 {
882 return (lhs.asCompleteString() != rhs.asCompleteString());
883 }
884
885 namespace hotfix1050625 {
886 std::string asString( const Url & url_r )
887 { return url_r.m_impl->asString1050625(); }
888 }
889
891} // namespace zypp
893/*
894** vim: set ts=2 sts=2 sw=2 ai et:
895*/
#define RX_SPLIT_URL
Definition: Url.cc:34
UrlBySchemeMap urlByScheme
Definition: Url.cc:169
Url manipulation class.
Definition: Url.h:92
bool schemeIsPlugin() const
Definition: Url.h:281
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
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
bool emptyOrRoot() const
Test for "" or "/".
Definition: Pathname.h:121
const std::string & asString() const
String representation.
Definition: Pathname.h:91
Regular expression.
Definition: Regex.h:95
Regular expression match result.
Definition: Regex.h:168
unsigned size() const
Definition: Regex.cc:106
Generic Url base class.
Definition: UrlBase.h:271
virtual void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition: UrlBase.cc:970
virtual std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition: UrlBase.cc:697
virtual std::string getPort() const
Returns the port number from the URL authority.
Definition: UrlBase.cc:754
virtual void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition: UrlBase.cc:891
virtual void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition: UrlBase.cc:1082
virtual zypp::url::ParamMap getPathParamsMap(EEncoding eflag) const
Returns a string map with path parameter keys and values.
Definition: UrlBase.cc:802
virtual zypp::url::ParamVec getPathParamsVec() const
Returns a vector with encoded path parameter substrings.
Definition: UrlBase.cc:781
virtual std::string getUsername(EEncoding eflag) const
Returns the username from the URL authority.
Definition: UrlBase.cc:721
virtual UrlSchemes getKnownSchemes() const
Returns scheme names known by this object.
Definition: UrlBase.cc:415
virtual std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition: UrlBase.cc:660
virtual void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: UrlBase.cc:1323
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
Definition: UrlBase.cc:367
virtual void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition: UrlBase.cc:1244
virtual std::string getFragment(EEncoding eflag) const
Returns the encoded fragment component of the URL.
Definition: UrlBase.cc:710
virtual std::string getPathParams() const
Returns the encoded path parameters from the URL.
Definition: UrlBase.cc:773
virtual void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition: UrlBase.cc:1302
virtual std::string getPassword(EEncoding eflag) const
Returns the password from the URL authority.
Definition: UrlBase.cc:732
virtual std::string getScheme() const
Returns the scheme name of the URL.
Definition: UrlBase.cc:652
virtual zypp::url::ParamMap getQueryStringMap(EEncoding eflag) const
Returns a string map with query parameter and their values.
Definition: UrlBase.cc:857
virtual void setUsername(const std::string &user, EEncoding eflag)
Set the username in the URL authority.
Definition: UrlBase.cc:1014
virtual std::string getPathParam(const std::string &param, EEncoding eflag) const
Return the value for the specified path parameter.
Definition: UrlBase.cc:825
virtual void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition: UrlBase.cc:1257
virtual std::string asString() const
Returns a default string representation of the Url object.
Definition: UrlBase.cc:504
virtual bool isKnownScheme(const std::string &scheme) const
Returns if scheme name is known to this object.
Definition: UrlBase.cc:423
virtual std::string getHost(EEncoding eflag) const
Returns the hostname or IP from the URL authority.
Definition: UrlBase.cc:743
virtual void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition: UrlBase.cc:945
virtual void setPathName(const std::string &path, EEncoding eflag)
Set the path name.
Definition: UrlBase.cc:1167
virtual void setPort(const std::string &port)
Set the port number in the URL authority.
Definition: UrlBase.cc:1135
virtual std::string getPathData() const
Returns the encoded path component of the URL.
Definition: UrlBase.cc:687
virtual bool isValid() const
Verifies the Url.
Definition: UrlBase.cc:472
virtual std::string getPathName(EEncoding eflag) const
Returns the path name from the URL.
Definition: UrlBase.cc:762
virtual void setFragment(const std::string &fragment, EEncoding eflag)
Set the fragment string in the URL.
Definition: UrlBase.cc:987
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
Definition: UrlBase.cc:440
virtual zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition: UrlBase.cc:836
virtual std::string getQueryParam(const std::string &param, EEncoding eflag) const
Return the value for the specified query parameter.
Definition: UrlBase.cc:880
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition: UrlBase.cc:387
virtual void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition: UrlBase.cc:1289
virtual void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition: UrlBase.cc:1332
virtual void setPassword(const std::string &pass, EEncoding eflag)
Set the password in the URL authority.
Definition: UrlBase.cc:1048
virtual void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition: UrlBase.cc:1279
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:294
virtual void setPathParams(const std::string &params)
Set the path parameters.
Definition: UrlBase.cc:1227
std::string asString1050625() const
Definition: UrlBase.cc:509
virtual void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition: UrlBase.cc:915
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition: UrlBase.cc:379
Base class for all URL exceptions.
Definition: UrlException.h:32
Thrown if a feature e.g.
Definition: UrlException.h:125
Thrown if the url or a component can't be parsed at all.
Definition: UrlException.h:68
String related utilities and Regular expression matching.
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition: Regex.h:70
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:177
Url details namespace.
Definition: UrlBase.cc:57
RWCOW_pointer< UrlBase > UrlRef
Copy-On-Write Url reference.
Definition: UrlBase.h:1089
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition: UrlBase.h:251
std::string encode(const std::string &str, const std::string &safe, EEncoding eflag)
Encodes a string using URL percent encoding.
Definition: UrlUtils.cc:32
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_ENCODED
Flag to request encoded string(s).
Definition: UrlUtils.h:53
std::string decode(const std::string &str, bool allowNUL)
Decodes a URL percent encoded string.
Definition: UrlUtils.cc:87
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...
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
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
static const ViewOption WITH_SCHEME
Option to include scheme name in the URL string.
Definition: UrlBase.h:51
static const ViewOption WITH_PORT
Option to include port number in the URL string.
Definition: UrlBase.h:81
static const ViewOption WITH_PASSWORD
Option to include password in the URL string.
Definition: UrlBase.h:67
static const ViewOption WITH_PATH_PARAMS
Option to include path parameters in the URL string.
Definition: UrlBase.h:95
static const ViewOption WITH_FRAGMENT
Option to include fragment string in the URL string.
Definition: UrlBase.h:107
static const ViewOption WITH_PATH_NAME
Option to include path name in the URL string.
Definition: UrlBase.h:87
static const ViewOption EMPTY_AUTHORITY
Explicitely include the URL authority separator "//".
Definition: UrlBase.h:121
static const ViewOption DEFAULTS
Default combination of view options.
Definition: UrlBase.h:177
static const ViewOption WITH_USERNAME
Option to include username in the URL string.
Definition: UrlBase.h:58
static const ViewOption WITH_QUERY_STR
Option to include query string in the URL string.
Definition: UrlBase.h:101
static const ViewOption WITH_HOST
Option to include hostname in the URL string.
Definition: UrlBase.h:74
#define arrayBegin(A)
Simple C-array iterator.
Definition: Easy.h:41
#define arrayEnd(A)
Definition: Easy.h:43
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:428
#define _(MSG)
Definition: Gettext.h:37