Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
asdf.asdf
ASDF Representation
Authors:
Ilya Yaroshenko
License:
MIT
- class
AsdfSerdeException: mir.serde.SerdeException; - Serde Exception
- size_t
location; - zero based faulty location
- pure nothrow @nogc @safe this(string
msg, size_tlocation, stringfile= __FILE__, size_tline= __LINE__); - pure nothrow @nogc @safe this(string
msg, stringfile= __FILE__, size_tline= __LINE__, Throwablenext= null); - pure nothrow @nogc @safe this(string
msg, Throwablenext, stringfile= __FILE__, size_tline= __LINE__);
- class
InvalidAsdfException: mir.serde.SerdeException; -
- pure nothrow @safe this(uint
kind, stringfile= __FILE__, size_tline= __LINE__, Throwablenext= null); - pure nothrow @safe this(uint
kind, Throwablenext, stringfile= __FILE__, size_tline= __LINE__);
- class
EmptyAsdfException: mir.serde.SerdeException; -
- pure nothrow @nogc @safe this(string
msg= "ASDF value is empty", stringfile= __FILE__, size_tline= __LINE__, Throwablenext= null);
- struct
Asdf; - The structure for ASDF manipulation.
- enum
Kind: ubyte; -
null_true_false_numberstringarrayobject
- const pure @nogc @safe ubyte
kind(); - Returns ASDF Kind
- ubyte[]
data; - Plain ASDF data.
- pure nothrow @nogc @safe this(ubyte[]
data); - Creates ASDF using already allocated data
- pure @safe this(in char[]
str); - Creates ASDF from a stringExamples:
assert(Asdf("string") == "string"); assert(Asdf("string") != "String");
- pure nothrow @nogc @safe void
remove(); - Sets deleted bit onExamples:
import mir.conv: to; import asdf.jsonparser; auto asdfData = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`.parseJson; asdfData["inner", "d"].remove; assert(asdfData.to!string == `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","e":{}}}`);
- const void
toString(Dg)(scope Dgsink); - const pure nothrow @nogc @safe bool
opEquals(in Asdfrhs); - == operator overloads for nullExamples:
import asdf.jsonparser; auto asdfData = `null`.parseJson; assert(asdfData == asdfData);
- const pure nothrow @safe bool
opEquals(typeof(null)); - == operator overloads for nullExamples:
import asdf.jsonparser; auto asdfData = `null`.parseJson; assert(asdfData == null);
- const pure nothrow @safe bool
opEquals(boolboolean); - == operator overloads for boolExamples:
import asdf.jsonparser; auto asdfData = `true`.parseJson; assert(asdfData == true); assert(asdfData != false);
- const pure nothrow @trusted bool
opEquals(in char[]str); - == operator overloads for stringExamples:
import asdf.jsonparser; auto asdfData = `"str"`.parseJson; assert(asdfData == "str"); assert(asdfData != "stR");
- pure auto
byElement(); - Returns:input range composed of elements of an array.
- pure auto
byKeyValue(); - Returns:Input range composed of key-value pairs of an object. Elements are type of Tuple!(const(char)[], "key", Asdf, "value").
- pure Asdf
opIndex(in char[][]keys...); - Searches for a value recursively in an ASDF object.Parameters:
char[][] keyslist of keys keys Returns ASDF value if it was found (first win) or ASDF with empty plain data. Examples:import asdf.jsonparser; auto asdfData = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`.parseJson; assert(asdfData["inner", "a"] == true); assert(asdfData["inner", "b"] == false); assert(asdfData["inner", "c"] == "32323"); assert(asdfData["inner", "d"] == null); assert(asdfData["no", "such", "keys"] == Asdf.init);
- T
get(T)(Tdef); - Parameters:
T defdefault value. It is used when ASDF value equals Asdf.init. Returns:cast(T) this if this != Asdf.init anddefotherwise.Examples:import asdf.jsonparser; auto asdfData = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`.parseJson; assert(asdfData["inner", "a"].get(false) == true); assert(asdfData["inner", "b"].get(true) == false); assert(asdfData["inner", "c"].get(100) == 32323); assert(asdfData["no", "such", "keys"].get(100) == 100);
- T
opCast(T)(); - cast operator overloading.Examples:null
import std.math; import asdf.serialization; auto null_ = serializeToAsdf(null); interface I {} class C {} assert(cast(uint[]) null_ is null); assert(cast(uint[uint]) null_ is null); assert(cast(I) null_ is null); assert(cast(C) null_ is null); assert(isNaN(cast(double) null_)); assert(! cast(bool) null_);
Examples:booleanimport std.math; import asdf.serialization; auto true_ = serializeToAsdf(true); auto false_ = serializeToAsdf(false); static struct C { this(bool){} } auto a = cast(C) true_; auto b = cast(C) false_; assert(cast(bool) true_ == true); assert(cast(bool) false_ == false); assert(cast(uint) true_ == 1); assert(cast(uint) false_ == 0); assert(cast(double) true_ == 1); assert(cast(double) false_ == 0);
Examples:numbersimport std.bigint; import asdf.serialization; auto number = serializeToAsdf(1234); auto zero = serializeToAsdf(0); static struct C { this(in char[] numberString) { assert(numberString == "1234"); } } auto a = cast(C) number; assert(cast(bool) number == true); assert(cast(bool) zero == false); assert(cast(uint) number == 1234); assert(cast(double) number == 1234); assert(cast(BigInt) number == 1234); assert(cast(uint) zero == 0); assert(cast(double) zero == 0); assert(cast(BigInt) zero == 0);
Examples:stringimport std.bigint; import asdf.serialization; auto number = serializeToAsdf("1234"); auto false_ = serializeToAsdf("false"); auto bar = serializeToAsdf("bar"); auto zero = serializeToAsdf("0"); static struct C { this(in char[] str) { assert(str == "1234"); } } auto a = cast(C) number; assert(cast(string) number == "1234"); assert(cast(bool) number == true); assert(cast(bool) bar == true); assert(cast(bool) zero == false); assert(cast(bool) false_ == false); assert(cast(uint) number == 1234); assert(cast(double) number == 1234); assert(cast(BigInt) number == 1234); assert(cast(uint) zero == 0); assert(cast(double) zero == 0); assert(cast(BigInt) zero == 0);
Examples:For ASDF arrays and objects cast(T) just returns this.deserialize!T.import std.bigint; import asdf.serialization; assert(cast(int[]) serializeToAsdf([100, 20]) == [100, 20]);
Examples:UNIX Timeimport std.datetime; import asdf.serialization; auto num = serializeToAsdf(0.123456789); // rounding up to usecs assert(cast(DateTime) num == DateTime(1970, 1, 1)); assert(cast(SysTime) num == SysTime(DateTime(1970, 1, 1), usecs(123456), UTC())); // UTC time zone is used.
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Thu Mar 24 03:41:36 2022