HiBONRecord

HiBON Helper template to implement constructor and toHiBON member functions

mixin template HiBONRecord (
string CTOR = ""
) {}

Constructors

this
this(HiBON hibon)
Undocumented in source.
this
this(Document doc)
Undocumented in source.

Members

Aliases

check
alias check = Check!(HiBONRecordException)
Undocumented in source.
isRecord
alias isRecord = HiBONRecord.isRecord!ThisType
Undocumented in source.

Functions

serialize
immutable(ubyte[]) serialize()
Undocumented in source. Be warned that the author may not have intended to support it.
toDoc
const(Document) toDoc()
Undocumented in source. Be warned that the author may not have intended to support it.
toHiBON
inout(HiBON) toHiBON()
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

HAS_TYPE
enum HAS_TYPE;
Undocumented in source.
NO_DEFAULT_CTOR
enum NO_DEFAULT_CTOR;
Undocumented in source.
keys
enum keys;
Undocumented in source.

Mixins

__anonymous
mixin JSONString
Undocumented in source.
__anonymous
mixin HiBONRecordType
Undocumented in source.

Static functions

_keys
string[] _keys()
less_than
bool less_than(Key a, Key b)
Undocumented in source. Be warned that the author may not have intended to support it.

Templates

GetKeyName
template GetKeyName(uint i)
Undocumented in source.

Mixed In Members

From mixin JSONString

toString
void toString(void delegate(scope const(char)[]) @(safe) sink, FormatSpec!char fmt)
Undocumented in source. Be warned that the author may not have intended to support it.

From mixin HiBONRecordType

ThisType
alias ThisType = typeof(this)
Undocumented in source.
record_types
alias record_types = getUDAs!(ThisType, recordType)
Undocumented in source.
type_name
enum type_name;
Undocumented in source.
isRecord
alias isRecord = isRecordT!ThisType
Undocumented in source.
isRecord
bool isRecord(Document doc)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

@recodeType("TEST") // Set the HiBONRecord type name
 struct Test {
 @label("$X") uint x;     // The member in HiBON is "$X"
 string name;             // The member in HiBON is "name"
 @label("num") int num;   // The member in HiBON is "num" and is optional
 @optional  string text;  // optional hibon member 
 @exclude bool dummy;   // This parameter is not included in the HiBON
 }

CTOR = is used for constructor

struct TestCtor {
uint x;
HiBONRecord!("TEST2",
q{
this(uint x) {
this.x=x;
}
}
);
}
 /// Reseved keys and types

{ /// Check for reseved HiBON types
        @recordType("$@")
        static struct S {
            int x;
            mixin HiBONRecord;
        }

        S s;
        const doc = s.toDoc;
        assert(doc.valid is Document.Element.ErrorCode.RESERVED_HIBON_TYPE);
    }
    { /// Check for reseved keys 
        static struct S {
            @label("$@x") int x;
            mixin HiBONRecord;
        }

        S s;
        const doc = s.toDoc;
        assert(doc.valid is Document.Element.ErrorCode.RESERVED_KEY);
    }

Meta