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);
fc::istream & getline(fc::istream &, std::string &, char delim='\n')
fc::optional< uint16_t > port() const
url & operator=(const url &c)
void to_variant(const flat_set< T, A... > &var, variant &vo, uint32_t _max_depth)
ovariant_object args() const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
uint64_t to_uint64(const std::string &)
Defines exception's used by fc.
std::shared_ptr< detail::url_impl > get_null_url()
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
fc::optional< uint16_t > _port
wraps boost::filesystem::path to provide platform independent path manipulation.
void parse(const std::string &s)
std::string as_string() const