Dart DocumentationbsonBsonCString

BsonCString class

class BsonCString extends BsonString{
 bool useKeyCash;
 int get typeByte{
  throw "Function typeByte of BsonCString must not be called";
 }
 BsonCString(String data, [this.useKeyCash = true]): super(data);
 List<int> get utfData{
   if (useKeyCash){
     return _Statics.getKeyUtf8(data);
   }
   else {
     return super.utfData;
   }
 }

 byteLength()=>utfData.length+1;
 packValue(BsonBinary buffer){
    buffer.byteList.setRange(buffer.offset,buffer.offset+utfData.length,utfData);
    buffer.offset += utfData.length;
    buffer.writeByte(0);
 }
}

Extends

BsonObject > BsonString > BsonCString

Constructors

new BsonCString(String data, [bool useKeyCash = true]) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
BsonCString(String data, [this.useKeyCash = true]): super(data);

Properties

String data #

inherited from BsonString
String data

final int typeByte #

int get typeByte{
throw "Function typeByte of BsonCString must not be called";
}

bool useKeyCash #

bool useKeyCash

final List<int> utfData #

List<int> get utfData{
 if (useKeyCash){
   return _Statics.getKeyUtf8(data);
 }
 else {
   return super.utfData;
 }
}

final value #

inherited from BsonString
get value=>data;

Methods

dynamic byteLength() #

byteLength()=>utfData.length+1;

dynamic packElement(String name, buffer) #

inherited from BsonObject
packElement(String name, var buffer){
 buffer.writeByte(typeByte);
 if (name != null){
   new BsonCString(name).packValue(buffer);
 }
 packValue(buffer);
}

dynamic packValue(BsonBinary buffer) #

packValue(BsonBinary buffer){
  buffer.byteList.setRange(buffer.offset,buffer.offset+utfData.length,utfData);
  buffer.offset += utfData.length;
  buffer.writeByte(0);
}

_ElementPair unpackElement(buffer) #

inherited from BsonObject
_ElementPair unpackElement(buffer){
 _ElementPair result = new _ElementPair();
 result.name = buffer.readCString();
 unpackValue(buffer);
 result.value = value;
 return result;
}

dynamic unpackValue(BsonBinary buffer) #

inherited from BsonString
unpackValue(BsonBinary buffer){
  int size = buffer.readInt32()-1;
  data = UTF8.decode(buffer.byteList.getRange(buffer.offset, buffer.offset+size).toList());
  buffer.offset += size+1;
}