writeStringHeader method

void writeStringHeader(
  1. int byteCount
)

Implementation

void writeStringHeader(int byteCount) {
  // When we write the header, we'll ask for all the space we need for the payload as well
  // as that may help ensure we only allocate a buffer once.
  if (byteCount <= MessagePackRange.maxFixStringLength) {
    _bytesBuilder.addByte(MessagePackCode.minFixStr | byteCount);
  } else if (byteCount <= _maxUint8) {
    _bytesBuilder.add(<int>[MessagePackCode.str8, byteCount]);
  } else if (byteCount <= _maxUint16) {
    _bytesBuilder.addByte(MessagePackCode.str16);
    _writeBigEndianShort(byteCount);
  } else {
    _bytesBuilder.addByte(MessagePackCode.str32);
    _writeBigEndianInt(byteCount);
  }
}