Skip to content

Commit c462010

Browse files
committed
Fix build
1 parent 70c81ba commit c462010

7 files changed

Lines changed: 28 additions & 42 deletions

File tree

sources/plugins/RfxLanXpl/xplcore/XplMessage.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,11 @@ namespace xplcore
199199
try
200200
{
201201
//we explode the string onto the { char
202-
std::vector<std::string> result;
203202
auto trimRawMessage = boost::trim_copy(rawMessage);
204203
if (trimRawMessage[trimRawMessage.size() - 1] == '\0')
205204
trimRawMessage.erase(trimRawMessage.end() - 1);
206205

207-
boost::split(result, trimRawMessage, boost::is_any_of("{}"), boost::token_compress_on);
208-
206+
std::vector<std::string> result = shared::CStringExtension::splitAnyOfAndCompress(trimRawMessage, "{}");
209207

210208
//we trim each '\n' '\r' at the beggining or the end of each line
211209
//and we suppress empty lines due to previous trim
@@ -255,9 +253,8 @@ namespace xplcore
255253
//Header block parsing
256254

257255
//we explode onto line feed char and also '\r' to be more peaceful
258-
std::vector<std::string> header;
259256
auto trimHeaderBlockIndex = boost::trim_copy(result[headerBlockIndex]);
260-
boost::split(header, trimHeaderBlockIndex, boost::is_any_of("\n\r"), boost::token_compress_on);
257+
std::vector<std::string> header = shared::CStringExtension::splitAnyOfAndCompress(trimHeaderBlockIndex, "\n\r");
261258

262259
//We must have 3 results : hop, source and dest
263260
if (header.size() != 3)
@@ -270,9 +267,8 @@ namespace xplcore
270267
for (auto headerLineIter = header.begin(); headerLineIter != header.end(); ++headerLineIter)
271268
{
272269
auto headerLine = *headerLineIter;
273-
std::vector<std::string> headerLineDecomposed;
274270
auto trimHeaderLine = boost::trim_copy(headerLine);
275-
boost::split(headerLineDecomposed, trimHeaderLine, boost::is_any_of("="), boost::token_compress_on);
271+
std::vector<std::string> headerLineDecomposed = shared::CStringExtension::splitAnyOfAndCompress(trimHeaderLine, "=");
276272

277273
const auto nameIndex = 0;
278274
const auto valueIndex = 1;
@@ -319,16 +315,14 @@ namespace xplcore
319315
msg.setMessageSchemaIdentifier(CXplMessageSchemaIdentifier::parse(result[messageSchemaIndex]));
320316

321317
//Body parsing
322-
std::vector<std::string> body;
323318
auto trimBodyIndex = boost::trim_copy(result[bodyIndex]);
324-
boost::split(body, trimBodyIndex, boost::is_any_of("\n\r"), boost::token_compress_on);
325-
319+
std::vector<std::string> body = shared::CStringExtension::splitAnyOfAndCompress(trimBodyIndex, "\n\r");
320+
326321
for (auto bodyIter = body.begin(); bodyIter != body.end(); ++bodyIter)
327322
{
328323
auto bodyLine = *bodyIter;
329-
std::vector<std::string> bodyLineDecomposed;
330324
auto trimBodyLine = boost::trim_copy(bodyLine);
331-
boost::split(bodyLineDecomposed, trimBodyLine, boost::is_any_of("="), boost::token_compress_on);
325+
std::vector<std::string> bodyLineDecomposed = shared::CStringExtension::splitAnyOfAndCompress(trimBodyLine, "=");
332326

333327
//we must have a couple of name=value -> 2 elements
334328
if (bodyLineDecomposed.size() != 2)

sources/plugins/RfxLanXpl/xplcore/XplMessageFilter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "XplException.h"
55
#include <boost/algorithm/string.hpp>
66

7+
#include "shared/StringExtension.h"
8+
79
// A client send its data as broadcast on the XPL port,
810
// and listen on a certain port, given in its XPL frame.
911

@@ -24,8 +26,7 @@ namespace xplcore
2426
//we allow a single "*" for all filter instead of *.*.*.*.*.*
2527
if (lineString != CXplHelper::WildcardString)
2628
{
27-
std::vector<std::string> line;
28-
boost::split(line, lineString, boost::is_any_of("."), boost::token_compress_on);
29+
std::vector<std::string> line = shared::CStringExtension::splitAnyOfAndCompress(lineString, ".");
2930
if (line.size() != 6)
3031
throw CXplException("The filter string must be formed like : [msgtype].[vendor].[device].[instance].[class].[type] (wildchar * is allowed). Value given : " + filter);
3132

sources/plugins/RfxLanXpl/xplcore/XplMessageSchemaIdentifier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "XplException.h"
55
#include <boost/algorithm/string.hpp>
66

7+
#include "shared/StringExtension.h"
8+
79
namespace xplcore
810
{
911
CXplMessageSchemaIdentifier::CXplMessageSchemaIdentifier()
@@ -64,8 +66,7 @@ namespace xplcore
6466
{
6567
auto lineString = boost::trim_copy(rawMessageSchemaIdentifier);
6668

67-
std::vector<std::string> line;
68-
boost::split(line, lineString, boost::is_any_of("."), boost::token_compress_on);
69+
std::vector<std::string> line = shared::CStringExtension::splitAnyOfAndCompress(lineString, ".");
6970

7071
//We must have 2 results : class Id, type Id
7172
if (line.size() != 2)

sources/plugins/RfxLanXpl/xplrules/Protocol.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ namespace xplrules
3535
//------------------------------------
3636
///\brief Destructor
3737
//------------------------------------
38-
virtual ~CProtocol()
39-
{
40-
}
38+
~CProtocol() override = default;
4139

4240
// IProtocol implementation
4341
boost::shared_ptr<IRule> createRuleInstance(CRuleInstanceManager& instanceManager) override

sources/plugins/RfxLanXpl/xplrules/rfxLanXpl/AcBasic.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,20 @@ namespace xplrules
99
namespace rfxLanXpl
1010
{
1111
DECLARE_ENUM_IMPLEMENTATION_NESTED(CAcBasic::EState, EState,
12-
((Off))
13-
((On))
14-
((Dim))
12+
((Off))
13+
((On))
14+
((Dim))
1515
);
1616

1717
std::string CAcBasic::m_keywordAddress = "address";
1818
std::string CAcBasic::m_keywordUnit = "unit";
1919
std::string CAcBasic::m_keywordCommand = "command";
20-
std::string CAcBasic::m_keywordCommandValues = "{ \"values\" : [\"on\", \"off\", \"preset\"] }";
20+
std::string CAcBasic::m_keywordCommandValues = R"({ "values" : ["on", "off", "preset"] })";
2121
std::string CAcBasic::m_keywordLevel = "level";
2222
xplcore::CXplMessageSchemaIdentifier CAcBasic::m_protocol = xplcore::CXplMessageSchemaIdentifier::parse("ac.basic");
2323

24-
CAcBasic::CAcBasic()
25-
{
26-
}
27-
28-
CAcBasic::~CAcBasic()
29-
{
30-
}
24+
CAcBasic::CAcBasic() = default;
25+
CAcBasic::~CAcBasic() = default;
3126

3227
// IRule implementation
3328
xplcore::CXplMessageSchemaIdentifier CAcBasic::getProtocol()
@@ -39,13 +34,13 @@ namespace xplrules
3934
{
4035
std::string deviceId = msg.getBodyValue(m_keywordAddress) + "-" + msg.getBodyValue(m_keywordUnit);
4136
std::string commercialName("ANSLUT, Chacon, DI.O, KlikAanKlikUit, NEXA, Proove, Intertechno, Düwi, HomeEasy UK/EU");
42-
return CDeviceIdentifier(deviceId, commercialName, m_protocol, m_protocol);
37+
return {deviceId, commercialName, m_protocol, m_protocol};
4338
}
4439

4540
KeywordList CAcBasic::identifyKeywords(xplcore::CXplMessage& msg)
4641
{
4742
KeywordList keywords;
48-
keywords.push_back(boost::make_shared<shared::plugin::yPluginApi::historization::CDimmable>(m_keywordCommand));
43+
keywords.emplace_back(boost::make_shared<shared::plugin::yPluginApi::historization::CDimmable>(m_keywordCommand));
4944
return keywords;
5045
}
5146

@@ -61,6 +56,7 @@ namespace xplrules
6156
EState valFromEquipment(msg.getBodyValue(m_keywordCommand));
6257

6358
auto sw(boost::make_shared<shared::plugin::yPluginApi::historization::CDimmable>(m_keywordCommand));
59+
// ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
6460
switch (valFromEquipment)
6561
{
6662
case EState::kOnValue:
@@ -73,9 +69,9 @@ namespace xplrules
7369
sw->set(boost::lexical_cast<int>(msg.getBodyValue(m_keywordLevel)));
7470
break;
7571
}
76-
data.push_back(sw);
72+
data.emplace_back(sw);
7773
}
78-
catch (...)
74+
catch (...) // NOLINT(bugprone-empty-catch)
7975
{
8076
}
8177

@@ -96,8 +92,7 @@ namespace xplrules
9692

9793
//check the device address is valid
9894
std::string address = commandData->getDevice();
99-
std::vector<std::string> splittedAddress;
100-
boost::split(splittedAddress, address, boost::is_any_of("-"), boost::token_compress_on);
95+
std::vector<std::string> splittedAddress = shared::CStringExtension::splitAnyOfAndCompress(address, "-");
10196

10297
if (splittedAddress.size() != 2)
10398
{
@@ -149,7 +144,7 @@ namespace xplrules
149144
//set the command
150145
auto s = EState::kDim;
151146
newMessage->addToBody(m_keywordCommand, s);
152-
newMessage->addToBody(m_keywordLevel, boost::lexical_cast<std::string>(commandDetails.switchLevel()));
147+
newMessage->addToBody(m_keywordLevel, std::to_string(commandDetails.switchLevel()));
153148
}
154149

155150
return newMessage;
@@ -177,5 +172,3 @@ namespace xplrules
177172
}
178173
} //namespace rfxLanXpl
179174
} //namespace xplrules
180-
181-

sources/plugins/RfxLanXpl/xplrules/rfxLanXpl/AcBasic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace xplrules
1717
{
1818
public:
1919
CAcBasic();
20-
virtual ~CAcBasic();
20+
~CAcBasic() override;
2121

2222
//------------------------------------
2323
///\brief Provide the xpl protocol implemented by this class
@@ -52,7 +52,7 @@ namespace xplrules
5252
((Off))
5353
((On))
5454
((Dim))
55-
) ;
55+
)
5656

5757
private:
5858

sources/shared/shared/StringExtension.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22
#include "exception/Exception.hpp"
33
#include <cstdarg>
4-
#include <Poco/Types.h>
54
#include <ostream>
65
#include <string_view>
76
#include <vector>

0 commit comments

Comments
 (0)