Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <windows.h>
00013 #include <wininet.h>
00014
00015 #include <opc/common/uri_facade.h>
00016 #include <opc/common/exception.h>
00017
00018
00019 namespace Common
00020 {
00021
00022 void Uri::Initialize(const char* uriString, std::size_t size)
00023 {
00024 URL_COMPONENTS url = {0};
00025 url.dwStructSize = sizeof(url);
00026 url.dwSchemeLength = 1;
00027 url.dwUserNameLength = 1;
00028 url.dwPasswordLength = 1;
00029 url.dwHostNameLength = 1;
00030 DWORD options = 0;
00031
00032
00033
00034 if (!InternetCrackUrl(uriString, size, options, &url))
00035 {
00036 THROW_ERROR1(CannotParseUri, uriString);
00037 }
00038
00039
00040 SchemeStr = std::string(url.lpszScheme, url.lpszScheme + url.dwSchemeLength);
00041 UserStr = std::string(url.lpszUserName, url.lpszUserName + url.dwUserNameLength);
00042 PasswordStr = std::string(url.lpszPassword, url.lpszPassword + url.dwPasswordLength);
00043 HostStr = std::string(url.lpszHostName, url.lpszHostName + url.dwHostNameLength);
00044 PortNum = url.nPort;
00045
00046 if (SchemeStr.empty() || HostStr.empty())
00047 {
00048 THROW_ERROR1(CannotParseUri, uriString);
00049 }
00050 }
00051
00052 }
00053
00054