MCPcopy Create free account
hub / github.com/Clarionos/clarion / parse

Method parse

libraries/fc/src/network/url.cpp:15–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13 {
14 public:
15 void parse( const fc::string& s )
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.valid() && _args->size() )
64 {
65 // TODO: args = fc::move(_args);
66 _query = fc::move(_largs);
67 }
68 }
69
70 string _proto;
71 ostring _host;

Callers 2

initialize_implMethod · 0.80
urlMethod · 0.80

Calls 6

substrMethod · 0.80
pathClass · 0.50
findMethod · 0.45
c_strMethod · 0.45
validMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected