Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::detail::url_impl Class Reference
Collaboration diagram for fc::detail::url_impl:

Public Member Functions

void parse (const fc::string &s)
 

Public Attributes

string _proto
 
ostring _host
 
ostring _user
 
ostring _pass
 
opath _path
 
ostring _query
 
ovariant_object _args
 
std::optional< uint16_t_port
 

Detailed Description

Definition at line 12 of file url.cpp.

Member Function Documentation

◆ parse()

void fc::detail::url_impl::parse ( const fc::string & s)
inline

Definition at line 15 of file url.cpp.

16 {
17 std::stringstream ss(s);
18 std::string skip,_lpath,_largs,luser,lpass;
19 std::getline( ss, _proto, ':' );
20 std::getline( ss, skip, '/' );
21 std::getline( ss, skip, '/' );
22
23 if( s.find('@') != size_t(fc::string::npos) ) {
24 fc::string user_pass;
25 std::getline( ss, user_pass, '@' );
26 std::stringstream upss(user_pass);
27 if( user_pass.find( ':' ) != size_t(fc::string::npos) ) {
28 std::getline( upss, luser, ':' );
29 std::getline( upss, lpass, ':' );
30 _user = fc::move(luser);
31 _pass = fc::move(lpass);
32 } else {
33 _user = fc::move(user_pass);
34 }
35 }
36 fc::string host_port;
37 std::getline( ss, host_port, '/' );
38 auto pos = host_port.find( ':' );
39 if( pos != fc::string::npos ) {
40 try {
41 _port = static_cast<uint16_t>(to_uint64( host_port.substr( pos+1 ) ));
42 } catch ( ... ) {
43 FC_THROW_EXCEPTION( parse_error_exception, "Unable to parse port field in url",( "url", s ) );
44 }
45 _host = host_port.substr(0,pos);
46 } else {
47 _host = fc::move(host_port);
48 }
49 std::getline( ss, _lpath, '?' );
50#ifdef WIN32
51 // On windows, a URL like file:///c:/autoexec.bat would result in _lpath = c:/autoexec.bat
52 // which is what we really want (it's already an absolute path)
53 if (!stricmp(_proto.c_str(), "file"))
54 _path = _lpath;
55 else
56 _path = fc::path( "/" ) / _lpath; // let other schemes behave like unix
57#else
58 // On unix, a URL like file:///etc/rc.local would result in _lpath = etc/rc.local
59 // but we really want to make it the absolute path /etc/rc.local
60 _path = fc::path( "/" ) / _lpath;
61#endif
62 std::getline( ss, _largs );
63 if( _args && _args->size() )
64 {
65 // TODO: args = fc::move(_args);
66 _query = fc::move(_largs);
67 }
68 }
std::optional< uint16_t > _port
Definition url.cpp:77
ovariant_object _args
Definition url.cpp:76
wraps boost::filesystem::path to provide platform independent path manipulation.
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
static const Segment ss(Segment::ss)
std::string string
Definition string.hpp:10
uint64_t to_uint64(const fc::string &)
Definition string.cpp:105
unsigned short uint16_t
Definition stdint.h:125
char * s
Here is the call graph for this function:

Member Data Documentation

◆ _args

ovariant_object fc::detail::url_impl::_args

Definition at line 76 of file url.cpp.

◆ _host

ostring fc::detail::url_impl::_host

Definition at line 71 of file url.cpp.

◆ _pass

ostring fc::detail::url_impl::_pass

Definition at line 73 of file url.cpp.

◆ _path

opath fc::detail::url_impl::_path

Definition at line 74 of file url.cpp.

◆ _port

std::optional<uint16_t> fc::detail::url_impl::_port

Definition at line 77 of file url.cpp.

◆ _proto

string fc::detail::url_impl::_proto

Definition at line 70 of file url.cpp.

◆ _query

ostring fc::detail::url_impl::_query

Definition at line 75 of file url.cpp.

◆ _user

ostring fc::detail::url_impl::_user

Definition at line 72 of file url.cpp.


The documentation for this class was generated from the following file: