36 std::string::const_iterator first = v.begin();
37 if (!
parse(first, v.end(), *
this) || first != v.end())
38 throw std::invalid_argument(
"invalid URI: \"" + v +
"\"");
40 bool uri::is_null()
const {
43 std::string uri::encoding()
const {
44 std::ostringstream oss;
60 bool uri::parse_literal(std::string::const_iterator& first, std::string::const_iterator last,
const char* v) {
61 std::string::const_iterator f = first;
73 bool parse(std::string::const_iterator& first, std::string::const_iterator last,
uri& v, std::string* errs) {
74 std::string::const_iterator f = first;
79 if (
parse(f, last, tmp.scheme_, &endc) && !endc) {
85 std::string::const_iterator anchor = f;
88 if (!
parse(f, last, tmp.authority_))
93 if(tmp.authority_.port() == 0) {
94 std::string protocol = tmp.scheme().string();
95 tmp.authority_.setDefaultPort(protocol);
98 parse(f, last, tmp.path_, errs ? &e : 0);
102 parse(f, last, tmp.query_, errs ? &e : 0);
107 parse(f, last, tmp.fragment_, errs ? &e : 0);
111 if (errs && !e.empty()) {
114 *errs +=
"URI \"" + std::string(first, f) +
"\": " + e;
friend bool TECOMMONEXPORT parse(std::string::const_iterator &first, std::string::const_iterator last, uri &v, std::string *errs)
Parse URI, returning whether found or not and advancing first and setting URI if found.
const traits AUTHORITY_TRAITS
authority traits
bool empty() const
Test if null/empty.
std::ostream & operator<<(std::ostream &os, const authority &v)
Stream out URI authority.
bool is_null() const
Test if null/empty.
Uniform Resource Identifier (URI) reference.
bool parse(std::string::const_iterator &first, std::string::const_iterator last, authority &v)
Parse URI authority, returning whether found or not and advancing first and setting authority if foun...
bool empty() const
Test if empty and not absolute.
const traits QUERY_TRAITS
query traits
const traits SCHEME_TRAITS
scheme traits
bool is_null() const
Test if null/empty.
const traits FRAGMENT_TRAITS
fragment traits
std::ostream & operator<<(std::ostream &os) const
Stream out encoding.
authority_type authority_