14 void parse(
const std::string& s )
16 std::stringstream ss(s);
17 std::string skip,_lpath,_largs,luser,lpass;
22 if( s.find(
'@') !=
size_t(std::string::npos) ) {
23 std::string user_pass;
25 std::stringstream upss(user_pass);
26 if( user_pass.find(
':' ) !=
size_t(std::string::npos) ) {
29 _user = std::move(luser);
30 _pass = std::move(lpass);
32 _user = std::move(user_pass);
35 std::string host_port;
37 auto pos = host_port.find(
':' );
38 if( pos != std::string::npos ) {
40 _port =
static_cast<uint16_t
>(
to_uint64( host_port.substr( pos+1 ) ));
42 FC_THROW_EXCEPTION( parse_error_exception,
"Unable to parse port field in url",(
"url", s ) );
44 _host = host_port.substr(0,pos);
46 _host = std::move(host_port);
52 if (!stricmp(
_proto.c_str(),
"file"))
87 url::operator string()
const
90 ss<<my->_proto<<
"://";
91 if( my->_user.valid() ) {
93 if( my->_pass.valid() ) {
98 if( my->_host.valid() ) ss<<*my->_host;
99 if( my->_port.valid() ) ss<<
":"<<*my->_port;
100 if( my->_path.valid() ) ss<<my->_path->generic_string();
105 :my(
std::make_shared<detail::url_impl>() )
112 static auto u = std::make_shared<detail::url_impl>();
124 :my(
std::move(u.my) )
130 :my(
std::make_shared<detail::url_impl>(*mu.my) )
135 :my(
std::move( mu.my ) )
150 my = std::move(u.my);
157 my = std::make_shared<detail::url_impl>(*u.my);
162 my = std::move(u.my);