45 std::string::const_iterator first = v.begin();
46 if (!
parse(first, v.end(), *
this) || first != v.end())
47 throw std::invalid_argument(
"invalid URI authority: \"" + v +
"\"");
52 unsigned short v, i, ii;
53 std::string s, protocol;
56 fp = fopen(
"../../../../src/terralib/common/URI/protocolPorts.txt",
"r");
58 while(fgets(buf, 1000, fp) != (
char*)
null) {
60 if(s.find(
"Port Assignments:") != std::string::npos)
64 while(fgets(buf, 1000, fp) != (
char*)
null)
66 if(buf[0] ==
'#' || buf[0] ==
'\n' || buf[0] ==
' ' || buf[0] ==
'\t')
69 if(s.find(
"/") == std::string::npos)
73 while(!(s[i] ==
' ' || s[i] ==
'\t'))
75 protocol = s.substr(0, i);
76 while(s[i] ==
' ' || s[i] ==
'\t')
81 v = (
unsigned short)atoi(s.substr(ii, i-ii).c_str());
107 std::string::const_iterator it =
login_.begin();
111 if((c >=
'0' && c <=
'9') || (c >=
'a' && c <= 'z') || (c >=
'A' && c <=
'Z'))
127 std::string::const_iterator it =
password_.begin();
131 if((c >=
'0' && c <=
'9') || (c >=
'a' && c <= 'z') || (c >=
'A' && c <=
'Z'))
140 std::ostringstream oss;
145 if(
login_.empty() ==
false)
149 if(
login_.empty() ==
false)
156 bool parse(std::string::const_iterator& first, std::string::const_iterator last,
authority& v) {
158 std::string::const_iterator f = first;
163 if (
parse(f, last, ipaddr))
167 if (
parse(f, last, dn))
174 if (!
parse(f, last, ipv6addr))
182 std::string host(first, f);
183 unsigned int port = 0;
186 std::string::const_iterator anchor = f;
187 for (; f != last; ++f) {
189 if (c <
'0' ||
'9' < c)
192 port = port * 10 + (c -
'0');
202 v.
port_ = (
unsigned short)port;
208 std::string::const_iterator f = first;
209 std::string login, password;
211 while(f != last && *f !=
'/')
217 if(!(f == last || *f ==
'/'))
253 if(login.empty() ==
false)
255 if(password.empty() ==
false)
265 if(*f >=
'0' && *f <=
'9')
267 else if(*f >=
'a' && *f <=
'f')
269 else if(*f >=
'A' && *f <=
'F')
274 if(*f >=
'0' && *f <=
'9')
276 else if(*f >=
'a' && *f <=
'f')
278 else if(*f >=
'A' && *f <=
'F')
290 unsigned char c = *f;
292 sprintf(buf,
"%x", c);
bool parseLoginPassword(std::string::const_iterator &first, std::string::const_iterator last, authority &v)
std::string string() const
Calculate string.
void setDefaultPort(const std::string &scheme)
Set Default port for the protocol. Added by Lauro.
void setLogin(const std::string &login)
Set login. Added by Lauro.
friend bool TECOMMONEXPORT parse(std::string::const_iterator &first, std::string::const_iterator last, authority &v)
Parse URI authority, returning whether found or not and advancing first and setting authority if foun...
Uniform Resource Identifier (URI) reference.
bool parse(std::string::const_iterator &first, std::string::const_iterator last, authority &v)
Parse URI authority, returning whether found or not and advancing first and setting authority if foun...
URI authority component (without userinfo).
#define TE_PROTOCOL_DEFAULT_PORTS_FILE
std::string getLogin() const
Get login. Added by Lauro.
int getDefaultPort(const std::string &scheme)
Get Default port for the protocol. Added by Lauro.
bool encodeAndConcate(std::string::const_iterator &f, std::string &s)
std::string getEncodedLogin() const
Get endoded login. Added by Lauro.
static const char IP_LITERAL_BEGIN_CHAR
IP literal begin ('[')
void setPassword(const std::string &password)
Set password. Added by Lauro.
static std::map< std::string, unsigned short > protocol2DefaultPort_
Protocol to default port. Added by Lauro.
std::string getEncodedPassword() const
Get encoded password. Added by Lauro.
static const char IP_LITERAL_END_CHAR
IP literal end (']')
std::string getPassword() const
Get password. Added by Lauro.
std::ostream & operator<<(std::ostream &os) const
Stream out.
static const char PORT_SEPARATOR_CHAR
port separator (':')
bool decodeAndConcate(std::string::const_iterator &f, std::string &s)