Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions parameter/BitParameterType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,6 @@ uint64_t CBitParameterType::getMask() const
return getMaxEncodableValue() << _bitPos;
}

// Check data has no bit set outside available range
bool CBitParameterType::isEncodable(uint64_t uiData) const
{
size_t uiShift = 8 * sizeof(uiData) - _uiBitSize;

if (uiShift) {

// Check high bits are clean
return !(uiData >> uiShift);
}

return true;
}

// From IXmlSource
void CBitParameterType::toXml(CXmlElement &xmlElement,
CXmlSerializingContext &serializingContext) const
Expand Down
2 changes: 0 additions & 2 deletions parameter/BitParameterType.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class CBitParameterType : public CTypeElement
uint64_t getMaxEncodableValue() const;
// Biwise mask
uint64_t getMask() const;
// Check data has no bit set outside available range
bool isEncodable(uint64_t uiData) const;

// Pos in bits
size_t _bitPos{0};
Expand Down
2 changes: 1 addition & 1 deletion remote-processor/RemoteCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IRemoteCommand
* @returns a reference to a vector containing all the arguments.
*/
virtual const std::vector<std::string> &getArguments() const = 0;
virtual const std::string packArguments(size_t startArgument, size_t nbArguments) const = 0;
virtual std::string packArguments(size_t startArgument, size_t nbArguments) const = 0;

protected:
virtual ~IRemoteCommand() {}
Expand Down
25 changes: 4 additions & 21 deletions remote-processor/RequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "RequestMessage.h"
#include "Utility.h"
#include <assert.h>
#include <algorithm>
#include <ctype.h>
Expand Down Expand Up @@ -81,30 +82,12 @@ const string &CRequestMessage::getArgument(size_t argument) const
return _argumentVector[argument];
}

const string CRequestMessage::packArguments(size_t uiStartArgument, size_t uiNbArguments) const
string CRequestMessage::packArguments(size_t uiStartArgument, size_t uiNbArguments) const
{
string strPackedArguments;

assert(uiStartArgument + uiNbArguments <= _argumentVector.size());

// Pack arguments, separating them with a space
bool bFirst = true;

for (size_t argument = uiStartArgument; argument < uiStartArgument + uiNbArguments;
argument++) {

if (!bFirst) {

strPackedArguments += " ";
} else {

bFirst = false;
}

strPackedArguments += _argumentVector[argument];
}

return strPackedArguments;
auto start = begin(_argumentVector) + uiStartArgument;
return utility::asString(std::vector<std::string>(start, start + uiNbArguments), " ");
}

// Fill data to send
Expand Down
2 changes: 1 addition & 1 deletion remote-processor/RequestMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class REMOTE_PROCESSOR_EXPORT CRequestMessage : public CMessage, public IRemoteC
size_t getArgumentCount() const override;
const std::string &getArgument(size_t argument) const override;
const std::vector<std::string> &getArguments() const override;
const std::string packArguments(size_t startArgument, size_t nbArguments) const override;
std::string packArguments(size_t startArgument, size_t nbArguments) const override;

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion test/functional-tests/include/StoreLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class StoreLogger : public CParameterMgrFullConnector::ILogger

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

const Logs filter(Log::Level level) const
Logs filter(Log::Level level) const
{
return filter([&level](const Log &log) { return log.level == level; });
};
Expand Down
8 changes: 0 additions & 8 deletions utility/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ using std::string;
namespace utility
{

// Format string list
std::string asString(const std::list<std::string> &lstr, const std::string &strSeparator)
{
return join<std::string>(begin(lstr), end(lstr), [strSeparator](string acc, string right) {
return acc + strSeparator + right;
});
}

// Format string map
std::string asString(const std::map<std::string, std::string> &mapStr,
const std::string &strItemSeparator, const std::string &strKeyValueSeparator)
Expand Down
16 changes: 13 additions & 3 deletions utility/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <map>
#include <sstream>
#include <numeric>
#include <type_traits>

namespace utility
{
Expand Down Expand Up @@ -62,15 +63,24 @@ T join(InputIt first, InputIt last, BinaryOperation op, T empty = T{})
}

/**
* Format the items of a map into a string as a list of key-value pairs. The map must be
* composed of pairs of strings.
* Format the items of a sequence container of strings into a string.
*
* @tparam Sequence the string sequence container (e.g. list or vector)
* @param[in] lstr A list of strings
* @param[in] separator The separator to use between each item
*
* @return the concatenated elements.
*/
std::string asString(const std::list<std::string> &lstr, const std::string &separator = "\n");
template <class Sequence>
std::string asString(const Sequence &lstr, const std::string &separator = "\n")
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_assert(std::equal<lstr::element_type, std::string>::value, "Provided output containor container can not contain string.")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

static_assert(std::is_same<typename Sequence::value_type, std::string>::value,
"asString called on a sequence container that does not contains strings");

return join<std::string>(
begin(lstr), end(lstr),
[separator](std::string acc, std::string right) { return acc + separator + right; });
}

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