Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/factory/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,36 @@ std::ostream& operator<<(std::ostream& strm, const PVStructure::Formatter& forma
return strm;

case scalarArray:
{
strm<<format::indent();
printTimeT(strm, format.xtop);
printAlarmT(strm, format.xtop);
strm<<std::setprecision(6)<<*static_cast<const PVScalarArray*>(value.get())<<'\n';
return strm;

const PVScalarArray* pvArray = static_cast<const PVScalarArray*>(value.get());
ScalarArrayConstPtr scalarArray = pvArray->getScalarArray();

// Stringify byte arrays if requested
if (format.xstring && scalarArray && scalarArray->getElementType() == pvByte) {
shared_vector<const int8_t> byteArray;
pvArray->getAs(byteArray);

const char* str = reinterpret_cast<const char*>(byteArray.data());
const size_t slen = strlen(str);

const size_t buflen = epicsStrnEscapedFromRawSize(str, slen);

char* buf = new char[buflen+1] {};
epicsStrnEscapedFromRaw(buf, buflen+1, str, slen);

strm<<buf;
delete [] buf;
} else {
strm<<std::setprecision(6);
strm<<*pvArray;
}
strm<<'\n';
return strm;
}
case structure:
if(printEnumT(strm, format.xtop, true)) {
strm<<'\n';
Expand Down
4 changes: 4 additions & 0 deletions src/pv/pvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -888,13 +888,15 @@ class epicsShareClass PVStructure : public PVField, public BitSetSerializable
const BitSet* xhighlight;
mode_t xmode;
format_t xfmt;
bool xstring;
public:
explicit Formatter(const PVStructure& top)
:xtop(top)
,xshow(0)
,xhighlight(0)
,xmode(Auto)
,xfmt(NT)
,xstring(false)
{}

// those fields (and their parents) to be printed. non-NT mode.
Expand All @@ -906,6 +908,8 @@ class epicsShareClass PVStructure : public PVField, public BitSetSerializable

FORCE_INLINE Formatter& format(format_t f) { xfmt = f; return *this; }

FORCE_INLINE Formatter& asString(bool b) { xstring = b; return *this; }

friend epicsShareFunc std::ostream& operator<<(std::ostream& strm, const Formatter& format);
friend void printRaw(std::ostream& strm, const PVStructure::Formatter& format, const PVStructure& cur);
};
Expand Down