std1.0.0-beta-7 SafeC docs

std :: serial::value

Trait std::Format

#include <std/serial/value.h> source

trait Format {
    void write(const &Value v, &String out) const;
    struct Value parse(const &char text, ?&int ok) const;
}

A text format for Value trees. Each backend is a small struct whose methods are the format's writer and parser: Json (json.h), Yaml (yaml.h), Csv (csv.h), Xml (xml.h; carries the root element's tag) and Html (html.h). Value::encode / Value::decode take any of them, and so does generic code bounded by Format:

struct String text = v.encode(Json::new());
struct Value back = Value::decode(Xml::new("doc"), text.as_ptr(), &ok);

Required methods

§void write(const &Value v, &String out) constsource

appends v's text to out

§struct Value parse(const &char text, ?&int ok) constsource

*ok: 1, or 0 on malformed input