00001 #ifndef uripp_uri_h 00002 #define uripp_uri_h 00003 #include "apidefs.h" 00004 #include "scheme.h" 00005 #include "authority.h" 00006 #include "path.h" 00007 #include "query.h" 00008 #include "fragment.h" 00009 #include "utils.h" 00010 #include <string> 00011 #include <iostream> 00052 00053 namespace uripp { 00099 class URIPP_API uri { 00100 public: 00101 typedef uripp::scheme scheme_type; 00102 typedef uripp::authority authority_type; 00103 typedef uripp::path path_type; 00104 typedef uripp::query query_type; 00105 typedef uripp::fragment fragment_type; 00106 uri(); 00107 00108 00109 uri(const std::string& v); 00110 bool empty() const {return is_null();} 00111 bool is_null() const; 00112 bool relative() const {return scheme_.is_null();} 00113 const scheme_type& scheme() const {return scheme_;} 00114 scheme_type& scheme() {return scheme_;} 00115 const authority_type& authority() const {return authority_;} 00116 authority_type& authority() {return authority_;} 00117 const path_type& path() const {return path_;} 00118 path_type& path() {return path_;} 00119 const query_type& query() const {return query_;} 00120 query_type& query() {return query_;} 00121 const fragment_type& fragment() const {return fragment_;} 00122 fragment_type& fragment() {return fragment_;} 00123 std::string encoding() const; 00124 std::ostream& operator <<(std::ostream& os) const; 00125 private: 00126 friend bool URIPP_API parse(std::string::const_iterator& first, std::string::const_iterator last, uri& v, std::string* errs); 00127 static bool parse_literal(std::string::const_iterator& first, std::string::const_iterator last, const char* v); 00128 scheme_type scheme_; 00129 authority_type authority_; 00130 path_type path_; 00131 query_type query_; 00132 fragment_type fragment_; 00133 }; 00140 bool URIPP_API parse(std::string::const_iterator& first, std::string::const_iterator last, uri& v, std::string* errs = 0); 00142 inline std::ostream& operator <<(std::ostream& os, const uri& v) {return v.operator <<(os);} 00143 } 00144 #endif