diff --git a/pvDataApp/factory/Convert.cpp b/pvDataApp/factory/Convert.cpp index 036cb38..f093429 100644 --- a/pvDataApp/factory/Convert.cpp +++ b/pvDataApp/factory/Convert.cpp @@ -1067,29 +1067,7 @@ void Convert::copyStructureArray( String message("Convert.copyStructureArray destination is immutable"); throw std::invalid_argument(message); } - StructureConstPtr xxx = from->getStructureArray()->getStructure(); - StructureConstPtr yyy = to->getStructureArray()->getStructure(); - if(!isCopyStructureCompatible(xxx,yyy)) { - String message("Convert.copyStructureArray from and to are not compatible"); - throw std::invalid_argument(message); - } - size_t length = from->getLength(); - if(to->getCapacity()setCapacity(length); - PVStructurePtr * fromArray = from->get(); - PVStructurePtr * toArray = to->get(); - for(size_t i=0; igetStructureArray()->getStructure(); - toArray[i] = pvDataCreate->createPVStructure(structure); - } - copyStructure(fromArray[i],toArray[i]); - } - } - to->setLength(length); - to->postPut(); + to->put(0,from->getLength(),from->getVector(),0); } String Convert::toString(PVScalarPtr const & pv) diff --git a/pvDataApp/factory/PVStructureArray.cpp b/pvDataApp/factory/PVStructureArray.cpp index 683b550..1a0aa16 100644 --- a/pvDataApp/factory/PVStructureArray.cpp +++ b/pvDataApp/factory/PVStructureArray.cpp @@ -178,19 +178,19 @@ void PVStructureArray::deserialize(ByteBuffer *pbuffer, if(size>=0) { // prepare array, if necessary if(size>getCapacity()) setCapacity(size); - PVStructurePtrArray pvArray = *value.get(); + PVStructurePtrArray *pvArray = value.get(); for(size_t i = 0; iensureData(1); size_t temp = pbuffer->getByte(); if(temp==0) { - pvArray[i].reset(); + (*pvArray)[i].reset(); } else { - if(pvArray[i].get()==NULL) { + if((*pvArray)[i].get()==NULL) { StructureConstPtr structure = structureArray->getStructure(); - pvArray[i] = getPVDataCreate()->createPVStructure(structure); + (*pvArray)[i] = getPVDataCreate()->createPVStructure(structure); } - pvArray[i]->deserialize(pbuffer, pcontrol); + (*pvArray)[i]->deserialize(pbuffer, pcontrol); } } setLength(size); diff --git a/testApp/pv/testPVStructureArray.cpp b/testApp/pv/testPVStructureArray.cpp index 889dc96..8543d8a 100644 --- a/testApp/pv/testPVStructureArray.cpp +++ b/testApp/pv/testPVStructureArray.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ static FieldCreatePtr fieldCreate; static PVDataCreatePtr pvDataCreate; static StandardFieldPtr standardField; static StandardPVFieldPtr standardPVField; +static ConvertPtr convert; static String buffer; void testPVStructureArray(FILE * fd) { @@ -45,6 +47,11 @@ void testPVStructureArray(FILE * fd) { buffer.clear(); pvAlarmStructure->toString(&buffer); fprintf(fd,"pvAlarmStructure\n%s\n",buffer.c_str()); + PVStructureArrayPtr copy(pvDataCreate->createPVStructureArray(alarm)); + convert->copyStructureArray(pvAlarmStructure,copy); + buffer.clear(); + copy->toString(&buffer); + fprintf(fd,"copy\n%s\n",buffer.c_str()); } StructureConstPtr getPowerSupplyStructure() { @@ -101,6 +108,7 @@ int main(int argc,char *argv[]) pvDataCreate = getPVDataCreate(); standardField = getStandardField(); standardPVField = getStandardPVField(); + convert = getConvert(); testPVStructureArray(fd); testPowerSupplyArray(fd); return(0);