Commit 1ebb304b7d71a1d0e23a80db7e97356641b085ba

Authored by Jojo-1000
Committed by Moritz Wirger
1 parent e61da3b3

Move function definitions into namespace block to improve readability.

src/BaseHttpHandler.cpp
... ... @@ -24,8 +24,9 @@
24 24  
25 25 #include "hueplusplus/HueExceptionMacro.h"
26 26  
27   -std::string hueplusplus::BaseHttpHandler::sendGetHTTPBody(
28   - const std::string& msg, const std::string& adr, int port) const
  27 +namespace hueplusplus
  28 +{
  29 +std::string BaseHttpHandler::sendGetHTTPBody(const std::string& msg, const std::string& adr, int port) const
29 30 {
30 31 std::string response = send(msg, adr, port);
31 32 size_t start = response.find("\r\n\r\n");
... ... @@ -42,7 +43,7 @@ std::string hueplusplus::BaseHttpHandler::sendGetHTTPBody(
42 43 return response;
43 44 }
44 45  
45   -std::string hueplusplus::BaseHttpHandler::sendHTTPRequest(const std::string& method, const std::string& uri,
  46 +std::string BaseHttpHandler::sendHTTPRequest(const std::string& method, const std::string& uri,
46 47 const std::string& contentType, const std::string& body, const std::string& adr, int port) const
47 48 {
48 49 std::string request;
... ... @@ -69,50 +70,51 @@ std::string hueplusplus::BaseHttpHandler::sendHTTPRequest(const std::string& met
69 70 return sendGetHTTPBody(request.c_str(), adr, port);
70 71 }
71 72  
72   -std::string hueplusplus::BaseHttpHandler::GETString(const std::string& uri, const std::string& contentType,
73   - const std::string& body, const std::string& adr, int port) const
  73 +std::string BaseHttpHandler::GETString(const std::string& uri, const std::string& contentType, const std::string& body,
  74 + const std::string& adr, int port) const
74 75 {
75 76 return sendHTTPRequest("GET", uri, contentType, body, adr, port);
76 77 }
77 78  
78   -std::string hueplusplus::BaseHttpHandler::POSTString(const std::string& uri, const std::string& contentType,
79   - const std::string& body, const std::string& adr, int port) const
  79 +std::string BaseHttpHandler::POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
  80 + const std::string& adr, int port) const
80 81 {
81 82 return sendHTTPRequest("POST", uri, contentType, body, adr, port);
82 83 }
83 84  
84   -std::string hueplusplus::BaseHttpHandler::PUTString(const std::string& uri, const std::string& contentType,
85   - const std::string& body, const std::string& adr, int port) const
  85 +std::string BaseHttpHandler::PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
  86 + const std::string& adr, int port) const
86 87 {
87 88 return sendHTTPRequest("PUT", uri, contentType, body, adr, port);
88 89 }
89 90  
90   -std::string hueplusplus::BaseHttpHandler::DELETEString(const std::string& uri, const std::string& contentType,
  91 +std::string BaseHttpHandler::DELETEString(const std::string& uri, const std::string& contentType,
91 92 const std::string& body, const std::string& adr, int port) const
92 93 {
93 94 return sendHTTPRequest("DELETE", uri, contentType, body, adr, port);
94 95 }
95 96  
96   -nlohmann::json hueplusplus::BaseHttpHandler::GETJson(
  97 +nlohmann::json BaseHttpHandler::GETJson(
97 98 const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
98 99 {
99 100 return nlohmann::json::parse(GETString(uri, "application/json", body.dump(), adr, port));
100 101 }
101 102  
102   -nlohmann::json hueplusplus::BaseHttpHandler::POSTJson(
  103 +nlohmann::json BaseHttpHandler::POSTJson(
103 104 const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
104 105 {
105 106 return nlohmann::json::parse(POSTString(uri, "application/json", body.dump(), adr, port));
106 107 }
107 108  
108   -nlohmann::json hueplusplus::BaseHttpHandler::PUTJson(
  109 +nlohmann::json BaseHttpHandler::PUTJson(
109 110 const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
110 111 {
111 112 return nlohmann::json::parse(PUTString(uri, "application/json", body.dump(), adr, port));
112 113 }
113 114  
114   -nlohmann::json hueplusplus::BaseHttpHandler::DELETEJson(
  115 +nlohmann::json BaseHttpHandler::DELETEJson(
115 116 const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
116 117 {
117 118 return nlohmann::json::parse(DELETEString(uri, "application/json", body.dump(), adr, port));
118 119 }
  120 +} // namespace hueplusplus
... ...
src/ExtendedColorHueStrategy.cpp
... ... @@ -28,7 +28,9 @@
28 28  
29 29 #include "hueplusplus/HueConfig.h"
30 30  
31   -bool hueplusplus::ExtendedColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
  31 +namespace hueplusplus
  32 +{
  33 +bool ExtendedColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
32 34 {
33 35 light.refreshState();
34 36 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -110,7 +112,7 @@ bool hueplusplus::ExtendedColorHueStrategy::alertHueSaturation(uint16_t hue, uin
110 112 }
111 113 }
112 114  
113   -bool hueplusplus::ExtendedColorHueStrategy::alertXY(float x, float y, HueLight& light) const
  115 +bool ExtendedColorHueStrategy::alertXY(float x, float y, HueLight& light) const
114 116 {
115 117 light.refreshState();
116 118 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -192,7 +194,7 @@ bool hueplusplus::ExtendedColorHueStrategy::alertXY(float x, float y, HueLight&amp;
192 194 }
193 195 }
194 196  
195   -bool hueplusplus::ExtendedColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
  197 +bool ExtendedColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
196 198 {
197 199 light.refreshState();
198 200 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -273,3 +275,4 @@ bool hueplusplus::ExtendedColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8
273 275 return false;
274 276 }
275 277 }
  278 +} // namespace hueplusplus
... ...
src/ExtendedColorTemperatureStrategy.cpp
... ... @@ -30,7 +30,9 @@
30 30 #include "hueplusplus/HueExceptionMacro.h"
31 31 #include "hueplusplus/Utils.h"
32 32  
33   -bool hueplusplus::ExtendedColorTemperatureStrategy::setColorTemperature(
  33 +namespace hueplusplus
  34 +{
  35 +bool ExtendedColorTemperatureStrategy::setColorTemperature(
34 36 unsigned int mired, uint8_t transition, HueLight& light) const
35 37 {
36 38 light.refreshState();
... ... @@ -68,7 +70,7 @@ bool hueplusplus::ExtendedColorTemperatureStrategy::setColorTemperature(
68 70 return utils::validateReplyForLight(request, reply, light.id);
69 71 }
70 72  
71   -bool hueplusplus::ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
  73 +bool ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
72 74 {
73 75 light.refreshState();
74 76 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -149,3 +151,4 @@ bool hueplusplus::ExtendedColorTemperatureStrategy::alertTemperature(unsigned in
149 151 return false;
150 152 }
151 153 }
  154 +} // namespace hueplusplus
... ...
src/Hue.cpp
... ... @@ -41,9 +41,11 @@
41 41 #include "hueplusplus/UPnP.h"
42 42 #include "hueplusplus/Utils.h"
43 43  
44   -hueplusplus::HueFinder::HueFinder(std::shared_ptr<const IHttpHandler> handler) : http_handler(std::move(handler)) {}
  44 +namespace hueplusplus
  45 +{
  46 +HueFinder::HueFinder(std::shared_ptr<const IHttpHandler> handler) : http_handler(std::move(handler)) {}
45 47  
46   -std::vector<hueplusplus::HueFinder::HueIdentification> hueplusplus::HueFinder::FindBridges() const
  48 +std::vector<HueFinder::HueIdentification> HueFinder::FindBridges() const
47 49 {
48 50 UPnP uplug;
49 51 std::vector<std::pair<std::string, std::string>> foundDevices = uplug.getDevices(http_handler);
... ... @@ -71,7 +73,7 @@ std::vector&lt;hueplusplus::HueFinder::HueIdentification&gt; hueplusplus::HueFinder::F
71 73 return foundBridges;
72 74 }
73 75  
74   -hueplusplus::Hue hueplusplus::HueFinder::GetBridge(const HueIdentification& identification)
  76 +Hue HueFinder::GetBridge(const HueIdentification& identification)
75 77 {
76 78 std::string normalizedMac = NormalizeMac(identification.mac);
77 79 auto pos = usernames.find(normalizedMac);
... ... @@ -91,17 +93,17 @@ hueplusplus::Hue hueplusplus::HueFinder::GetBridge(const HueIdentification&amp; iden
91 93 return bridge;
92 94 }
93 95  
94   -void hueplusplus::HueFinder::AddUsername(const std::string& mac, const std::string& username)
  96 +void HueFinder::AddUsername(const std::string& mac, const std::string& username)
95 97 {
96 98 usernames[NormalizeMac(mac)] = username;
97 99 }
98 100  
99   -const std::map<std::string, std::string>& hueplusplus::HueFinder::GetAllUsernames() const
  101 +const std::map<std::string, std::string>& HueFinder::GetAllUsernames() const
100 102 {
101 103 return usernames;
102 104 }
103 105  
104   -std::string hueplusplus::HueFinder::NormalizeMac(std::string input)
  106 +std::string HueFinder::NormalizeMac(std::string input)
105 107 {
106 108 // Remove any non alphanumeric characters (e.g. ':' and whitespace)
107 109 input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }),
... ... @@ -111,7 +113,7 @@ std::string hueplusplus::HueFinder::NormalizeMac(std::string input)
111 113 return input;
112 114 }
113 115  
114   -std::string hueplusplus::HueFinder::ParseDescription(const std::string& description)
  116 +std::string HueFinder::ParseDescription(const std::string& description)
115 117 {
116 118 const char* model = "<modelName>Philips hue bridge";
117 119 const char* serialBegin = "<serialNumber>";
... ... @@ -133,7 +135,7 @@ std::string hueplusplus::HueFinder::ParseDescription(const std::string&amp; descript
133 135 return std::string();
134 136 }
135 137  
136   -hueplusplus::Hue::Hue(
  138 +Hue::Hue(
137 139 const std::string& ip, const int port, const std::string& username, std::shared_ptr<const IHttpHandler> handler)
138 140 : ip(ip),
139 141 port(port),
... ... @@ -147,17 +149,17 @@ hueplusplus::Hue::Hue(
147 149 commands(ip, port, username, http_handler)
148 150 {}
149 151  
150   -std::string hueplusplus::Hue::getBridgeIP()
  152 +std::string Hue::getBridgeIP()
151 153 {
152 154 return ip;
153 155 }
154 156  
155   -int hueplusplus::Hue::getBridgePort()
  157 +int Hue::getBridgePort()
156 158 {
157 159 return port;
158 160 }
159 161  
160   -std::string hueplusplus::Hue::requestUsername()
  162 +std::string Hue::requestUsername()
161 163 {
162 164 std::cout << "Please press the link Button! You've got 35 secs!\n"; // when the link
163 165 // button was
... ... @@ -206,22 +208,22 @@ std::string hueplusplus::Hue::requestUsername()
206 208 return username;
207 209 }
208 210  
209   -std::string hueplusplus::Hue::getUsername()
  211 +std::string Hue::getUsername()
210 212 {
211 213 return username;
212 214 }
213 215  
214   -void hueplusplus::Hue::setIP(const std::string& ip)
  216 +void Hue::setIP(const std::string& ip)
215 217 {
216 218 this->ip = ip;
217 219 }
218 220  
219   -void hueplusplus::Hue::setPort(const int port)
  221 +void Hue::setPort(const int port)
220 222 {
221 223 this->port = port;
222 224 }
223 225  
224   -hueplusplus::HueLight& hueplusplus::Hue::getLight(int id)
  226 +HueLight& Hue::getLight(int id)
225 227 {
226 228 auto pos = lights.find(id);
227 229 if (pos != lights.end())
... ... @@ -244,7 +246,7 @@ hueplusplus::HueLight&amp; hueplusplus::Hue::getLight(int id)
244 246 return lights.find(id)->second;
245 247 }
246 248  
247   -bool hueplusplus::Hue::removeLight(int id)
  249 +bool Hue::removeLight(int id)
248 250 {
249 251 nlohmann::json result
250 252 = commands.DELETERequest("/lights/" + std::to_string(id), nlohmann::json::object(), CURRENT_FILE_INFO);
... ... @@ -256,7 +258,7 @@ bool hueplusplus::Hue::removeLight(int id)
256 258 return success;
257 259 }
258 260  
259   -std::vector<std::reference_wrapper<hueplusplus::HueLight>> hueplusplus::Hue::getAllLights()
  261 +std::vector<std::reference_wrapper<HueLight>> Hue::getAllLights()
260 262 {
261 263 refreshState();
262 264 nlohmann::json lightsState = state["lights"];
... ... @@ -272,7 +274,7 @@ std::vector&lt;std::reference_wrapper&lt;hueplusplus::HueLight&gt;&gt; hueplusplus::Hue::get
272 274 return result;
273 275 }
274 276  
275   -bool hueplusplus::Hue::lightExists(int id)
  277 +bool Hue::lightExists(int id)
276 278 {
277 279 refreshState();
278 280 auto pos = lights.find(id);
... ... @@ -287,7 +289,7 @@ bool hueplusplus::Hue::lightExists(int id)
287 289 return false;
288 290 }
289 291  
290   -bool hueplusplus::Hue::lightExists(int id) const
  292 +bool Hue::lightExists(int id) const
291 293 {
292 294 auto pos = lights.find(id);
293 295 if (pos != lights.end())
... ... @@ -301,7 +303,7 @@ bool hueplusplus::Hue::lightExists(int id) const
301 303 return false;
302 304 }
303 305  
304   -std::string hueplusplus::Hue::getPictureOfLight(int id) const
  306 +std::string Hue::getPictureOfLight(int id) const
305 307 {
306 308 std::string ret = "";
307 309 auto pos = lights.find(id);
... ... @@ -312,7 +314,7 @@ std::string hueplusplus::Hue::getPictureOfLight(int id) const
312 314 return ret;
313 315 }
314 316  
315   -std::string hueplusplus::Hue::getPictureOfModel(const std::string& model_id) const
  317 +std::string Hue::getPictureOfModel(const std::string& model_id) const
316 318 {
317 319 std::string ret = "";
318 320 if (model_id == "LCT001" || model_id == "LCT007" || model_id == "LCT010" || model_id == "LCT014"
... ... @@ -436,7 +438,7 @@ std::string hueplusplus::Hue::getPictureOfModel(const std::string&amp; model_id) con
436 438 return ret;
437 439 }
438 440  
439   -void hueplusplus::Hue::refreshState()
  441 +void Hue::refreshState()
440 442 {
441 443 if (username.empty())
442 444 {
... ... @@ -454,3 +456,4 @@ void hueplusplus::Hue::refreshState()
454 456 << answer.dump() << std::endl;
455 457 }
456 458 }
  459 +} // namespace hueplusplus
... ...
src/HueCommandAPI.cpp
... ... @@ -26,7 +26,9 @@
26 26  
27 27 #include "hueplusplus/HueExceptionMacro.h"
28 28  
29   -constexpr std::chrono::steady_clock::duration hueplusplus::HueCommandAPI::minDelay;
  29 +namespace hueplusplus
  30 +{
  31 +constexpr std::chrono::steady_clock::duration HueCommandAPI::minDelay;
30 32  
31 33 namespace
32 34 {
... ... @@ -62,7 +64,7 @@ nlohmann::json RunWithTimeout(std::shared_ptr&lt;Timeout&gt; timeout, std::chrono::ste
62 64 }
63 65 } // namespace
64 66  
65   -hueplusplus::HueCommandAPI::HueCommandAPI(
  67 +HueCommandAPI::HueCommandAPI(
66 68 const std::string& ip, const int port, const std::string& username, std::shared_ptr<const IHttpHandler> httpHandler)
67 69 : ip(ip),
68 70 port(port),
... ... @@ -71,43 +73,43 @@ hueplusplus::HueCommandAPI::HueCommandAPI(
71 73 timeout(new TimeoutData{std::chrono::steady_clock::now(), {}})
72 74 {}
73 75  
74   -nlohmann::json hueplusplus::HueCommandAPI::PUTRequest(const std::string& path, const nlohmann::json& request) const
  76 +nlohmann::json HueCommandAPI::PUTRequest(const std::string& path, const nlohmann::json& request) const
75 77 {
76 78 return PUTRequest(path, request, CURRENT_FILE_INFO);
77 79 }
78 80  
79   -nlohmann::json hueplusplus::HueCommandAPI::PUTRequest(
  81 +nlohmann::json HueCommandAPI::PUTRequest(
80 82 const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
81 83 {
82 84 return HandleError(fileInfo,
83 85 RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->PUTJson(CombinedPath(path), request, ip); }));
84 86 }
85 87  
86   -nlohmann::json hueplusplus::HueCommandAPI::GETRequest(const std::string& path, const nlohmann::json& request) const
  88 +nlohmann::json HueCommandAPI::GETRequest(const std::string& path, const nlohmann::json& request) const
87 89 {
88 90 return GETRequest(path, request, CURRENT_FILE_INFO);
89 91 }
90 92  
91   -nlohmann::json hueplusplus::HueCommandAPI::GETRequest(
  93 +nlohmann::json HueCommandAPI::GETRequest(
92 94 const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
93 95 {
94 96 return HandleError(fileInfo,
95 97 RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->GETJson(CombinedPath(path), request, ip); }));
96 98 }
97 99  
98   -nlohmann::json hueplusplus::HueCommandAPI::DELETERequest(const std::string& path, const nlohmann::json& request) const
  100 +nlohmann::json HueCommandAPI::DELETERequest(const std::string& path, const nlohmann::json& request) const
99 101 {
100 102 return DELETERequest(path, request, CURRENT_FILE_INFO);
101 103 }
102 104  
103   -nlohmann::json hueplusplus::HueCommandAPI::DELETERequest(
  105 +nlohmann::json HueCommandAPI::DELETERequest(
104 106 const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
105 107 {
106 108 return HandleError(fileInfo,
107 109 RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->DELETEJson(CombinedPath(path), request, ip); }));
108 110 }
109 111  
110   -nlohmann::json hueplusplus::HueCommandAPI::HandleError(FileInfo fileInfo, const nlohmann::json& response) const
  112 +nlohmann::json HueCommandAPI::HandleError(FileInfo fileInfo, const nlohmann::json& response) const
111 113 {
112 114 if (response.count("error"))
113 115 {
... ... @@ -120,7 +122,7 @@ nlohmann::json hueplusplus::HueCommandAPI::HandleError(FileInfo fileInfo, const
120 122 return response;
121 123 }
122 124  
123   -std::string hueplusplus::HueCommandAPI::CombinedPath(const std::string& path) const
  125 +std::string HueCommandAPI::CombinedPath(const std::string& path) const
124 126 {
125 127 std::string result = "/api/";
126 128 result.append(username);
... ... @@ -132,3 +134,4 @@ std::string hueplusplus::HueCommandAPI::CombinedPath(const std::string&amp; path) co
132 134 result.append(path);
133 135 return result;
134 136 }
  137 +} // namespace hueplusplus
... ...
src/HueDeviceTypes.cpp
... ... @@ -26,6 +26,8 @@
26 26  
27 27 #include "hueplusplus/HueExceptionMacro.h"
28 28  
  29 +namespace hueplusplus
  30 +{
29 31 namespace
30 32 {
31 33 const std::set<std::string> getGamutBTypes()
... ... @@ -66,7 +68,7 @@ const std::set&lt;std::string&gt; getTemperatureLightTypes()
66 68 }
67 69 } // namespace
68 70  
69   -auto hueplusplus::MakeHueLight::operator()(std::string type, int id, HueCommandAPI commands,
  71 +auto MakeHueLight::operator()(std::string type, int id, HueCommandAPI commands,
70 72 std::shared_ptr<BrightnessStrategy> simpleBrightnessStrategy,
71 73 std::shared_ptr<ColorTemperatureStrategy> extendedColorTemperatureStrategy,
72 74 std::shared_ptr<ColorTemperatureStrategy> simpleColorTemperatureStrategy,
... ... @@ -112,3 +114,4 @@ auto hueplusplus::MakeHueLight::operator()(std::string type, int id, HueCommandA
112 114 std::cerr << "Could not determine HueLight type:" << type << "!\n";
113 115 throw HueException(CURRENT_FILE_INFO, "Could not determine HueLight type!");
114 116 }
  117 +} // namespace hueplusplus
... ...
src/HueException.cpp
... ... @@ -22,21 +22,23 @@
22 22  
23 23 #include "hueplusplus/HueException.h"
24 24  
25   -hueplusplus::HueException::HueException(FileInfo fileInfo, const std::string& message)
  25 +namespace hueplusplus
  26 +{
  27 +HueException::HueException(FileInfo fileInfo, const std::string& message)
26 28 : HueException("HueException", std::move(fileInfo), message)
27 29 {}
28 30  
29   -const char* hueplusplus::HueException::what() const noexcept
  31 +const char* HueException::what() const noexcept
30 32 {
31 33 return whatMessage.c_str();
32 34 }
33 35  
34   -const hueplusplus::FileInfo& hueplusplus::HueException::GetFile() const noexcept
  36 +const FileInfo& HueException::GetFile() const noexcept
35 37 {
36 38 return fileInfo;
37 39 }
38 40  
39   -hueplusplus::HueException::HueException(const char* exceptionName, FileInfo fileInfo, const std::string& message)
  41 +HueException::HueException(const char* exceptionName, FileInfo fileInfo, const std::string& message)
40 42 : fileInfo(std::move(fileInfo))
41 43 {
42 44 whatMessage = exceptionName;
... ... @@ -46,7 +48,7 @@ hueplusplus::HueException::HueException(const char* exceptionName, FileInfo file
46 48 whatMessage.append(message);
47 49 }
48 50  
49   -hueplusplus::HueAPIResponseException::HueAPIResponseException(
  51 +HueAPIResponseException::HueAPIResponseException(
50 52 FileInfo fileInfo, int error, std::string address, std::string description)
51 53 : HueException("HueApiResponseException", std::move(fileInfo), GetMessage(error, address, description)),
52 54 error(error),
... ... @@ -54,23 +56,22 @@ hueplusplus::HueAPIResponseException::HueAPIResponseException(
54 56 description(std::move(description))
55 57 {}
56 58  
57   -int hueplusplus::HueAPIResponseException::GetErrorNumber() const noexcept
  59 +int HueAPIResponseException::GetErrorNumber() const noexcept
58 60 {
59 61 return error;
60 62 }
61 63  
62   -const std::string& hueplusplus::HueAPIResponseException::GetAddress() const noexcept
  64 +const std::string& HueAPIResponseException::GetAddress() const noexcept
63 65 {
64 66 return address;
65 67 }
66 68  
67   -const std::string& hueplusplus::HueAPIResponseException::GetDescription() const noexcept
  69 +const std::string& HueAPIResponseException::GetDescription() const noexcept
68 70 {
69 71 return description;
70 72 }
71 73  
72   -hueplusplus::HueAPIResponseException hueplusplus::HueAPIResponseException::Create(
73   - FileInfo fileInfo, const nlohmann::json& response)
  74 +HueAPIResponseException HueAPIResponseException::Create(FileInfo fileInfo, const nlohmann::json& response)
74 75 {
75 76 const nlohmann::json error = response.at("error");
76 77 int errorCode = error.value("type", -1);
... ... @@ -79,8 +80,7 @@ hueplusplus::HueAPIResponseException hueplusplus::HueAPIResponseException::Creat
79 80 return HueAPIResponseException(std::move(fileInfo), errorCode, std::move(address), std::move(description));
80 81 }
81 82  
82   -std::string hueplusplus::HueAPIResponseException::GetMessage(
83   - int error, const std::string& addr, const std::string& description)
  83 +std::string HueAPIResponseException::GetMessage(int error, const std::string& addr, const std::string& description)
84 84 {
85 85 std::string result = std::to_string(error);
86 86 result.append(" ");
... ... @@ -90,7 +90,7 @@ std::string hueplusplus::HueAPIResponseException::GetMessage(
90 90 return result;
91 91 }
92 92  
93   -std::string hueplusplus::FileInfo::ToString() const
  93 +std::string FileInfo::ToString() const
94 94 {
95 95 if (filename.empty() || line < 0)
96 96 {
... ... @@ -103,3 +103,4 @@ std::string hueplusplus::FileInfo::ToString() const
103 103 result.append(std::to_string(line));
104 104 return result;
105 105 }
  106 +} // namespace hueplusplus
... ...
src/HueLight.cpp
... ... @@ -30,56 +30,58 @@
30 30 #include "hueplusplus/Utils.h"
31 31 #include "json/json.hpp"
32 32  
33   -bool hueplusplus::HueLight::On(uint8_t transition)
  33 +namespace hueplusplus
  34 +{
  35 +bool HueLight::On(uint8_t transition)
34 36 {
35 37 refreshState();
36 38 return OnNoRefresh(transition);
37 39 }
38 40  
39   -bool hueplusplus::HueLight::Off(uint8_t transition)
  41 +bool HueLight::Off(uint8_t transition)
40 42 {
41 43 refreshState();
42 44 return OffNoRefresh(transition);
43 45 }
44 46  
45   -bool hueplusplus::HueLight::isOn()
  47 +bool HueLight::isOn()
46 48 {
47 49 refreshState();
48 50 return state["state"]["on"].get<bool>();
49 51 }
50 52  
51   -bool hueplusplus::HueLight::isOn() const
  53 +bool HueLight::isOn() const
52 54 {
53 55 return state["state"]["on"].get<bool>();
54 56 }
55 57  
56   -int hueplusplus::HueLight::getId() const
  58 +int HueLight::getId() const
57 59 {
58 60 return id;
59 61 }
60 62  
61   -std::string hueplusplus::HueLight::getType() const
  63 +std::string HueLight::getType() const
62 64 {
63 65 return state["type"].get<std::string>();
64 66 }
65 67  
66   -std::string hueplusplus::HueLight::getName()
  68 +std::string HueLight::getName()
67 69 {
68 70 refreshState();
69 71 return state["name"].get<std::string>();
70 72 }
71 73  
72   -std::string hueplusplus::HueLight::getName() const
  74 +std::string HueLight::getName() const
73 75 {
74 76 return state["name"].get<std::string>();
75 77 }
76 78  
77   -std::string hueplusplus::HueLight::getModelId() const
  79 +std::string HueLight::getModelId() const
78 80 {
79 81 return state["modelid"].get<std::string>();
80 82 }
81 83  
82   -std::string hueplusplus::HueLight::getUId() const
  84 +std::string HueLight::getUId() const
83 85 {
84 86 if (state.count("uniqueid"))
85 87 {
... ... @@ -88,7 +90,7 @@ std::string hueplusplus::HueLight::getUId() const
88 90 return std::string();
89 91 }
90 92  
91   -std::string hueplusplus::HueLight::getManufacturername() const
  93 +std::string HueLight::getManufacturername() const
92 94 {
93 95 if (state.count("manufacturername"))
94 96 {
... ... @@ -97,7 +99,7 @@ std::string hueplusplus::HueLight::getManufacturername() const
97 99 return std::string();
98 100 }
99 101  
100   -std::string hueplusplus::HueLight::getProductname() const
  102 +std::string HueLight::getProductname() const
101 103 {
102 104 if (state.count("productname"))
103 105 {
... ... @@ -106,7 +108,7 @@ std::string hueplusplus::HueLight::getProductname() const
106 108 return std::string();
107 109 }
108 110  
109   -std::string hueplusplus::HueLight::getLuminaireUId() const
  111 +std::string HueLight::getLuminaireUId() const
110 112 {
111 113 if (state.count("luminaireuniqueid"))
112 114 {
... ... @@ -115,18 +117,18 @@ std::string hueplusplus::HueLight::getLuminaireUId() const
115 117 return std::string();
116 118 }
117 119  
118   -std::string hueplusplus::HueLight::getSwVersion()
  120 +std::string HueLight::getSwVersion()
119 121 {
120 122 refreshState();
121 123 return state["swversion"].get<std::string>();
122 124 }
123 125  
124   -std::string hueplusplus::HueLight::getSwVersion() const
  126 +std::string HueLight::getSwVersion() const
125 127 {
126 128 return state["swversion"].get<std::string>();
127 129 }
128 130  
129   -bool hueplusplus::HueLight::setName(const std::string& name)
  131 +bool HueLight::setName(const std::string& name)
130 132 {
131 133 nlohmann::json request = nlohmann::json::object();
132 134 request["name"] = name;
... ... @@ -136,22 +138,22 @@ bool hueplusplus::HueLight::setName(const std::string&amp; name)
136 138 return utils::safeGetMember(reply, 0, "success", "/lights/" + std::to_string(id) + "/name") == name;
137 139 }
138 140  
139   -hueplusplus::ColorType hueplusplus::HueLight::getColorType() const
  141 +ColorType HueLight::getColorType() const
140 142 {
141 143 return colorType;
142 144 }
143 145  
144   -unsigned int hueplusplus::HueLight::KelvinToMired(unsigned int kelvin) const
  146 +unsigned int HueLight::KelvinToMired(unsigned int kelvin) const
145 147 {
146 148 return int(0.5f + (1000000 / kelvin));
147 149 }
148 150  
149   -unsigned int hueplusplus::HueLight::MiredToKelvin(unsigned int mired) const
  151 +unsigned int HueLight::MiredToKelvin(unsigned int mired) const
150 152 {
151 153 return int(0.5f + (1000000 / mired));
152 154 }
153 155  
154   -bool hueplusplus::HueLight::alert()
  156 +bool HueLight::alert()
155 157 {
156 158 nlohmann::json request;
157 159 request["alert"] = "select";
... ... @@ -161,12 +163,9 @@ bool hueplusplus::HueLight::alert()
161 163 return utils::validateReplyForLight(request, reply, id);
162 164 }
163 165  
164   -hueplusplus::HueLight::HueLight(int id, const HueCommandAPI& commands)
165   - : HueLight(id, commands, nullptr, nullptr, nullptr)
166   -{}
  166 +HueLight::HueLight(int id, const HueCommandAPI& commands) : HueLight(id, commands, nullptr, nullptr, nullptr) {}
167 167  
168   -hueplusplus::HueLight::HueLight(int id, const HueCommandAPI& commands,
169   - std::shared_ptr<const BrightnessStrategy> brightnessStrategy,
  168 +HueLight::HueLight(int id, const HueCommandAPI& commands, std::shared_ptr<const BrightnessStrategy> brightnessStrategy,
170 169 std::shared_ptr<const ColorTemperatureStrategy> colorTempStrategy,
171 170 std::shared_ptr<const ColorHueStrategy> colorHueStrategy)
172 171 : id(id),
... ... @@ -179,7 +178,7 @@ hueplusplus::HueLight::HueLight(int id, const HueCommandAPI&amp; commands,
179 178 refreshState();
180 179 }
181 180  
182   -bool hueplusplus::HueLight::OnNoRefresh(uint8_t transition)
  181 +bool HueLight::OnNoRefresh(uint8_t transition)
183 182 {
184 183 nlohmann::json request = nlohmann::json::object();
185 184 if (transition != 4)
... ... @@ -203,7 +202,7 @@ bool hueplusplus::HueLight::OnNoRefresh(uint8_t transition)
203 202 return utils::validateReplyForLight(request, reply, id);
204 203 }
205 204  
206   -bool hueplusplus::HueLight::OffNoRefresh(uint8_t transition)
  205 +bool HueLight::OffNoRefresh(uint8_t transition)
207 206 {
208 207 nlohmann::json request = nlohmann::json::object();
209 208 if (transition != 4)
... ... @@ -227,13 +226,12 @@ bool hueplusplus::HueLight::OffNoRefresh(uint8_t transition)
227 226 return utils::validateReplyForLight(request, reply, id);
228 227 }
229 228  
230   -nlohmann::json hueplusplus::HueLight::SendPutRequest(
231   - const nlohmann::json& request, const std::string& subPath, FileInfo fileInfo)
  229 +nlohmann::json HueLight::SendPutRequest(const nlohmann::json& request, const std::string& subPath, FileInfo fileInfo)
232 230 {
233 231 return commands.PUTRequest("/lights/" + std::to_string(id) + subPath, request, std::move(fileInfo));
234 232 }
235 233  
236   -void hueplusplus::HueLight::refreshState()
  234 +void HueLight::refreshState()
237 235 {
238 236 // std::chrono::steady_clock::time_point start =
239 237 // std::chrono::steady_clock::now(); std::cout << "\tRefreshing lampstate of
... ... @@ -254,3 +252,4 @@ void hueplusplus::HueLight::refreshState()
254 252 // std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now()
255 253 // - start).count() << "ms" << std::endl;
256 254 }
  255 +} // namespace hueplusplus
... ...
src/LinHttpHandler.cpp
... ... @@ -38,6 +38,8 @@
38 38 #include <sys/socket.h> // socket, connect
39 39 #include <unistd.h> // read, write, close
40 40  
  41 +namespace hueplusplus
  42 +{
41 43 class SocketCloser
42 44 {
43 45 public:
... ... @@ -48,7 +50,7 @@ private:
48 50 int s;
49 51 };
50 52  
51   -std::string hueplusplus::LinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
  53 +std::string LinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
52 54 {
53 55 // create socket
54 56 int socketFD = socket(AF_INET, SOCK_STREAM, 0);
... ... @@ -136,7 +138,7 @@ std::string hueplusplus::LinHttpHandler::send(const std::string&amp; msg, const std:
136 138 return response;
137 139 }
138 140  
139   -std::vector<std::string> hueplusplus::LinHttpHandler::sendMulticast(
  141 +std::vector<std::string> LinHttpHandler::sendMulticast(
140 142 const std::string& msg, const std::string& adr, int port, int timeout) const
141 143 {
142 144 hostent* server; // host information
... ... @@ -221,3 +223,4 @@ std::vector&lt;std::string&gt; hueplusplus::LinHttpHandler::sendMulticast(
221 223 }
222 224 return returnString;
223 225 }
  226 +} // namespace hueplusplus
... ...
src/SimpleBrightnessStrategy.cpp
... ... @@ -29,7 +29,9 @@
29 29 #include "hueplusplus/HueExceptionMacro.h"
30 30 #include "hueplusplus/Utils.h"
31 31  
32   -bool hueplusplus::SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const
  32 +namespace hueplusplus
  33 +{
  34 +bool SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const
33 35 {
34 36 light.refreshState();
35 37 if (bri == 0)
... ... @@ -76,13 +78,14 @@ bool hueplusplus::SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint
76 78 }
77 79 }
78 80  
79   -unsigned int hueplusplus::SimpleBrightnessStrategy::getBrightness(HueLight& light) const
  81 +unsigned int SimpleBrightnessStrategy::getBrightness(HueLight& light) const
80 82 {
81 83 light.refreshState();
82 84 return light.state["state"]["bri"].get<unsigned int>();
83 85 }
84 86  
85   -unsigned int hueplusplus::SimpleBrightnessStrategy::getBrightness(const HueLight& light) const
  87 +unsigned int SimpleBrightnessStrategy::getBrightness(const HueLight& light) const
86 88 {
87 89 return light.state["state"]["bri"].get<unsigned int>();
88 90 }
  91 +} // namespace hueplusplus
... ...
src/SimpleColorHueStrategy.cpp
... ... @@ -30,7 +30,9 @@
30 30 #include "hueplusplus/HueExceptionMacro.h"
31 31 #include "hueplusplus/Utils.h"
32 32  
33   -bool hueplusplus::SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const
  33 +namespace hueplusplus
  34 +{
  35 +bool SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const
34 36 {
35 37 light.refreshState();
36 38 nlohmann::json request = nlohmann::json::object();
... ... @@ -60,7 +62,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t tran
60 62 return utils::validateReplyForLight(request, reply, light.id);
61 63 }
62 64  
63   -bool hueplusplus::SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const
  65 +bool SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const
64 66 {
65 67 light.refreshState();
66 68 nlohmann::json request = nlohmann::json::object();
... ... @@ -93,8 +95,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_
93 95 return utils::validateReplyForLight(request, reply, light.id);
94 96 }
95 97  
96   -bool hueplusplus::SimpleColorHueStrategy::setColorHueSaturation(
97   - uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const
  98 +bool SimpleColorHueStrategy::setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const
98 99 {
99 100 light.refreshState();
100 101 nlohmann::json request = nlohmann::json::object();
... ... @@ -133,7 +134,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorHueSaturation(
133 134 return utils::validateReplyForLight(request, reply, light.id);
134 135 }
135 136  
136   -bool hueplusplus::SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t transition, HueLight& light) const
  137 +bool SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t transition, HueLight& light) const
137 138 {
138 139 light.refreshState();
139 140 nlohmann::json request = nlohmann::json::object();
... ... @@ -166,8 +167,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t t
166 167 return utils::validateReplyForLight(request, reply, light.id);
167 168 }
168 169  
169   -bool hueplusplus::SimpleColorHueStrategy::setColorRGB(
170   - uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const
  170 +bool SimpleColorHueStrategy::setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const
171 171 {
172 172 if ((r == 0) && (g == 0) && (b == 0))
173 173 {
... ... @@ -193,7 +193,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorRGB(
193 193 return light.setColorXY(x, y, transition);
194 194 }
195 195  
196   -bool hueplusplus::SimpleColorHueStrategy::setColorLoop(bool on, HueLight& light) const
  196 +bool SimpleColorHueStrategy::setColorLoop(bool on, HueLight& light) const
197 197 {
198 198 // colorloop
199 199 light.refreshState();
... ... @@ -220,7 +220,7 @@ bool hueplusplus::SimpleColorHueStrategy::setColorLoop(bool on, HueLight&amp; light)
220 220 return utils::validateReplyForLight(request, reply, light.id);
221 221 }
222 222  
223   -bool hueplusplus::SimpleColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
  223 +bool SimpleColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
224 224 {
225 225 light.refreshState();
226 226 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -279,7 +279,7 @@ bool hueplusplus::SimpleColorHueStrategy::alertHueSaturation(uint16_t hue, uint8
279 279 }
280 280 }
281 281  
282   -bool hueplusplus::SimpleColorHueStrategy::alertXY(float x, float y, HueLight& light) const
  282 +bool SimpleColorHueStrategy::alertXY(float x, float y, HueLight& light) const
283 283 {
284 284 light.refreshState();
285 285 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -338,7 +338,7 @@ bool hueplusplus::SimpleColorHueStrategy::alertXY(float x, float y, HueLight&amp; li
338 338 }
339 339 }
340 340  
341   -bool hueplusplus::SimpleColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
  341 +bool SimpleColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
342 342 {
343 343 light.refreshState();
344 344 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -397,24 +397,24 @@ bool hueplusplus::SimpleColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t
397 397 }
398 398 }
399 399  
400   -std::pair<uint16_t, uint8_t> hueplusplus::SimpleColorHueStrategy::getColorHueSaturation(HueLight& light) const
  400 +std::pair<uint16_t, uint8_t> SimpleColorHueStrategy::getColorHueSaturation(HueLight& light) const
401 401 {
402 402 light.refreshState();
403 403 return std::make_pair(light.state["state"]["hue"].get<uint16_t>(), light.state["state"]["sat"].get<uint8_t>());
404 404 }
405 405  
406   -std::pair<uint16_t, uint8_t> hueplusplus::SimpleColorHueStrategy::getColorHueSaturation(const HueLight& light) const
  406 +std::pair<uint16_t, uint8_t> SimpleColorHueStrategy::getColorHueSaturation(const HueLight& light) const
407 407 {
408 408 return std::make_pair(light.state["state"]["hue"].get<uint16_t>(), light.state["state"]["sat"].get<uint8_t>());
409 409 }
410 410  
411   -std::pair<float, float> hueplusplus::SimpleColorHueStrategy::getColorXY(HueLight& light) const
  411 +std::pair<float, float> SimpleColorHueStrategy::getColorXY(HueLight& light) const
412 412 {
413 413 light.refreshState();
414 414 return std::make_pair(light.state["state"]["xy"][0].get<float>(), light.state["state"]["xy"][1].get<float>());
415 415 }
416 416  
417   -std::pair<float, float> hueplusplus::SimpleColorHueStrategy::getColorXY(const HueLight& light) const
  417 +std::pair<float, float> SimpleColorHueStrategy::getColorXY(const HueLight& light) const
418 418 {
419 419 return std::make_pair(light.state["state"]["xy"][0].get<float>(), light.state["state"]["xy"][1].get<float>());
420 420 }
... ... @@ -428,3 +428,4 @@ float t = (x0 * y1 - y0 * x1 + (y0 - y1) * pointx + (x1 - x0) * pointy) * sign;
428 428  
429 429 return s > 0 && t > 0 && (s + t) < A * sign;
430 430 }*/
  431 +} // namespace hueplusplus
... ...
src/SimpleColorTemperatureStrategy.cpp
... ... @@ -30,8 +30,9 @@
30 30 #include "hueplusplus/HueExceptionMacro.h"
31 31 #include "hueplusplus/Utils.h"
32 32  
33   -bool hueplusplus::SimpleColorTemperatureStrategy::setColorTemperature(
34   - unsigned int mired, uint8_t transition, HueLight& light) const
  33 +namespace hueplusplus
  34 +{
  35 +bool SimpleColorTemperatureStrategy::setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const
35 36 {
36 37 light.refreshState();
37 38 nlohmann::json request = nlohmann::json::object();
... ... @@ -68,7 +69,7 @@ bool hueplusplus::SimpleColorTemperatureStrategy::setColorTemperature(
68 69 return utils::validateReplyForLight(request, reply, light.id);
69 70 }
70 71  
71   -bool hueplusplus::SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
  72 +bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
72 73 {
73 74 light.refreshState();
74 75 std::string cType = light.state["state"]["colormode"].get<std::string>();
... ... @@ -102,13 +103,14 @@ bool hueplusplus::SimpleColorTemperatureStrategy::alertTemperature(unsigned int
102 103 }
103 104 }
104 105  
105   -unsigned int hueplusplus::SimpleColorTemperatureStrategy::getColorTemperature(HueLight& light) const
  106 +unsigned int SimpleColorTemperatureStrategy::getColorTemperature(HueLight& light) const
106 107 {
107 108 light.refreshState();
108 109 return light.state["state"]["ct"].get<unsigned int>();
109 110 }
110 111  
111   -unsigned int hueplusplus::SimpleColorTemperatureStrategy::getColorTemperature(const HueLight& light) const
  112 +unsigned int SimpleColorTemperatureStrategy::getColorTemperature(const HueLight& light) const
112 113 {
113 114 return light.state["state"]["ct"].get<unsigned int>();
114 115 }
  116 +} // namespace hueplusplus
... ...
src/UPnP.cpp
... ... @@ -25,8 +25,9 @@
25 25 #include <algorithm>
26 26 #include <iostream>
27 27  
28   -std::vector<std::pair<std::string, std::string>> hueplusplus::UPnP::getDevices(
29   - std::shared_ptr<const IHttpHandler> handler)
  28 +namespace hueplusplus
  29 +{
  30 +std::vector<std::pair<std::string, std::string>> UPnP::getDevices(std::shared_ptr<const IHttpHandler> handler)
30 31 {
31 32 // send UPnP M-Search request
32 33 std::vector<std::string> foundDevices
... ... @@ -56,3 +57,4 @@ std::vector&lt;std::pair&lt;std::string, std::string&gt;&gt; hueplusplus::UPnP::getDevices(
56 57 }
57 58 return devices;
58 59 }
  60 +} // namespace hueplusplus
... ...
src/Utils.cpp
... ... @@ -24,7 +24,11 @@
24 24  
25 25 #include <iostream>
26 26  
27   -bool hueplusplus::utils::validateReplyForLight(const nlohmann::json& request, const nlohmann::json& reply, int lightId)
  27 +namespace hueplusplus
  28 +{
  29 +namespace utils
  30 +{
  31 +bool validateReplyForLight(const nlohmann::json& request, const nlohmann::json& reply, int lightId)
28 32 {
29 33 bool success = false;
30 34 std::string path = "/lights/" + std::to_string(lightId) + "/state/";
... ... @@ -75,4 +79,6 @@ bool hueplusplus::utils::validateReplyForLight(const nlohmann::json&amp; request, co
75 79 }
76 80 }
77 81 return success;
78   -}
79 82 \ No newline at end of file
  83 +}
  84 +} // namespace utils
  85 +} // namespace hueplusplus
... ...
src/WinHttpHandler.cpp
... ... @@ -32,6 +32,8 @@
32 32  
33 33 #pragma comment(lib, "Ws2_32.lib")
34 34  
  35 +namespace hueplusplus
  36 +{
35 37 namespace
36 38 {
37 39 class AddrInfoFreer
... ... @@ -54,7 +56,7 @@ private:
54 56 };
55 57 } // namespace
56 58  
57   -hueplusplus::WinHttpHandler::WinHttpHandler()
  59 +WinHttpHandler::WinHttpHandler()
58 60 {
59 61 // Initialize Winsock
60 62 int return_code = WSAStartup(MAKEWORD(2, 2), &wsaData);
... ... @@ -65,12 +67,12 @@ hueplusplus::WinHttpHandler::WinHttpHandler()
65 67 }
66 68 }
67 69  
68   -hueplusplus::WinHttpHandler::~WinHttpHandler()
  70 +WinHttpHandler::~WinHttpHandler()
69 71 {
70 72 WSACleanup();
71 73 }
72 74  
73   -std::string hueplusplus::WinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
  75 +std::string WinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
74 76 {
75 77 struct addrinfo hints = {};
76 78 hints.ai_family = AF_INET;
... ... @@ -171,7 +173,7 @@ std::string hueplusplus::WinHttpHandler::send(const std::string&amp; msg, const std:
171 173 return response;
172 174 }
173 175  
174   -std::vector<std::string> hueplusplus::WinHttpHandler::sendMulticast(
  176 +std::vector<std::string> WinHttpHandler::sendMulticast(
175 177 const std::string& msg, const std::string& adr, int port, int timeout) const
176 178 {
177 179 struct addrinfo hints = {};
... ... @@ -296,3 +298,4 @@ std::vector&lt;std::string&gt; hueplusplus::WinHttpHandler::sendMulticast(
296 298  
297 299 return returnString;
298 300 }
  301 +} // namespace hueplusplus
... ...