Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit e65c400

Browse files
committed
Merge pull request #361 from dawagner/dead-code-and-factorization
Dead code removal and some factorization
2 parents c3ff042 + e454bf2 commit e65c400

File tree

8 files changed

+20
-51
lines changed

8 files changed

+20
-51
lines changed

parameter/BitParameterType.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,6 @@ uint64_t CBitParameterType::getMask() const
225225
return getMaxEncodableValue() << _bitPos;
226226
}
227227

228-
// Check data has no bit set outside available range
229-
bool CBitParameterType::isEncodable(uint64_t uiData) const
230-
{
231-
size_t uiShift = 8 * sizeof(uiData) - _uiBitSize;
232-
233-
if (uiShift) {
234-
235-
// Check high bits are clean
236-
return !(uiData >> uiShift);
237-
}
238-
239-
return true;
240-
}
241-
242228
// From IXmlSource
243229
void CBitParameterType::toXml(CXmlElement &xmlElement,
244230
CXmlSerializingContext &serializingContext) const

parameter/BitParameterType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class CBitParameterType : public CTypeElement
8686
uint64_t getMaxEncodableValue() const;
8787
// Biwise mask
8888
uint64_t getMask() const;
89-
// Check data has no bit set outside available range
90-
bool isEncodable(uint64_t uiData) const;
9189

9290
// Pos in bits
9391
size_t _bitPos{0};

remote-processor/RemoteCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class IRemoteCommand
4848
* @returns a reference to a vector containing all the arguments.
4949
*/
5050
virtual const std::vector<std::string> &getArguments() const = 0;
51-
virtual const std::string packArguments(size_t startArgument, size_t nbArguments) const = 0;
51+
virtual std::string packArguments(size_t startArgument, size_t nbArguments) const = 0;
5252

5353
protected:
5454
virtual ~IRemoteCommand() {}

remote-processor/RequestMessage.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030
#include "RequestMessage.h"
31+
#include "Utility.h"
3132
#include <assert.h>
3233
#include <algorithm>
3334
#include <ctype.h>
@@ -81,30 +82,12 @@ const string &CRequestMessage::getArgument(size_t argument) const
8182
return _argumentVector[argument];
8283
}
8384

84-
const string CRequestMessage::packArguments(size_t uiStartArgument, size_t uiNbArguments) const
85+
string CRequestMessage::packArguments(size_t uiStartArgument, size_t uiNbArguments) const
8586
{
86-
string strPackedArguments;
87-
8887
assert(uiStartArgument + uiNbArguments <= _argumentVector.size());
8988

90-
// Pack arguments, separating them with a space
91-
bool bFirst = true;
92-
93-
for (size_t argument = uiStartArgument; argument < uiStartArgument + uiNbArguments;
94-
argument++) {
95-
96-
if (!bFirst) {
97-
98-
strPackedArguments += " ";
99-
} else {
100-
101-
bFirst = false;
102-
}
103-
104-
strPackedArguments += _argumentVector[argument];
105-
}
106-
107-
return strPackedArguments;
89+
auto start = begin(_argumentVector) + uiStartArgument;
90+
return utility::asString(std::vector<std::string>(start, start + uiNbArguments), " ");
10891
}
10992

11093
// Fill data to send

remote-processor/RequestMessage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class REMOTE_PROCESSOR_EXPORT CRequestMessage : public CMessage, public IRemoteC
5151
size_t getArgumentCount() const override;
5252
const std::string &getArgument(size_t argument) const override;
5353
const std::vector<std::string> &getArguments() const override;
54-
const std::string packArguments(size_t startArgument, size_t nbArguments) const override;
54+
std::string packArguments(size_t startArgument, size_t nbArguments) const override;
5555

5656
private:
5757
/**

test/functional-tests/include/StoreLogger.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class StoreLogger : public CParameterMgrFullConnector::ILogger
7070

7171
const Logs &getLogs() const { return logs; }
7272

73-
const Logs filter(Log::Level level) const
73+
Logs filter(Log::Level level) const
7474
{
7575
return filter([&level](const Log &log) { return log.level == level; });
7676
};

utility/Utility.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ using std::string;
3939
namespace utility
4040
{
4141

42-
// Format string list
43-
std::string asString(const std::list<std::string> &lstr, const std::string &strSeparator)
44-
{
45-
return join<std::string>(begin(lstr), end(lstr), [strSeparator](string acc, string right) {
46-
return acc + strSeparator + right;
47-
});
48-
}
49-
5042
// Format string map
5143
std::string asString(const std::map<std::string, std::string> &mapStr,
5244
const std::string &strItemSeparator, const std::string &strKeyValueSeparator)

utility/Utility.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <map>
3636
#include <sstream>
3737
#include <numeric>
38+
#include <type_traits>
3839

3940
namespace utility
4041
{
@@ -62,15 +63,24 @@ T join(InputIt first, InputIt last, BinaryOperation op, T empty = T{})
6263
}
6364

6465
/**
65-
* Format the items of a map into a string as a list of key-value pairs. The map must be
66-
* composed of pairs of strings.
66+
* Format the items of a sequence container of strings into a string.
6767
*
68+
* @tparam Sequence the string sequence container (e.g. list or vector)
6869
* @param[in] lstr A list of strings
6970
* @param[in] separator The separator to use between each item
7071
*
7172
* @return the concatenated elements.
7273
*/
73-
std::string asString(const std::list<std::string> &lstr, const std::string &separator = "\n");
74+
template <class Sequence>
75+
std::string asString(const Sequence &lstr, const std::string &separator = "\n")
76+
{
77+
static_assert(std::is_same<typename Sequence::value_type, std::string>::value,
78+
"asString called on a sequence container that does not contains strings");
79+
80+
return join<std::string>(
81+
begin(lstr), end(lstr),
82+
[separator](std::string acc, std::string right) { return acc + separator + right; });
83+
}
7484

7585
/**
7686
* Format the items of a map into a string as a list of key-value pairs. The map must be

0 commit comments

Comments
 (0)