summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parameter/ParameterBlackboard.cpp8
-rw-r--r--parameter/ParameterBlackboard.h5
-rw-r--r--parameter/StringParameter.cpp12
3 files changed, 9 insertions, 16 deletions
diff --git a/parameter/ParameterBlackboard.cpp b/parameter/ParameterBlackboard.cpp
index 3af9a1d..6001c77 100644
--- a/parameter/ParameterBlackboard.cpp
+++ b/parameter/ParameterBlackboard.cpp
@@ -99,14 +99,14 @@ void CParameterBlackboard::readInteger(void* pvDstData, uint32_t uiSize, uint32_
}
}
-void CParameterBlackboard::writeString(const char* pcSrcData, uint32_t uiOffset)
+void CParameterBlackboard::writeString(const std::string &input, uint32_t uiOffset)
{
- strcpy((char*)_pucData + uiOffset, pcSrcData);
+ strcpy((char*)_pucData + uiOffset, input.c_str());
}
-void CParameterBlackboard::readString(char* pcDstData, uint32_t uiOffset) const
+void CParameterBlackboard::readString(std::string &output, uint32_t uiOffset) const
{
- strcpy(pcDstData, (const char*)_pucData + uiOffset);
+ output = std::string((const char*)_pucData + uiOffset);
}
// Access from/to subsystems
diff --git a/parameter/ParameterBlackboard.h b/parameter/ParameterBlackboard.h
index 111208a..bd48cc4 100644
--- a/parameter/ParameterBlackboard.h
+++ b/parameter/ParameterBlackboard.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include "BinaryStream.h"
+#include <string>
class CParameterBlackboard
{
@@ -45,8 +46,8 @@ public:
// Single parameter access
void writeInteger(const void* pvSrcData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian);
void readInteger(void* pvDstData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian) const;
- void writeString(const char* pcSrcData, uint32_t uiOffset);
- void readString(char* pcDstData, uint32_t uiOffset) const;
+ void writeString(const std::string &input, uint32_t uiOffset);
+ void readString(std::string &output, uint32_t uiOffset) const;
// Access from/to subsystems
uint8_t* getLocation(uint32_t uiOffset);
diff --git a/parameter/StringParameter.cpp b/parameter/StringParameter.cpp
index cb13e9b..8ba5b16 100644
--- a/parameter/StringParameter.cpp
+++ b/parameter/StringParameter.cpp
@@ -32,7 +32,6 @@
#include "ParameterAccessContext.h"
#include "ConfigurationAccessContext.h"
#include "ParameterBlackboard.h"
-#include <alloca.h>
#define base CBaseParameter
@@ -79,19 +78,12 @@ bool CStringParameter::doSetValue(const string& strValue, uint32_t uiOffset, CPa
// Write blackboard
CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard();
- pBlackboard->writeString(strValue.c_str(), uiOffset);
+ pBlackboard->writeString(strValue, uiOffset);
return true;
}
void CStringParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const
{
- char* pcValue = (char*)alloca(getSize());
-
- // Read blackboard
- const CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard();
-
- pBlackboard->readString(pcValue, uiOffset);
-
- strValue = pcValue;
+ parameterAccessContext.getParameterBlackboard()->readString(strValue, uiOffset);
}