KEqVCodec class final
A Codec for handling simpliest file data format: key=value
.
The name of keys must be an alphanumeric String with space,
$
and _
. Any invalid characters found causes throwing
ArgumentError.
This is an example of the data format:
foo=bar
baz=
bob = male
alice= female
number = 3
esc_num = "3"
is_dart =true
KEqVCodec will be recognized the key and value field with trimmed String. Then, it will convert to num, bool, String and Null depending on which values will be convert to String with character escape staregy from JSON. Therefore, the given Map's values must satisified those four primitive type of Dart or throw InvalidValueTypeError when encode.
During decode, it expects that every lines contain at least one equal sign, which the first one will be used to identify key and value. A valid satement must contains name of key, equal symbol and value (optional) in a sequence. If incompleted statements existed, it throws FormatException.
Constructors
- KEqVCodec({Quoting quoting = Quoting.doubleQuote, int keySpacing = 1, int valueSpacing = 1})
-
Create KEqVCodec instance and specified preferences during encode.
factory
- KEqVCodec.noSpacing({Quoting quoting = Quoting.doubleQuote})
-
Create KEqVCodec that no spacing applied.
const
- KEqVCodec.symmetricSpacing({Quoting quoting = Quoting.doubleQuote, int spacing = 1})
-
Apply same
spacing
surrounded by equal sign when encode.factory
Properties
-
decoder
→ Converter<
String, Map< String, dynamic> > -
Returns the decoder of
this
, converting fromT
toS
.no setteroverride -
encoder
→ Converter<
Map< String, dynamic> , String> -
Returns the encoder from
S
toT
.no setteroverride - hashCode → int
-
The hash code for this object.
no setterinherited
-
inverted
→ Codec<
String, Map< String, dynamic> > -
Inverts
this
.no setterinherited - keySpacing → int
-
Define spacing between key and equal sign.
final
- quoting → Quoting
-
Apply quoting symbol to prevent String value parsed to
another type.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valueSpacing → int
-
Define spacing between equal sign and value.
final
Methods
-
decode(
String encoded) → Map< String, dynamic> -
Decodes
encoded
data.inherited -
encode(
Map< String, dynamic> input) → String -
Encodes
input
.inherited -
fuse<
R> (Codec< String, R> other) → Codec<Map< String, dynamic> , R> -
Fuses
this
withother
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
binarizer(
Encoding encoding, {Compressor? compressor, Quoting quoting = Quoting.doubleQuote, int keySpacing = 1, int valueSpacing = 1}) → KEqVBinarizer - fuse from String to byte with provided Encoding.