From 9ad725a27233e806cdc7baeeccf2d948cd3b84e6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Jun 2015 16:51:04 -0400 Subject: [PATCH] remove unused PrinterPlain --- documentation/TODO.md | 5 - src/factory/Convert.cpp | 3 - src/factory/printer.cpp | 254 +--------------------------------------- src/misc/Makefile | 1 - src/pv/printer.h | 73 ------------ 5 files changed, 1 insertion(+), 335 deletions(-) delete mode 100644 src/pv/printer.h diff --git a/documentation/TODO.md b/documentation/TODO.md index 1a135d2..2ab06e5 100644 --- a/documentation/TODO.md +++ b/documentation/TODO.md @@ -1,11 +1,6 @@ TODO =========== -printer ------------- - -pv/printer.h is not used. - doxygen ------- diff --git a/src/factory/Convert.cpp b/src/factory/Convert.cpp index dfdc5dc..649ec1a 100644 --- a/src/factory/Convert.cpp +++ b/src/factory/Convert.cpp @@ -52,9 +52,6 @@ void Convert::getString(string *buf,PVField const *pvField,int /*indentLevel*/) std::ostringstream strm; pvField->dumpValue(strm); strm << std::endl; -// PrinterPlain p; -// p.setStream(strm); -// p.print(*pvField); strm.str().swap(*buf); } diff --git a/src/factory/printer.cpp b/src/factory/printer.cpp index b225d80..7ddba8f 100644 --- a/src/factory/printer.cpp +++ b/src/factory/printer.cpp @@ -8,20 +8,10 @@ #include #define epicsExportSharedSymbols -#include +#include using std::string; -namespace { - -void indentN(std::ostream& strm, size_t N) -{ - while(N--) - strm.put(' '); -} - -} - namespace epics { namespace pvData { namespace format @@ -52,246 +42,4 @@ namespace format } }; -PrinterBase::PrinterBase() - :strm(NULL) -{} - -PrinterBase::~PrinterBase() {} - -void PrinterBase::setStream(std::ostream& s) -{ - strm = &s; -} - -void PrinterBase::clearStream() -{ - strm = NULL; -} - -void PrinterBase::print(const PVField& pv) -{ - if(!strm) - throw std::runtime_error("No stream set for PV Printer"); - impl_print(pv); -} - -void PrinterBase::beginStructure(const PVStructure&) {} -void PrinterBase::endStructure(const PVStructure&) {} - -void PrinterBase::beginStructureArray(const PVStructureArray&) {} -void PrinterBase::endStructureArray(const PVStructureArray&) {} - -void PrinterBase::beginUnion(const PVUnion&) {} -void PrinterBase::endUnion(const PVUnion&) {} - -void PrinterBase::beginUnionArray(const PVUnionArray&) {} -void PrinterBase::endUnionArray(const PVUnionArray&) {} - -void PrinterBase::encodeScalar(const PVScalar&) {} - -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. - * As the tree is walked structures and structarrays - * are appended to the inprog queue. - */ - std::deque todo, inprog; - - todo.push_back(&pv); - - while(!todo.empty()) { - const PVField *next = todo.front(); - todo.pop_front(); - - if(next==marker) { - // finished with a structure or structarray, - // now we fall back to its parent. - assert(!inprog.empty()); - switch(inprog.back()->getField()->getType()) { - case structure: - endStructure(*static_cast(inprog.back())); - break; - - case structureArray: - endStructureArray(*static_cast(inprog.back())); - break; - - case union_: - endUnion(*static_cast(inprog.back())); - break; - - case unionArray: - endUnionArray(*static_cast(inprog.back())); - break; - - default: - assert(false); // oops! - return; - } - inprog.pop_back(); - - } else { - // real field - - if(!next) { - // NULL entry in a structure array - encodeNull(); - continue; - } - - switch(next->getField()->getType()) { - case scalar: - encodeScalar(*static_cast(next)); - break; - case scalarArray: - encodeArray(*static_cast(next)); - break; - case structure: { - const PVStructure &fld = *static_cast(next); - const PVFieldPtrArray& vals = fld.getPVFields(); - - inprog.push_back(next); - - beginStructure(fld); - for(size_t i=0, nfld=fld.getStructure()->getNumberFields(); i(next); - PVStructureArray::const_svector vals(fld.view()); - - inprog.push_back(next); - - beginStructureArray(fld); - for(PVStructureArray::const_svector::const_iterator it=vals.begin(); - it!=vals.end(); ++it) - { - todo.push_back(it->get()); - } - - todo.push_back(marker); - break; - } - case union_: { - const PVUnion &fld = *static_cast(next); - - inprog.push_back(next); - - beginUnion(fld); - PVFieldPtr val = fld.get(); - if (val.get()) // TODO print "(none)" ? - todo.push_back(val.get()); - - todo.push_back(marker); - break; - } - case unionArray: { - const PVUnionArray &fld = *static_cast(next); - PVUnionArray::const_svector vals(fld.view()); - - inprog.push_back(next); - - beginUnionArray(fld); - for(PVUnionArray::const_svector::const_iterator it=vals.begin(); - it!=vals.end(); ++it) - { - todo.push_back(it->get()); - } - - todo.push_back(marker); - break; - } - } - } - } -} - - -PrinterPlain::PrinterPlain() - :PrinterBase() - ,ilvl(0) -{} - -PrinterPlain::~PrinterPlain() {} - -void PrinterPlain::beginStructure(const PVStructure& pv) -{ - indentN(S(), ilvl); - S() << pv.getStructure()->getID() << " " << pv.getFieldName(); - S() << std::endl; - ilvl++; -} - -void PrinterPlain::endStructure(const PVStructure&) {ilvl--;} - -void PrinterPlain::beginStructureArray(const PVStructureArray& pv) -{ - indentN(S(), ilvl); - S() << pv.getStructureArray()->getID() << " " - << pv.getFieldName() << "[] "; - ilvl++; -} - -void PrinterPlain::endStructureArray(const PVStructureArray&) {ilvl--;} - -void PrinterPlain::beginUnion(const PVUnion& pv) -{ - indentN(S(), ilvl); - S() << pv.getUnion()->getID() << " " << pv.getFieldName() << std::endl; - ilvl++; -} - -void PrinterPlain::endUnion(const PVUnion&) {ilvl--;} - -void PrinterPlain::beginUnionArray(const PVUnionArray& pv) -{ - indentN(S(), ilvl); - S() << pv.getUnionArray()->getID() << " " - << pv.getFieldName() << "[] "; - ilvl++; -} - -void PrinterPlain::endUnionArray(const PVUnionArray&) {ilvl--;} - -void PrinterPlain::encodeScalar(const PVScalar& pv) -{ - indentN(S(), ilvl); - S() << pv.getScalar()->getID() << " " - << pv.getFieldName() << " " - << pv.getAs() << std::endl; -} - -void PrinterPlain::encodeArray(const PVScalarArray& pv) -{ - indentN(S(), ilvl); - shared_vector temp; - pv.getAs(temp); - - S() << pv.getScalarArray()->getID() << " " - << pv.getFieldName() << " ["; - for(size_t i=0, len=pv.getLength(); i -#include - -#include "pvData.h" - -namespace epics { namespace pvData { - -class PrinterBase -{ -public: - virtual void setStream(std::ostream&); - virtual void clearStream(); - - virtual void print(const PVField&); - -protected: - PrinterBase(); - virtual ~PrinterBase()=0; - - virtual void beginStructure(const PVStructure&); - virtual void endStructure(const PVStructure&); - - virtual void beginStructureArray(const PVStructureArray&); - virtual void endStructureArray(const PVStructureArray&); - - virtual void beginUnion(const PVUnion&); - virtual void endUnion(const PVUnion&); - - virtual void beginUnionArray(const PVUnionArray&); - virtual void endUnionArray(const PVUnionArray&); - - virtual void encodeScalar(const PVScalar&); - virtual void encodeArray(const PVScalarArray&); - virtual void encodeNull(); - - inline std::ostream& S() { return *strm; } - - void impl_print(const PVField&); -private: - std::ostream *strm; -}; - -class PrinterPlain : public PrinterBase -{ - size_t ilvl; -protected: - virtual void beginStructure(const PVStructure&); - virtual void endStructure(const PVStructure&); - - virtual void beginStructureArray(const PVStructureArray&); - virtual void endStructureArray(const PVStructureArray&); - - virtual void beginUnion(const PVUnion&); - virtual void endUnion(const PVUnion&); - - virtual void beginUnionArray(const PVUnionArray&); - virtual void endUnionArray(const PVUnionArray&); - - virtual void encodeScalar(const PVScalar&); - virtual void encodeArray(const PVScalarArray&); - virtual void encodeNull(); - -public: - PrinterPlain(); - virtual ~PrinterPlain(); -}; - -}} - -#endif // PRINTER_H