added method putStringArray(std::vector<std::string> const & value)

This commit is contained in:
Marty Kraimer
2015-04-23 11:00:48 -04:00
parent dbbdc2b253
commit e5778699ec
2 changed files with 26 additions and 10 deletions

View File

@ -741,17 +741,23 @@ public:
*/
void putString(std::string const & value);
/**
* Copy the sub-array to the value field.
* Copy the array to the value field.
* If the value field is not a double array field an exception is thrown.
* @param value The place where data is copied.
*/
void putDoubleArray(epics::pvData::shared_vector<const double> const & value);
/**
* Copy the sub-array to the value field.
* If the value field is not a double array field an exception is thrown.
* @param value The place where data is copied.
* Copy array to the value field.
* If the value field is not a string array field an exception is thrown.
* @param value data source
*/
void putStringArray(epics::pvData::shared_vector<const std::string> const & value);
/**
* Copy array to the value field.
* If the value field is not a scalarArray field an exception is thrown.
* @param value data source
*/
void putStringArray(std::vector<std::string> const & value);
private:
EasyPutData(epics::pvData::StructureConstPtr const &structure);
void checkValue();

View File

@ -39,10 +39,10 @@ public:
typedef std::tr1::shared_ptr<PVArray> PVArrayPtr;
static ConvertPtr convert = getConvert();
static string noValue("no value field");
static string noScalar("value is not a scalar");
static string notScalar("value is not a scalar");
static string notCompatibleScalar("value is not a compatible scalar");
static string noArray("value is not an array");
static string noScalarArray("value is not a scalarArray");
static string notArray("value is not an array");
static string notScalarArray("value is not a scalarArray");
static string notDoubleArray("value is not a doubleArray");
static string notStringArray("value is not a stringArray");
@ -146,7 +146,7 @@ PVScalarPtr EasyPutData::getScalarValue()
checkValue();
PVScalarPtr pv = pvStructure->getSubField<PVScalar>("value");
if(!pv) {
throw std::runtime_error(messagePrefix + noScalar);
throw std::runtime_error(messagePrefix + notScalar);
}
return pv;
}
@ -156,7 +156,7 @@ PVArrayPtr EasyPutData::getArrayValue()
checkValue();
PVArrayPtr pv = pvStructure->getSubField<PVArray>("value");
if(!pv) {
throw std::runtime_error(messagePrefix + noArray);
throw std::runtime_error(messagePrefix + notArray);
}
return pv;
}
@ -166,7 +166,7 @@ PVScalarArrayPtr EasyPutData::getScalarArrayValue()
checkValue();
PVScalarArrayPtr pv = pvStructure->getSubField<PVScalarArray>("value");
if(!pv) {
throw std::runtime_error(messagePrefix + noScalarArray);
throw std::runtime_error(messagePrefix + notScalarArray);
}
return pv;
}
@ -254,4 +254,14 @@ void EasyPutData::putStringArray(shared_vector<const std::string> const & value)
pv->replace(value);
}
void EasyPutData::putStringArray(std::vector<std::string> const & value)
{
checkValue();
PVScalarArrayPtr pv = pvStructure->getSubField<PVScalarArray>("value");
if(!pv) {
throw std::runtime_error(messagePrefix + notScalarArray);
}
convert->fromStringArray(pv,0,value.size(),value,0);
}
}}