cbor

Members

Classes

CborException
class CborException
Undocumented in source.

Enums

CborTokenType
enum CborTokenType

Functions

assertEqual
void assertEqual(A a, B b)
Undocumented in source. Be warned that the author may not have intended to support it.
assertHexAndClear
void assertHexAndClear(string hex)
Undocumented in source. Be warned that the author may not have intended to support it.
assertToken
void assertToken(CborToken expected)
Undocumented in source. Be warned that the author may not have intended to support it.
assertf
void assertf(bool condition, string formatStr, Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
decodeCbor
void decodeCbor(R input, T outValue)
Undocumented in source. Be warned that the author may not have intended to support it.
decodeCborSingle
T decodeCborSingle(R input)

Decodes single cbor value and tries to convert it to requested type. If types don't match CborException is thrown. Note, that ubyte[] and string types are slices of input range if ubyte[] was provided. Will consume input range, decoding all the elements of T.

decodeCborSingleDup
T decodeCborSingleDup(R input)

Decodes single cbor value and tries to convert it to requested type. If types don't match CborException is thrown. Note, that this version will dup all array slices for you. Will consume input range, decoding all the elements of T.

decodeCborToken
CborToken decodeCborToken(R input)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCbor
size_t encodeCbor(R sink, E value)

Encodes value E into output range sink. Returns number of bytes written to sink. If flatten flag is yes then static arrays and structs will be encoded in place without headers.

encodeCborAggregate
size_t encodeCborAggregate(R sink, A aggregate)

Encodes classes and structs. If withFieldName is yes, than value is encoded as map. If withFieldName is no, then value is encoded as an array. If flatten flag is yes then static arrays and structs will be encoded in place without headers.

encodeCborArray
size_t encodeCborArray(R sink, E value)

Encodes array of any items or a tuple as cbor array.

encodeCborArray
size_t encodeCborArray(R sink, A aggregate)

Encodes structs and classes as cbor array.

encodeCborArrayHeader
size_t encodeCborArrayHeader(R sink, ulong arrayLength)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborArrayHeader
size_t encodeCborArrayHeader(R sink)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborBool
size_t encodeCborBool(R sink, E value)

Encodes boolean.

encodeCborBreak
size_t encodeCborBreak(R sink)

Encodes break. Use after all items of indefinite-length sequence were encoded.

encodeCborBytes
size_t encodeCborBytes(R sink, E value)

Encodes range of ubytes.

encodeCborBytesHeader
size_t encodeCborBytesHeader(R sink, ulong bytesLength)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborBytesHeader
size_t encodeCborBytesHeader(R sink)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborBytesItems
size_t encodeCborBytesItems(R sink, D bytes)

Writes range of ubyte to the sink. Needs to go after a call to encodeCborBytesHeader. The length of supplied range must be equal to one provided to encodeCborBytesHeader.

encodeCborFloat
size_t encodeCborFloat(R sink, E value)

Encodes floating.

encodeCborInt
size_t encodeCborInt(R sink, E value)

Encodes integer.

encodeCborMap
size_t encodeCborMap(R sink, E value)

Encodes asociative array as cbor map.

encodeCborMap
size_t encodeCborMap(R sink, A aggregate)

Encodes structs and classes as cbor map. Note, that decoding of structs and classes from maps is not supported (yet).

encodeCborMapHeader
size_t encodeCborMapHeader(R sink, ulong mapLength)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborMapHeader
size_t encodeCborMapHeader(R sink)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborNull
size_t encodeCborNull(R sink)

Encodes null.

encodeCborSimple
size_t encodeCborSimple(R sink, ubyte simple)

Encodes simple. Simple data type is essentially a number that has special meaning. Value must lie in range [0..23] or [32..255].

encodeCborString
size_t encodeCborString(R sink, E value)

Encodes string.

encodeCborStringHeader
size_t encodeCborStringHeader(R sink, ulong textLength)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborStringHeader
size_t encodeCborStringHeader(R sink)
Undocumented in source. Be warned that the author may not have intended to support it.
encodeCborTag
size_t encodeCborTag(R sink, ulong value)
encodeCborUndefined
size_t encodeCborUndefined(R sink)

Encodes undefined.

getTokenAndReset
CborToken getTokenAndReset()
Undocumented in source. Be warned that the author may not have intended to support it.
printBufferAndReset
void printBufferAndReset()
Undocumented in source. Be warned that the author may not have intended to support it.
printCborStream
void printCborStream(R input)
void printCborStream(R input, Sink sink, ulong numItems, string indent)

Outputs textual representation of cbor stream into sink or stdout if not provided.

readBytes
ubyte[] readBytes(R input, ulong length)
Undocumented in source. Be warned that the author may not have intended to support it.

Imports

Flag (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.
No (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.
Yes (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.

Structs

CborToken
struct CborToken

Templates

numEncodableMembers
template numEncodableMembers(alias T)

Returns a number of aggregate members that will be encoded by cbor-d.

Variables

testBuf
Appender!(ubyte[]) testBuf;
Undocumented in source.

Meta

Standards

Conforms to RFC 7049.

Authors

Andrey Penechko.

Concise Binary Object Representation (CBOR) for D lang.

The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.