json print/parse updates

These functions don't create new refs,
so they don't really need to work with shared_ptr.

Fully support printing.

Add option for maskable PVStructure printing.
This commit is contained in:
Michael Davidsaver
2018-09-18 06:45:50 -07:00
parent 5a59b1da75
commit aa87a2a23d
3 changed files with 127 additions and 27 deletions

View File

@@ -302,13 +302,17 @@ struct handler {
operator yajl_handle() { return handle; }
};
struct noop {
void operator()(pvd::PVField*) {}
};
} // namespace
namespace epics{namespace pvData{
epicsShareFunc
void parseJSON(std::istream& strm,
const PVField::shared_pointer& dest,
PVField& dest,
BitSet *assigned)
{
#ifndef EPICS_YAJL_VERSION
@@ -318,7 +322,12 @@ void parseJSON(std::istream& strm,
conf.checkUTF8 = 1;
#endif
context ctxt(dest, assigned);
// we won't create refs to 'dest' which presist beyond this call.
// however, it is convienent to treat 'dest' in the same manner as
// any union/structureArray memebers it may contain.
PVFieldPtr fakedest(&dest, noop());
context ctxt(fakedest, assigned);
#ifndef EPICS_YAJL_VERSION
handler handle(yajl_alloc(&jtree_cbs, &conf, NULL, &ctxt));
@@ -334,6 +343,7 @@ void parseJSON(std::istream& strm,
if(!ctxt.stack.empty())
throw std::logic_error("field stack not empty");
assert(fakedest.use_count()==1);
}
}} // namespace epics::pvData