uri_facade_win.cpp
Go to the documentation of this file.
1 
11 
12 #include <windows.h>
13 #include <wininet.h>
14 
15 #include <opc/common/uri_facade.h>
16 #include <opc/common/exception.h>
17 
18 
19 namespace Common
20 {
21 
22 void Uri::Initialize(const char * uriString, std::size_t size)
23 {
24  URL_COMPONENTS url = {0};
25  url.dwStructSize = sizeof(url);
26  url.dwSchemeLength = 1;
27  url.dwUserNameLength = 1;
28  url.dwPasswordLength = 1;
29  url.dwHostNameLength = 1;
30  DWORD options = 0;
31 
32  // TODO msdn says do not use this function in services and in server patforms. :(
33  // TODO http://msdn.microsoft.com/en-us/library/windows/desktop/aa384376(v=vs.85).aspx
34  if (!InternetCrackUrl(uriString, size, options, &url))
35  {
36  THROW_ERROR1(CannotParseUri, uriString);
37  }
38 
39 
40  SchemeStr = std::string(url.lpszScheme, url.lpszScheme + url.dwSchemeLength);
41  UserStr = std::string(url.lpszUserName, url.lpszUserName + url.dwUserNameLength);
42  PasswordStr = std::string(url.lpszPassword, url.lpszPassword + url.dwPasswordLength);
43  HostStr = std::string(url.lpszHostName, url.lpszHostName + url.dwHostNameLength);
44  PortNum = url.nPort;
45 
46  if (SchemeStr.empty() || HostStr.empty())
47  {
48  THROW_ERROR1(CannotParseUri, uriString);
49  }
50 }
51 
52 } // namespace Common
53 
54 
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
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
url
Definition: setup.py:46
Common::ErrorData CannotParseUri


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