diff --git a/pvDataApp/factory/printer.cpp b/pvDataApp/factory/printer.cpp index 20dde9d..1776a1d 100644 --- a/pvDataApp/factory/printer.cpp +++ b/pvDataApp/factory/printer.cpp @@ -48,8 +48,12 @@ void PrinterBase::encodeScalar(const PVScalar& pv) {} void PrinterBase::encodeArray(const PVScalarArray&) {} +void PrinterBase::encodeNull() {} + void PrinterBase::impl_print(const PVField& pv) { + static const PVField* marker = (const PVField*)▮ + /* Depth first recursive iteration. * Each PV to be printed is appended to the todo queue. * The last child of a structure is followed by a NULL. @@ -64,7 +68,7 @@ void PrinterBase::impl_print(const PVField& pv) const PVField *next = todo.front(); todo.pop_front(); - if(!next) { + if(next==marker) { // finished with a structure or structarray, // now we fall back to its parent. assert(!inprog.empty()); @@ -86,6 +90,12 @@ void PrinterBase::impl_print(const PVField& pv) } else { // real field + if(!next) { + // NULL entry in a structure array + encodeNull(); + continue; + } + switch(next->getField()->getType()) { case scalar: encodeScalar(*static_cast(next)); @@ -103,7 +113,7 @@ void PrinterBase::impl_print(const PVField& pv) for(size_t i=0, nfld=fld.getStructure()->getNumberFields(); igetID() << " " - << pv.getFieldName() << " "; + << pv.getFieldName() << "[] "; ilvl++; } @@ -179,5 +189,10 @@ void PrinterPlain::encodeArray(const PVScalarArray& pv) S() << "]" << std::endl; } +void PrinterPlain::encodeNull() +{ + indentN(S(), ilvl); + S() << "NULL" << std::endl; +} }} diff --git a/pvDataApp/pv/printer.h b/pvDataApp/pv/printer.h index 115b052..b9b60df 100644 --- a/pvDataApp/pv/printer.h +++ b/pvDataApp/pv/printer.h @@ -27,6 +27,7 @@ protected: virtual void encodeScalar(const PVScalar&); virtual void encodeArray(const PVScalarArray&); + virtual void encodeNull(); inline std::ostream& S() { return *strm; } @@ -47,6 +48,7 @@ protected: virtual void encodeScalar(const PVScalar&); virtual void encodeArray(const PVScalarArray&); + virtual void encodeNull(); public: PrinterPlain();