diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp index c4deaf43e..14421f125 100644 --- a/parameter/BitParameterType.cpp +++ b/parameter/BitParameterType.cpp @@ -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 diff --git a/parameter/BitParameterType.h b/parameter/BitParameterType.h index bf6955573..a6745c849 100644 --- a/parameter/BitParameterType.h +++ b/parameter/BitParameterType.h @@ -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}; diff --git a/remote-processor/RemoteCommand.h b/remote-processor/RemoteCommand.h index 025a133bd..75602064d 100644 --- a/remote-processor/RemoteCommand.h +++ b/remote-processor/RemoteCommand.h @@ -48,7 +48,7 @@ class IRemoteCommand * @returns a reference to a vector containing all the arguments. */ virtual const std::vector &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() {} diff --git a/remote-processor/RequestMessage.cpp b/remote-processor/RequestMessage.cpp index 0eb1e858f..0c32438c6 100644 --- a/remote-processor/RequestMessage.cpp +++ b/remote-processor/RequestMessage.cpp @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "RequestMessage.h" +#include "Utility.h" #include #include #include @@ -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(start, start + uiNbArguments), " "); } // Fill data to send diff --git a/remote-processor/RequestMessage.h b/remote-processor/RequestMessage.h index 6c9dfcba3..57c0be0ec 100644 --- a/remote-processor/RequestMessage.h +++ b/remote-processor/RequestMessage.h @@ -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 &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: /** diff --git a/test/functional-tests/include/StoreLogger.hpp b/test/functional-tests/include/StoreLogger.hpp index 55fcc81cd..1943a991c 100644 --- a/test/functional-tests/include/StoreLogger.hpp +++ b/test/functional-tests/include/StoreLogger.hpp @@ -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; }); }; diff --git a/utility/Utility.cpp b/utility/Utility.cpp index bf944229c..8b476e3c1 100644 --- a/utility/Utility.cpp +++ b/utility/Utility.cpp @@ -39,14 +39,6 @@ using std::string; namespace utility { -// Format string list -std::string asString(const std::list &lstr, const std::string &strSeparator) -{ - return join(begin(lstr), end(lstr), [strSeparator](string acc, string right) { - return acc + strSeparator + right; - }); -} - // Format string map std::string asString(const std::map &mapStr, const std::string &strItemSeparator, const std::string &strKeyValueSeparator) diff --git a/utility/Utility.h b/utility/Utility.h index 8a3d5b74f..0f2aec321 100644 --- a/utility/Utility.h +++ b/utility/Utility.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace utility { @@ -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 &lstr, const std::string &separator = "\n"); +template +std::string asString(const Sequence &lstr, const std::string &separator = "\n") +{ + static_assert(std::is_same::value, + "asString called on a sequence container that does not contains strings"); + + return join( + 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