uri_facade_lin_noregex.cpp
Go to the documentation of this file.
1 
11 #include <opc/common/uri_facade.h>
12 
13 #include <opc/common/exception.h>
14 
15 #include <libxml/uri.h>
16 
17 namespace Common
18 {
19 
20 void Uri::Initialize(const std::string& uriString)
21 {
22  xmlURIPtr uri = xmlParseURI(uriString.c_str());
23  if (!uri)
24  {
25  THROW_ERROR1(CannotParseUri, uriString);
26  }
27 
28  if (uri->scheme)
29  {
30  SchemeStr = uri->scheme;
31  }
32 
33  if (uri->user)
34  {
35  UserStr = uri->user;
36  int ix = UserStr.find(':');
37 
38  if (ix > 0)
39  {
40  PasswordStr = UserStr.substr(ix + 1);
41  UserStr = UserStr.substr(0, ix);
42  }
43  }
44 
45  if (uri->server)
46  {
47  HostStr = uri->server;
48  }
49 
50  PortNum = uri->port;
51  xmlFreeURI(uri);
52 
53  if (SchemeStr.empty() || HostStr.empty())
54  {
55  THROW_ERROR1(CannotParseUri, uriString);
56  }
57 }
58 
59 } // namespace Common
Addon interface definition GNU LGPL.
void Initialize(const std::string &uriString)
std::string PasswordStr
Definition: uri_facade.h:57
std::string SchemeStr
Definition: uri_facade.h:55
unsigned PortNum
Definition: uri_facade.h:59
string uri
Definition: client.py:31
std::string UserStr
Definition: uri_facade.h:56
#define THROW_ERROR1(data, param1)
Definition: exception.h:212
std::string HostStr
Definition: uri_facade.h:58
Common::ErrorData CannotParseUri


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08