Encoder class
The encoder class implements the CBOR encoder functionality as defined in RFC7049. This class is intended for single CBOR entity encoding, indefinite sequences and simple lists and maps
For specific more complex encoding such as for specialised lists and maps that contain raw byte sequences, tag values etc. use the builder classes.
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addBuilderOutput(
Uint8Buffer buffer) → void - Add the output of a builder to the encoding stream.
-
clear(
) → void - Clears the output buffer.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullBuilderHook(
bool validAsMapKey, dynamic keyValue) → void -
startIndefinite(
int majorType) → void - Indefinite item start.
-
strToByteString(
String str) → Uint8Buffer - String to byte string helper.
-
toString(
) → String -
A string representation of this object.
inherited
-
writeArray(
List value, [bool indefinite = false, int? length]) → bool - Array primitive. Valid elements are string, integer, bool, float(any size), array or map. Returns true if the encoding has been successful. If you supply a length this will be used and not calculated from the array size, unless you are encoding certain indefinite sequences you do not need to do this.
-
writeArrayImpl(
List value, [bool indefinite = false, int? length]) → bool - Array write implementation method. If the array cannot be fully encoded no encoding occurs, ie false is returned.
-
writeBase16(
Uint8Buffer data) → void - Tag based Base16 byte string encoding. The encoder does not itself perform the base encoding as stated in RFC7049, it just indicates to the decoder that the following byte string maybe base encoded.
-
writeBase64(
Uint8Buffer data) → void - Tag based Base64 byte string encoding. The encoder does not itself perform the base encoding as stated in RFC7049, it just indicates to the decoder that the following byte string maybe base encoded.
-
writeBase64URL(
Uint8Buffer data) → void - Tag based Base64 URL byte string encoding. The encoder does not itself perform the base encoding as stated in RFC7049, it just indicates to the decoder that the following byte string maybe base encoded.
-
writeBignum(
BigInt value) → void -
writeBool(
bool value) → void - Booleans.
-
writeBreak(
) → void - Indefinite item break primitive.
-
writeBuff(
Uint8Buffer data, [bool indefinite = false]) → void - Byte string primitive.
-
writeBytes(
Uint8Buffer data) → void - Primitive byte writer.
-
writeCborDi(
Uint8Buffer data) → void - Cbor data item encoder, refer to the RFC for details.
-
writeDateTime(
String dt) → void - Tag based Date/Time encoding. Standard format as described in RFC339 et al.
-
writeDouble(
double value) → void - Double precision float.
-
writeEpoch(
num epoch, [encodeFloatAs floatType = encodeFloatAs.single]) → void - Tag based epoch encoding. Format can be a positive or negative integer or a floating point number for which you can chose the encoding.
-
writeFloat(
double value) → void - Generalised float encoder, picks the smallest encoding it can. If you want a specific precision use the more specialised methods. Note this can lead to encodings you may not expect in corner cases, if you want specific sized encodings don't use this.
-
writeHalf(
double value) → void - Half precision float.
-
writeInt(
int value) → void - Positive and negative integers. If the value is too large to be encoded as an integer it is automatically converted to and encoded as a big num
-
writeMap(
Map value, [bool indefinite = false, int? length]) → bool - Map primitive. Valid map keys are integer and string. RFC7049 recommends keys be of a single type, we are more generous here. Valid map values are integer, string, bool, float(any size), array map or buffer. Returns true if the encoding has been successful.
-
writeMapImpl(
Map value, [bool indefinite = false, int? length]) → bool - Map write implementation method. If the map cannot be fully encoded no encoding occurs, ie false is returned.
-
writeMimeMessage(
String message) → void - Tag based MIME message writer. Note this method does not attempt to validate the MIME message supplied.
-
writeNull(
) → void - Null writer.
-
writeRawBuffer(
Uint8Buffer buff) → void - Raw byte buffer writer. No encoding is added to the buffer, it goes into the output stream as is.
-
writeRegEx(
String regex) → void - Tag based Regex writer. Note this method does not attempt to validate the RegEx expression supplied.
-
writeSimple(
int value) → void - Simple values, negative values, values over 255 or less than 0 will be encoded as an int.
-
writeSingle(
double value) → void - Single precision float.
-
writeSpecial(
int special) → void - Special(major type 7) primitive.
-
writeString(
String str, [bool indefinite = false]) → void - Primitive string writer.
-
writeTag(
int tag) → void - Tag primitive.
-
writeUndefined(
) → void - Undefined writer.
-
writeURI(
String uri) → void - Tag based URI writer
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited