From f4de6dd9b1a36a884dad505e02f155e3221063c5 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Wed, 15 Apr 2020 10:54:54 +0200 Subject: [PATCH] replaced tabs with spaces --- src/copy/createRequest.cpp | 2 +- src/factory/Compare.cpp | 4 +- src/factory/FieldCreateFactory.cpp | 88 ++++++++-------- src/factory/PVArray.cpp | 2 +- src/factory/PVDataCreateFactory.cpp | 18 ++-- src/factory/PVField.cpp | 2 +- src/factory/PVStructure.cpp | 30 +++--- src/factory/PVStructureArray.cpp | 4 +- src/factory/PVUnion.cpp | 36 +++---- src/factory/PVUnionArray.cpp | 4 +- src/factory/StandardField.cpp | 4 +- src/misc/bitSet.cpp | 2 +- src/misc/pv/serialize.h | 4 +- src/misc/pv/status.h | 26 ++--- src/misc/serializeHelper.cpp | 2 +- src/misc/status.cpp | 56 +++++----- src/pv/pvData.h | 16 +-- src/pv/pvIntrospect.h | 38 +++---- testApp/copy/testCreateRequest.cpp | 12 +-- testApp/misc/testSerialization.cpp | 158 ++++++++++++++-------------- testApp/pv/testFieldBuilder.cpp | 6 +- 21 files changed, 257 insertions(+), 257 deletions(-) diff --git a/src/copy/createRequest.cpp b/src/copy/createRequest.cpp index ebde3ac..6cc5d3e 100644 --- a/src/copy/createRequest.cpp +++ b/src/copy/createRequest.cpp @@ -129,7 +129,7 @@ struct CreateRequestImpl { if(pos==string::npos) break; numValues++; index = pos +1; - } + } vector valueList(numValues,""); index=0; for(size_t i=0; i Field::build() const std::ostream& operator<<(std::ostream& o, const Field& f) { - return f.dump(o); + return f.dump(o); }; Scalar::Scalar(ScalarType scalarType) @@ -136,18 +136,18 @@ std::ostream& Scalar::dump(std::ostream& o) const string Scalar::getID() const { static const string idScalarLUT[] = { - "boolean", // pvBoolean - "byte", // pvByte - "short", // pvShort - "int", // pvInt - "long", // pvLong - "ubyte", // pvUByte - "ushort", // pvUShort - "uint", // pvUInt - "ulong", // pvULong - "float", // pvFloat - "double", // pvDouble - "string" // pvString + "boolean", // pvBoolean + "byte", // pvByte + "short", // pvShort + "int", // pvInt + "long", // pvLong + "ubyte", // pvUByte + "ushort", // pvUShort + "uint", // pvUInt + "ulong", // pvULong + "float", // pvFloat + "double", // pvDouble + "string" // pvString }; return idScalarLUT[scalarType]; } @@ -227,7 +227,7 @@ static void serializeStructureField(const Structure* structure, ByteBuffer* buff // to optimize default (non-empty) IDs optimization // empty IDs are not allowed string id = structure->getID(); - if (id == Structure::DEFAULT_ID) // TODO slow comparison + if (id == Structure::DEFAULT_ID) // TODO slow comparison SerializeHelper::serializeString(string(), buffer, control); else SerializeHelper::serializeString(id, buffer, control); @@ -263,13 +263,13 @@ static StructureConstPtr deserializeStructureField(const FieldCreate* fieldCreat static void serializeUnionField(const Union* punion, ByteBuffer* buffer, SerializableControl* control) { - // to optimize default (non-empty) IDs optimization - // empty IDs are not allowed - string id = punion->getID(); - if (id == Union::DEFAULT_ID) // TODO slow comparison + // to optimize default (non-empty) IDs optimization + // empty IDs are not allowed + string id = punion->getID(); + if (id == Union::DEFAULT_ID) // TODO slow comparison SerializeHelper::serializeString(string(), buffer, control); - else - SerializeHelper::serializeString(id, buffer, control); + else + SerializeHelper::serializeString(id, buffer, control); FieldConstPtrArray const & fields = punion->getFields(); StringArray const & fieldNames = punion->getFieldNames(); @@ -297,7 +297,7 @@ static UnionConstPtr deserializeUnionField(const FieldCreate* fieldCreate, ByteB if (id.empty()) return fieldCreate->createUnion(fieldNames, fields); else - return fieldCreate->createUnion(id, fieldNames, fields); + return fieldCreate->createUnion(id, fieldNames, fields); } Array::Array(Type type) @@ -323,18 +323,18 @@ ScalarArray::~ScalarArray() const string ScalarArray::getIDScalarArrayLUT() const { static const string idScalarArrayLUT[] = { - "boolean[]", // pvBoolean - "byte[]", // pvByte - "short[]", // pvShort - "int[]", // pvInt - "long[]", // pvLong - "ubyte[]", // pvUByte - "ushort[]", // pvUShort - "uint[]", // pvUInt - "ulong[]", // pvULong - "float[]", // pvFloat - "double[]", // pvDouble - "string[]" // pvString + "boolean[]", // pvBoolean + "byte[]", // pvByte + "short[]", // pvShort + "int[]", // pvInt + "long[]", // pvLong + "ubyte[]", // pvUByte + "ushort[]", // pvUShort + "uint[]", // pvUInt + "ulong[]", // pvULong + "float[]", // pvFloat + "double[]", // pvDouble + "string[]" // pvString }; return idScalarArrayLUT[elementType]; } @@ -427,7 +427,7 @@ StructureArray::~StructureArray() string StructureArray::getID() const { - return pstructure->getID() + "[]"; + return pstructure->getID() + "[]"; } std::ostream& StructureArray::dump(std::ostream& o) const @@ -467,7 +467,7 @@ UnionArray::~UnionArray() string UnionArray::getID() const { - return punion->getID() + "[]"; + return punion->getID() + "[]"; } std::ostream& UnionArray::dump(std::ostream& o) const @@ -555,7 +555,7 @@ Structure::~Structure() string Structure::getID() const { - return id; + return id; } FieldConstPtr Structure::getField(string const & fieldName) const { @@ -771,7 +771,7 @@ int32 Union::guess(Type t, ScalarType s) const string Union::getID() const { - return id; + return id; } FieldConstPtr Union::getField(string const & fieldName) const { @@ -966,7 +966,7 @@ FieldBuilder::FieldBuilder(const FieldBuilderPtr & _parentBuilder, {} FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder, - string const & _nestedName, + string const & _nestedName, Type _nestedClassToBuild, bool _nestedArray) :fieldCreate(_parentBuilder->fieldCreate) ,idSet(false) @@ -979,10 +979,10 @@ FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder, void FieldBuilder::reset() { - id.erase(); + id.erase(); idSet = false; - fieldNames.clear(); - fields.clear(); + fieldNames.clear(); + fields.clear(); } FieldBuilderPtr FieldBuilder::begin() @@ -1023,7 +1023,7 @@ FieldBuilderPtr FieldBuilder::add(string const & name, FieldConstPtr const & fie } else if(*cur!=*field) { THROW_EXCEPTION2(std::runtime_error, "duplicate field name w/ different type : "+name); } // else exact duplicate is silently ignored - return shared_from_this(); + return shared_from_this(); } FieldBuilderPtr FieldBuilder::addArray(string const & name, ScalarType scalarType) @@ -1100,7 +1100,7 @@ StructureConstPtr FieldBuilder::createStructure() { if (parentBuilder.get()) THROW_EXCEPTION2(std::runtime_error, "createStructure() called in nested FieldBuilder"); - + StructureConstPtr field(static_pointer_cast(createFieldInternal(structure))); reset(); return field; @@ -1110,7 +1110,7 @@ UnionConstPtr FieldBuilder::createUnion() { if (parentBuilder.get()) THROW_EXCEPTION2(std::runtime_error, "createUnion() called in nested FieldBuilder"); - + UnionConstPtr field(static_pointer_cast(createFieldInternal(union_))); reset(); return field; diff --git a/src/factory/PVArray.cpp b/src/factory/PVArray.cpp index e3d473a..c2cb04f 100644 --- a/src/factory/PVArray.cpp +++ b/src/factory/PVArray.cpp @@ -49,7 +49,7 @@ PVArray::PVArray(FieldConstPtr const & field) std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array) { - return array.dumpValue(manip.stream, manip.index); + return array.dumpValue(manip.stream, manip.index); } }} diff --git a/src/factory/PVDataCreateFactory.cpp b/src/factory/PVDataCreateFactory.cpp index 5ed5b90..0f019c0 100644 --- a/src/factory/PVDataCreateFactory.cpp +++ b/src/factory/PVDataCreateFactory.cpp @@ -160,17 +160,17 @@ void PVString::serialize(ByteBuffer *pbuffer, void PVString::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher, size_t offset, size_t count) const { - // check bounds + // check bounds const size_t length = storage.value.length(); - /*if (offset < 0) offset = 0; - else*/ if (offset > length) offset = length; - //if (count < 0) count = length; + /*if (offset < 0) offset = 0; + else*/ if (offset > length) offset = length; + //if (count < 0) count = length; - const size_t maxCount = length - offset; - if (count > maxCount) - count = maxCount; - - // write + const size_t maxCount = length - offset; + if (count > maxCount) + count = maxCount; + + // write SerializeHelper::serializeSubstring(storage.value, offset, count, pbuffer, pflusher); } diff --git a/src/factory/PVField.cpp b/src/factory/PVField.cpp index 049ebe7..5da743c 100644 --- a/src/factory/PVField.cpp +++ b/src/factory/PVField.cpp @@ -91,7 +91,7 @@ bool PVField::equals(PVField &pv) std::ostream& operator<<(std::ostream& o, const PVField& f) { - return f.dumpValue(o); + return f.dumpValue(o); }; string PVField::getFullName() const diff --git a/src/factory/PVStructure.cpp b/src/factory/PVStructure.cpp index 75447f4..2ee5800 100644 --- a/src/factory/PVStructure.cpp +++ b/src/factory/PVStructure.cpp @@ -38,7 +38,7 @@ PVStructure::PVStructure(StructureConstPtr const & structurePtr) pvFields.push_back(pvDataCreate->createPVField(fields[i])); } for(size_t i=0; isetParentAndName(this,fieldNames[i]); + pvFields[i]->setParentAndName(this,fieldNames[i]); } } @@ -307,22 +307,22 @@ std::ostream& PVStructure::dumpValue(std::ostream& o) const o << format::indent() << getStructure()->getID() << ' ' << getFieldName(); o << std::endl; { - format::indent_scope s(o); + format::indent_scope s(o); - PVFieldPtrArray const & fieldsData = getPVFields(); - if (fieldsData.size() != 0) { - size_t length = getStructure()->getNumberFields(); - for(size_t i=0; igetField()->getType(); - if (type == scalar || type == scalarArray) - o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl; - else - o << *(fieldField.get()); - } - } + PVFieldPtrArray const & fieldsData = getPVFields(); + if (fieldsData.size() != 0) { + size_t length = getStructure()->getNumberFields(); + for(size_t i=0; igetField()->getType(); + if (type == scalar || type == scalarArray) + o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl; + else + o << *(fieldField.get()); + } + } } - return o; + return o; } diff --git a/src/factory/PVStructureArray.cpp b/src/factory/PVStructureArray.cpp index ea8a2a1..66577b5 100644 --- a/src/factory/PVStructureArray.cpp +++ b/src/factory/PVStructureArray.cpp @@ -218,10 +218,10 @@ std::ostream& PVStructureArray::dumpValue(std::ostream& o) const size_t length = getLength(); if (length > 0) { - format::indent_scope s(o); + format::indent_scope s(o); for (size_t i = 0; i < length; i++) - dumpValue(o, i); + dumpValue(o, i); } return o; diff --git a/src/factory/PVUnion.cpp b/src/factory/PVUnion.cpp index 5450dbe..400614a 100644 --- a/src/factory/PVUnion.cpp +++ b/src/factory/PVUnion.cpp @@ -23,7 +23,7 @@ using std::size_t; using std::string; namespace epics { namespace pvData { - + #define PVUNION_UNDEFINED_INDEX -1 const int32 PVUnion::UNDEFINED_INDEX = PVUNION_UNDEFINED_INDEX; @@ -75,13 +75,13 @@ PVFieldPtr PVUnion::select(int32 index) return value; } - + PVFieldPtr PVUnion::select(string const & fieldName) { int32 index = variant ? -1 : static_cast(unionPtr->getFieldIndex(fieldName)); - if (index == -1) + if (index == -1) throw std::invalid_argument("no such fieldName"); - return select(index); + return select(index); } void PVUnion::set(int32 index, PVFieldPtr const & value) @@ -94,14 +94,14 @@ void PVUnion::set(int32 index, PVFieldPtr const & value) { // for undefined index we accept only null values if (value) - throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX"); + throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX"); } else if (index < 0 || size_t(index) >= unionPtr->getFields().size()) throw std::invalid_argument("index out of bounds"); else if (!value) throw std::invalid_argument("Can't set defined index w/ NULL"); else if (value->getField() != unionPtr->getField(index)) - throw std::invalid_argument("selected field and its introspection data do not match"); + throw std::invalid_argument("selected field and its introspection data do not match"); } selector = index; @@ -180,20 +180,20 @@ std::ostream& PVUnion::dumpValue(std::ostream& o) const { o << format::indent() << getUnion()->getID() << ' ' << getFieldName() << std::endl; { - format::indent_scope s(o); + format::indent_scope s(o); const PVField::const_shared_pointer& fieldField = get(); - if (fieldField.get() == NULL) - o << format::indent() << "(none)" << std::endl; - else - { - Type type = fieldField->getField()->getType(); - if (type == scalar || type == scalarArray) - o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl; - else - o << *(fieldField.get()); - } + if (fieldField.get() == NULL) + o << format::indent() << "(none)" << std::endl; + else + { + Type type = fieldField->getField()->getType(); + if (type == scalar || type == scalarArray) + o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl; + else + o << *(fieldField.get()); + } } - return o; + return o; } void PVUnion::copy(const PVUnion& from) diff --git a/src/factory/PVUnionArray.cpp b/src/factory/PVUnionArray.cpp index 5bb79a0..151bc5b 100644 --- a/src/factory/PVUnionArray.cpp +++ b/src/factory/PVUnionArray.cpp @@ -217,10 +217,10 @@ std::ostream& PVUnionArray::dumpValue(std::ostream& o) const size_t length = getLength(); if (length > 0) { - format::indent_scope s(o); + format::indent_scope s(o); for (size_t i = 0; i < length; i++) - dumpValue(o, i); + dumpValue(o, i); } return o; diff --git a/src/factory/StandardField.cpp b/src/factory/StandardField.cpp index 4bfc7f3..20cbc8c 100644 --- a/src/factory/StandardField.cpp +++ b/src/factory/StandardField.cpp @@ -123,8 +123,8 @@ StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field, while(gotValueAlarm) { if(type==epics::pvData::scalar || type==epics::pvData::scalarArray) { ScalarType scalarType = (type==epics::pvData::scalar) ? - static_pointer_cast(field)->getScalarType() : - static_pointer_cast(field)->getElementType(); + static_pointer_cast(field)->getScalarType() : + static_pointer_cast(field)->getElementType(); switch(scalarType) { case pvBoolean: valueAlarm = booleanAlarmField; break; case pvByte: valueAlarm = byteAlarmField; break; diff --git a/src/misc/bitSet.cpp b/src/misc/bitSet.cpp index e58e778..0fa972e 100644 --- a/src/misc/bitSet.cpp +++ b/src/misc/bitSet.cpp @@ -338,7 +338,7 @@ namespace epics { namespace pvData { void BitSet::deserialize(ByteBuffer* buffer, DeserializableControl* control) { - uint32 bytes = static_cast(SerializeHelper::readSize(buffer, control)); // in bytes + uint32 bytes = static_cast(SerializeHelper::readSize(buffer, control)); // in bytes size_t wordsInUse = (bytes + 7) / BYTES_PER_WORD; words.resize(wordsInUse); diff --git a/src/misc/pv/serialize.h b/src/misc/pv/serialize.h index b9e1763..50000f7 100644 --- a/src/misc/pv/serialize.h +++ b/src/misc/pv/serialize.h @@ -150,7 +150,7 @@ namespace epics { namespace pvData { */ virtual void serialize(ByteBuffer *buffer, SerializableControl *flusher) const = 0; - /** + /** * Deserialize buffer. * @param buffer serialization buffer. * @param flusher deserialization control. @@ -213,7 +213,7 @@ namespace epics { namespace pvData { */ virtual void serialize(ByteBuffer *buffer, SerializableControl *flusher,BitSet *bitSet) const = 0; - /** + /** * Deserialize buffer. * @param buffer serialization buffer. * @param flusher deserialization control. diff --git a/src/misc/pv/status.h b/src/misc/pv/status.h index 4690511..0cb3f0d 100644 --- a/src/misc/pv/status.h +++ b/src/misc/pv/status.h @@ -28,10 +28,10 @@ namespace epics { namespace pvData { class epicsShareClass Status : public epics::pvData::Serializable { public: POINTER_DEFINITIONS(Status); - /** - * Status type enum. - */ - enum StatusType { + /** + * Status type enum. + */ + enum StatusType { /** Operation completed successfully. */ STATUSTYPE_OK, /** Operation completed successfully, but there is a warning message. */ @@ -40,11 +40,11 @@ namespace epics { namespace pvData { STATUSTYPE_ERROR, /** Operation failed due to an unexpected error. */ STATUSTYPE_FATAL - }; - - static const char* StatusTypeName[]; - - static Status Ok; + }; + + static const char* StatusTypeName[]; + + static Status Ok; static inline Status warn(const std::string& m) { return Status(STATUSTYPE_WARNING, m); } static inline Status error(const std::string& m) { return Status(STATUSTYPE_ERROR, m); } @@ -54,10 +54,10 @@ namespace epics { namespace pvData { * Creates OK status; STATUSTYPE_OK, empty message and stackDump. */ Status() :m_statusType(STATUSTYPE_OK) {} - - /** - * Create non-OK status. - */ + + /** + * Create non-OK status. + */ Status(StatusType type, std::string const & message); /** diff --git a/src/misc/serializeHelper.cpp b/src/misc/serializeHelper.cpp index 4bda586..33362d5 100644 --- a/src/misc/serializeHelper.cpp +++ b/src/misc/serializeHelper.cpp @@ -103,7 +103,7 @@ namespace epics { DeserializableControl* control) { std::size_t size = SerializeHelper::readSize(buffer, control); - if(size!=(size_t)-1) // TODO null strings check, to be removed in the future + if(size!=(size_t)-1) // TODO null strings check, to be removed in the future { if (buffer->getRemaining()>=size) { diff --git a/src/misc/status.cpp b/src/misc/status.cpp index 3097d0c..6f09d50 100644 --- a/src/misc/status.cpp +++ b/src/misc/status.cpp @@ -44,40 +44,40 @@ void Status::maximize(const Status& o) void Status::serialize(ByteBuffer *buffer, SerializableControl *flusher) const { - flusher->ensureBuffer(1); - if (m_statusType == STATUSTYPE_OK) - { - // special code for okStatus (optimization) - buffer->putByte((int8)-1); - } - else - { - buffer->putByte((int8)m_statusType); - SerializeHelper::serializeString(m_message, buffer, flusher); - SerializeHelper::serializeString(m_stackDump, buffer, flusher); - } + flusher->ensureBuffer(1); + if (m_statusType == STATUSTYPE_OK) + { + // special code for okStatus (optimization) + buffer->putByte((int8)-1); + } + else + { + buffer->putByte((int8)m_statusType); + SerializeHelper::serializeString(m_message, buffer, flusher); + SerializeHelper::serializeString(m_stackDump, buffer, flusher); + } } void Status::deserialize(ByteBuffer *buffer, DeserializableControl *flusher) { - flusher->ensureData(1); - int8 typeCode = buffer->getByte(); - if (typeCode == (int8)-1) - { - // in most of the cases status will be OK, we statistically optimize - if (m_statusType != STATUSTYPE_OK) - { - m_statusType = STATUSTYPE_OK; + flusher->ensureData(1); + int8 typeCode = buffer->getByte(); + if (typeCode == (int8)-1) + { + // in most of the cases status will be OK, we statistically optimize + if (m_statusType != STATUSTYPE_OK) + { + m_statusType = STATUSTYPE_OK; m_message.clear(); m_stackDump.clear(); - } - } - else - { - m_statusType = (StatusType)typeCode; - m_message = SerializeHelper::deserializeString(buffer, flusher); - m_stackDump = SerializeHelper::deserializeString(buffer, flusher); - } + } + } + else + { + m_statusType = (StatusType)typeCode; + m_message = SerializeHelper::deserializeString(buffer, flusher); + m_stackDump = SerializeHelper::deserializeString(buffer, flusher); + } } void Status::dump(std::ostream& o) const diff --git a/src/pv/pvData.h b/src/pv/pvData.h index 40d2564..a33fb0e 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -948,11 +948,11 @@ public: typedef PVUnion & reference; typedef const PVUnion & const_reference; - /** - * Undefined index. - * Default value upon PVUnion construction. Can be set by the user. - * Corresponds to @c null value. - */ + /** + * Undefined index. + * Default value upon PVUnion construction. Can be set by the user. + * Corresponds to @c null value. + */ static const int32 UNDEFINED_INDEX; /** @@ -1081,9 +1081,9 @@ private: friend class PVDataCreate; UnionConstPtr unionPtr; // same as PVField::getField() - int32 selector; - PVFieldPtr value; - bool variant; + int32 selector; + PVFieldPtr value; + bool variant; EPICS_NOT_COPYABLE(PVUnion) }; diff --git a/src/pv/pvIntrospect.h b/src/pv/pvIntrospect.h index 3b3783b..5cee5d0 100644 --- a/src/pv/pvIntrospect.h +++ b/src/pv/pvIntrospect.h @@ -1079,12 +1079,12 @@ public: //! Create a new instance of in-line @c Field builder pre-initialized with and existing Structure static FieldBuilderPtr begin(StructureConstPtr S); - /** - * Set ID of an object to be created. - * @param id id to be set. + /** + * Set ID of an object to be created. + * @param id id to be set. * @return this instance of a @c FieldBuilder. - */ - FieldBuilderPtr setId(std::string const & id); + */ + FieldBuilderPtr setId(std::string const & id); /** * Add a @c Scalar. @@ -1214,20 +1214,20 @@ private: FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const Union*); FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const UnionArray*); FieldBuilder(FieldBuilderPtr const & parentBuilder, - std::string const & nestedName, - Type nestedClassToBuild, bool nestedArray); + std::string const & nestedName, + Type nestedClassToBuild, bool nestedArray); const Field *findField(const std::string& name, Type ftype); - - void reset(); - FieldConstPtr createFieldInternal(Type type); + + void reset(); + FieldConstPtr createFieldInternal(Type type); friend class FieldCreate; const FieldCreatePtr fieldCreate; - std::string id; - bool idSet; + std::string id; + bool idSet; StringArray fieldNames; FieldConstPtrArray fields; @@ -1251,11 +1251,11 @@ class epicsShareClass FieldCreate { friend struct detail::field_factory; public: static const FieldCreatePtr &getFieldCreate(); - /** - * Create a new instance of in-line @c Field builder. - * @return a new instance of a @c FieldBuilder. - */ - FieldBuilderPtr createFieldBuilder() const; + /** + * Create a new instance of in-line @c Field builder. + * @return a new instance of a @c FieldBuilder. + */ + FieldBuilderPtr createFieldBuilder() const; /** * Create a new instance of in-line @c Field builder pre-initialized with and existing Structure * @return a new instance of a @c FieldBuilder. @@ -1323,7 +1323,7 @@ public: * @return a @c Structure interface for the newly created object. */ StructureConstPtr createStructure ( - std::string const & id, + std::string const & id, StringArray const & fieldNames, FieldConstPtrArray const & fields) const; /** @@ -1359,7 +1359,7 @@ public: * @return a @c Union interface for the newly created object. */ UnionConstPtr createUnion ( - std::string const & id, + std::string const & id, StringArray const & fieldNames, FieldConstPtrArray const & fields) const; /** diff --git a/testApp/copy/testCreateRequest.cpp b/testApp/copy/testCreateRequest.cpp index 0fb793c..b76f1c5 100644 --- a/testApp/copy/testCreateRequest.cpp +++ b/testApp/copy/testCreateRequest.cpp @@ -203,8 +203,8 @@ static void testCreateRequestInternal() { request = string("record[process=true,xxx=yyy]") + "putField(power.value)" - + "getField(alarm,timeStamp,power{value,alarm}," - + "current{value,alarm},voltage{value,alarm})"; + + "getField(alarm,timeStamp,power{value,alarm}," + + "current{value,alarm},voltage{value,alarm})"; pvRequest = createRequest->createRequest(request); if(!pvRequest) { cout<< createRequest->getMessage() << endl;} @@ -241,10 +241,10 @@ static void testCreateRequestInternal() { testPass("request %s",request.c_str()); request = string("record[process=true,xxx=yyy]") - + "putField(power.value)" - + "getField(alarm,timeStamp,power{value,alarm}," - + "current{value,alarm},voltage{value,alarm}," - + "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}," + + "putField(power.value)" + + "getField(alarm,timeStamp,power{value,alarm}," + + "current{value,alarm},voltage{value,alarm}," + + "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}," + "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}" + ")"; diff --git a/testApp/misc/testSerialization.cpp b/testApp/misc/testSerialization.cpp index 8ec0b44..6845452 100644 --- a/testApp/misc/testSerialization.cpp +++ b/testApp/misc/testSerialization.cpp @@ -146,48 +146,48 @@ void testEquals() { PVDataCreatePtr factory = getPVDataCreate(); testOk1(factory.get()!=NULL); - // be sure all is covered - for (int i = pvBoolean; i < pvString; i++) - { - ScalarType scalarType = static_cast(i); + // be sure all is covered + for (int i = pvBoolean; i < pvString; i++) + { + ScalarType scalarType = static_cast(i); - PVScalarPtr scalar1 = factory->createPVScalar(scalarType); - PVScalarPtr scalar2 = factory->createPVScalar(scalarType); - testOk1((*scalar1)==(*scalar2)); + PVScalarPtr scalar1 = factory->createPVScalar(scalarType); + PVScalarPtr scalar2 = factory->createPVScalar(scalarType); + testOk1((*scalar1)==(*scalar2)); - PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType); - PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType); - testOk1((*array1)==(*array2)); - } + PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType); + PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType); + testOk1((*array1)==(*array2)); + } - // and a structure + // and a structure PVStructurePtr structure1 = factory->createPVStructure(getStandardField()->timeStamp()); PVStructurePtr structure2 = factory->createPVStructure(getStandardField()->timeStamp()); - testOk1((*structure1)==(*structure2)); + testOk1((*structure1)==(*structure2)); // and a structure array PVStructureArrayPtr structureArray1 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure1->getStructure())); PVStructureArrayPtr structureArray2 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure2->getStructure())); - testOk1((*structureArray1)==(*structureArray2)); - - // variant union - PVUnionPtr variantUnion1 = factory->createPVVariantUnion(); - PVUnionPtr variantUnion2 = factory->createPVVariantUnion(); - testOk1((*variantUnion1)==(*variantUnion2)); - - variantUnion1->set(structure1); - variantUnion2->set(structure1); - testOk1((*variantUnion1)==(*variantUnion2)); + testOk1((*structureArray1)==(*structureArray2)); + + // variant union + PVUnionPtr variantUnion1 = factory->createPVVariantUnion(); + PVUnionPtr variantUnion2 = factory->createPVVariantUnion(); + testOk1((*variantUnion1)==(*variantUnion2)); + + variantUnion1->set(structure1); + variantUnion2->set(structure1); + testOk1((*variantUnion1)==(*variantUnion2)); - variantUnion2->set(structureArray1); - testOk1((*variantUnion1)!=(*variantUnion2)); - - // variant union array - PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray(); - PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray(); - testOk1((*variantUnionArray1)==(*variantUnionArray2)); + variantUnion2->set(structureArray1); + testOk1((*variantUnion1)!=(*variantUnion2)); + + // variant union array + PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray(); + PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray(); + testOk1((*variantUnionArray1)==(*variantUnionArray2)); - // union + // union UnionConstPtr punion = getFieldCreate()->createFieldBuilder()-> add("double", pvDouble)-> add("double2", pvDouble)-> @@ -198,30 +198,30 @@ void testEquals() { endNested()-> addArray("intArray", pvInt)-> createUnion(); - PVUnionPtr union1 = factory->createPVUnion(punion); - PVUnionPtr union2 = factory->createPVUnion(punion); - testOk1((*union1)==(*union2)); - - union1->select("double")->put(1.2); - union2->select("double")->put(1.2); - testOk1((*union1)==(*union2)); - - union2->select("double")->put(2.2); - testOk1((*union1)!=(*union2)); + PVUnionPtr union1 = factory->createPVUnion(punion); + PVUnionPtr union2 = factory->createPVUnion(punion); + testOk1((*union1)==(*union2)); + + union1->select("double")->put(1.2); + union2->select("double")->put(1.2); + testOk1((*union1)==(*union2)); + + union2->select("double")->put(2.2); + testOk1((*union1)!=(*union2)); - union2->select("double2")->put(1.2); - testOk1((*union1)!=(*union2)); + union2->select("double2")->put(1.2); + testOk1((*union1)!=(*union2)); - union2->select("nested"); - testOk1((*union1)!=(*union2)); + union2->select("nested"); + testOk1((*union1)!=(*union2)); - testOk1((*union1)!=(*variantUnion2)); - - PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion)); - PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion)); - testOk1((*unionArray1)==(*unionArray2)); + testOk1((*union1)!=(*variantUnion2)); + + PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion)); + PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion)); + testOk1((*unionArray1)==(*unionArray2)); - testOk1((*variantUnionArray1)!=(*unionArray2)); + testOk1((*variantUnionArray1)!=(*unionArray2)); } template @@ -264,7 +264,7 @@ void testScalar() { testDiag("type %s", ScalarTypeFunc::name(pvBoolean)); PVBooleanPtr pvBoolean = - std::tr1::static_pointer_cast(factory->createPVScalar(epics::pvData::pvBoolean)); + std::tr1::static_pointer_cast(factory->createPVScalar(epics::pvData::pvBoolean)); pvBoolean->put(false); serializationTest(pvBoolean); pvBoolean->put(true); @@ -284,7 +284,7 @@ void testScalar() { testDiag("type %s", ScalarTypeFunc::name(pvString)); PVStringPtr pvString = - std::tr1::static_pointer_cast(factory->createPVScalar(epics::pvData::pvString)); + std::tr1::static_pointer_cast(factory->createPVScalar(epics::pvData::pvString)); pvString->put(""); serializationTest(pvString); pvString->put("s"); @@ -382,7 +382,7 @@ void testStructure() { testOk1(factory.get()!=NULL); testDiag("\tSimple structure serialization"); - PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp()); + PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp()); pvStructure->getSubField("secondsPastEpoch")->put(123); pvStructure->getSubField("nanoseconds")->put(456); pvStructure->getSubField("userTag")->put(789); @@ -390,11 +390,11 @@ void testStructure() { serializationTest(pvStructure); testDiag("\tComplex structure serialization"); - pvStructure = factory->createPVStructure( - getStandardField()->structureArray( - getStandardField()->timeStamp(), "alarm,control,display,timeStamp") - ); - // TODO fill with data + pvStructure = factory->createPVStructure( + getStandardField()->structureArray( + getStandardField()->timeStamp(), "alarm,control,display,timeStamp") + ); + // TODO fill with data serializationTest(pvStructure); } @@ -469,7 +469,7 @@ void testUnion() { u = factory->createPVUnion(punion); testOk1(NULL!=u.get()); - // null union test + // null union test testOk1(NULL==u->get().get()); testOk1(PVUnion::UNDEFINED_INDEX == u->getSelectedIndex()); testOk1("" == u->getSelectedFieldName()); @@ -633,38 +633,38 @@ void serializationFieldTest(FieldConstPtr const & field) { testShow()<clear(); + buffer->clear(); - // serialize - field->serialize(buffer, flusher); + // serialize + field->serialize(buffer, flusher); - // deserialize - buffer->flip(); + // deserialize + buffer->flip(); - FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control); + FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control); testShow()<<" after "<<(void*)field.get()<<" == "<<(void*)deserializedField.get(); - testOk1(*field == *deserializedField); + testOk1(*field == *deserializedField); } void testIntrospectionSerialization() { - testDiag("Testing introspection serialization..."); + testDiag("Testing introspection serialization..."); - FieldCreatePtr factory = getFieldCreate(); - testOk1(factory.get()!=NULL); + FieldCreatePtr factory = getFieldCreate(); + testOk1(factory.get()!=NULL); - // be sure all is covered - for (int i = pvBoolean; i < pvString; i++) - { - ScalarType scalarType = static_cast(i); + // be sure all is covered + for (int i = pvBoolean; i < pvString; i++) + { + ScalarType scalarType = static_cast(i); - ScalarConstPtr scalar = factory->createScalar(scalarType); - serializationFieldTest(scalar); + ScalarConstPtr scalar = factory->createScalar(scalarType); + serializationFieldTest(scalar); - ScalarArrayConstPtr array = factory->createScalarArray(scalarType); - serializationFieldTest(array); - } + ScalarArrayConstPtr array = factory->createScalarArray(scalarType); + serializationFieldTest(array); + } // and a structure StructureConstPtr structure = getStandardField()->timeStamp(); diff --git a/testApp/pv/testFieldBuilder.cpp b/testApp/pv/testFieldBuilder.cpp index c619bde..b61e40d 100644 --- a/testApp/pv/testFieldBuilder.cpp +++ b/testApp/pv/testFieldBuilder.cpp @@ -25,7 +25,7 @@ void test_factory() testOk1(fb.get() != 0); FieldBuilderPtr fb2 = fieldCreate->createFieldBuilder(); - testOk1(fb.get() != fb2.get()); + testOk1(fb.get() != fb2.get()); } void test_structure() @@ -185,8 +185,8 @@ void test_nestedStructure() testOk1("intArray" == s->getFieldName(2)); testOk(pvInt == std::tr1::static_pointer_cast(f2)->getElementType(), "f2 element type == int"); -} - +} + void test_nestedStructureArray() {