UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
httpreadwrite.cpp
Go to the documentation of this file.
1// Copyright (C) 2021+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
2// Redistribution only with this Copyright remark. Last modified: 2024-08-18
9#include <stdexcept>
10
11namespace UPnPsdk {
12
13CUri::CUri(std::string a_url_str) : url_str(a_url_str) {
14 // Exception: no
15 const auto start = this->url_str.find("://");
16 if (start == std::string::npos)
17 throw std::invalid_argument(std::string(
18 (std::string)__FILE__ + ":" + std::to_string(__LINE__) +
19 ", constructor " + __func__ + ". '://' not found in url."));
20
21 // Exception: no
22 const auto end = this->url_str.find_first_of("/", start + 3);
23 if (end == std::string::npos)
24 throw std::invalid_argument(
25 std::string((std::string)__FILE__ + ":" + std::to_string(__LINE__) +
26 ", constructor " + __func__ +
27 ". hostport delimiter '/' not found in url."));
28
29 const auto hostport_size = end - start - 3;
30 if (hostport_size == 0)
31 throw std::invalid_argument(std::string(
32 (std::string)__FILE__ + ":" + std::to_string(__LINE__) +
33 ", constructor " + __func__ + ". 'No hostport found in url."));
34
35 // Exception: std::out_of_range if pos > size()
36 this->hostport = this->url_str.substr(start + 3, hostport_size);
37}
38
39} // namespace UPnPsdk
Declaration of class Uri.
const std::string url_str
URL.
CUri(std::string a_url_str)
Constructor.
std::string hostport
Host with port part from the URL.
Reengineered Object Oriented UPnP+ program code.