QtCS2018 Serialisation

From Qt Wiki
Revision as of 11:15, 11 June 2018 by Thiago Macieira (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Serialisation

Binary JSON

  • Was created for qtjsondb
  • fast reading
  • mmap()able
  • Deprecate soon (Qt 5.12?)
    • Remove from QJsonDocument in Qt 6
    • Provide compat API to read
      • BSJON → JSON → parse again

QJsonDocument

  • Limited to 128 MB of RAM footprint (due to Binary JSON)
  • Needs to be fixed before Qt 6
  • Can use the same backend as QCborValue
  • Complaint: updating in-place is not easy
    • If you update an entry in a node, you have to update the chain leading to it
    • QCborValue has the same problem, as it was designed to have the same API
   QJsonValue foo = ...;
   foo["s"] = "value";             // does not compile
   foo.toObject()["s"] = "value";  // updates the temporary!
   
   // must write instead:
   QJsonObject fooObject = foo.toObject();
   fooObject["s"] = "value";
   setFoo(fooObject);

Common DOM API?

  • Should we have a common API for manipulating trees of JSON-like values?
  • QCborValue is a superset of QJsonValue
    • But it would be confusing to users to use CBOR classes to manipulate JSON
    • Generic name?
  • What other uses would this API have?
    • Replace QJSValue (QtQml)?
    • Replace QVariantMap?
    • Entry point for a Protobuf API?
  • How to make sure people can't insert combinations not allowed in the output?
    • For example, associative containers using integers as keys in JSON
    • Do they do that? Maybe they won't write such code
      • They know what their content is used for
    • We could use templates, specialising for CBOR, JSON, etc.
    • We could have a wrapper class that has inlines and provides only the possible combinations
  • QCborValue integrated last Friday into QtCore 5.12
    • Need to know in the next few weeks if we keep it for 5.12
    • Can yank it out and move to a new module for Tech Preview

Serialising Qt state

  • Needed by Qt Remote Objects
  • Slightly different from CBOR and JSON purposes
    • Not about a standardised representation of a data model
    • More about transmitting state from two independent processes of the same application
  • Currently using QDataStream
    • Has a lot of problems, can't really detect errors and not extensible enough
  • Need more exploration, no conclusion

Protobuf

  • Need volunteers to write a Proof of Concept
    • plugin to protoc?