30 const std::string & extra_net_prefix )
32 G_DEBUG(
"GSmtp::FactoryParser::parse: [" << address <<
"] [" << extra_net_prefix <<
"]" ) ;
33 if( address.find(
"ip:") == 0U || address.find(
"net:") == 0U )
35 return std::make_pair( std::string(
"net") ,
G::Str::tail(address,address.find(
":")) ) ;
37 else if( address.find(extra_net_prefix+
":") == 0U )
39 return std::make_pair( extra_net_prefix ,
G::Str::tail(address,address.find(
":")) ) ;
41 else if( address.find(
"file:") == 0U || address.find(
"exe:") == 0U )
43 return std::make_pair( std::string(
"file") ,
G::Str::tail(address,address.find(
":")) ) ;
45 else if( address.find(
"exit:") == 0U )
47 return std::make_pair( std::string(
"exit") ,
G::Str::tail(address,address.find(
":")) ) ;
49 else if( address.empty() )
51 return std::make_pair( std::string() , std::string() ) ;
55 return std::make_pair( std::string(
"file") , address ) ;
61 std::pair<std::string,std::string> p = parse( address , extra_net_prefix ) ;
62 if( p.first ==
"net" || p.first == extra_net_prefix )
66 return std::string() +
"invalid network address: " + p.second ;
68 return std::string() ;
70 else if( p.first ==
"file" )
74 return "no such file" ;
76 return "probably not executable" ;
78 return "not an absolute path" ;
80 return std::string() ;
82 else if( p.first ==
"exit" )
85 return "not a numeric exit code" ;
87 return std::string() ;
91 return std::string() ;
A structure representing an external program, holding a path and a set of arguments.
static std::string tail(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
static bool executable(const Path &)
Returns true if the path is probably executable.
static bool parse(const std::string &in, std::string &host_or_address, std::string &service_or_port)
Parses a string that contains a hostname or ip address plus a server name or port number...
static std::pair< std::string, std::string > parse(const std::string &address, const std::string &)
Parses an identifier.
static std::string check(const std::string &address, const std::string &)
Parses and checks an identifier.
bool isAbsolute() const
Returns !isRelative().
static bool exists(const Path &file)
Returns true if the file (directory, link, device etc.) exists.
An overload discriminator class for File methods.
static bool isUInt(const std::string &s)
Returns true if the string can be converted into an unsigned integer without throwing an exception...
Path exe() const
Returns the executable.