/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include "dataimpl.h" namespace pvxs { namespace { struct FmtDelta { std::ostream& strm; const Value::Fmt& fmt; void field(const std::string& prefix, const Value& val, bool verytop) { if(verytop && !val.isMarked(false)) return; strm<as(); break; case StoreType::UInteger: strm<<" = "<as(); break; case StoreType::Bool: strm<<" = "<<(store->as() ? "true" : "false"); break; case StoreType::String: strm<<" = \""<as())<<"\""; break; case StoreType::Array: { auto& varr = store->as>(); if(varr.original_type()!=ArrayType::Value) { strm<<" = "<(); std::string cprefix(prefix); cprefix+="->"; if(val.type()==TypeCode::Union) { auto desc = Value::Helper::desc(val); auto udesc = Value::Helper::desc(uval); for(auto idx : range(desc->members.size())) { if(udesc == &desc->members[idx]) { cprefix+=desc->miter[idx].first; break; } } } top(cprefix, uval, false); } break; case TypeCode::StructA: case TypeCode::UnionA: case TypeCode::AnyA: { auto rawval = val.as>(); if(rawval.original_type()==ArrayType::Null) { } else if(rawval.original_type()==ArrayType::Value) { auto aval = rawval.castTo(); for(auto idx : range(aval.size())) { std::ostringstream strm; strm<() ? "true" : "false"); return; #define CASE(ENUM, TYPE) \ case TypeCode::ENUM : strm<(); return CASE(Int8, int8_t); CASE(Int16, int16_t); CASE(Int32, int32_t); CASE(Int64, int64_t); CASE(UInt8, uint8_t); CASE(UInt16, uint16_t); CASE(UInt32, uint32_t); CASE(UInt64, uint64_t); CASE(Float32, float); CASE(Float64, double); #undef CASE case TypeCode::String: strm<<"\""<())<<"\""; return; case TypeCode::BoolA: case TypeCode::Int8A: case TypeCode::Int16A: case TypeCode::Int32A: case TypeCode::Int64A: case TypeCode::UInt8A: case TypeCode::UInt16A: case TypeCode::UInt32A: case TypeCode::UInt64A: case TypeCode::Float32A: case TypeCode::Float64A: case TypeCode::StringA: { auto varr = fld.as>(); strm<(); if(!member.empty()) strm<<' '<top->desc) fld(store->top->desc, desc->members.data()); def = Value::Helper::build(fld); // not connection to fld (not parent) } strm<<" {"; bool first = true; { Indented I(strm); for(auto mem : def.ichildren()) { auto mname(def.nameOf(mem)); if(first) strm<<'\n'; strm<>()); strm<<" = {"<=fmt._limit) { strm<<"...\n"; break; } show(elem, std::string()); shown++; } } if(shown) strm<\n"; } return strm; } }