Table of Contents

Class TileCacheBlob

On-disk envelope around a tile payload: a magic and a format tag so the cache can store more than one encoding. The pipeline uses this; most apps never call it.

public static class TileCacheBlob
Inheritance
object
TileCacheBlob

Fields

HeaderSize

Header length in bytes: 4 of magic plus 4 of format.

public const int HeaderSize = 8

Field Value

int

Methods

TryParse(byte[], int, out Format, out int, out int)

Reads a header whose format tag this build knows. False for a legacy unwrapped record, a different magic, a truncated buffer, or a tag this build does not recognize.

public static bool TryParse(byte[] blob, int blobLength, out TileCacheBlob.Format format, out int payloadOffset, out int payloadLength)

Parameters

blob byte[]

Buffer that may start with this type's header.

blobLength int

Valid length of blob in bytes.

format TileCacheBlob.Format

Known format on success; default otherwise.

payloadOffset int

Byte index of the payload; HeaderSize on success.

payloadLength int

Payload length in bytes on success; 0 otherwise.

Returns

bool

True when the magic matches and the format tag is one of TileCacheBlob.Format.

TryParseHeader(byte[], int, out int, out int, out int)

Reads the magic and the raw format tag without requiring a known TileCacheBlob.Format. Use this when a caller-registered codec may own a tag this type does not list.

public static bool TryParseHeader(byte[] blob, int blobLength, out int rawFormat, out int payloadOffset, out int payloadLength)

Parameters

blob byte[]

Buffer that may start with this type's header.

blobLength int

Valid length of blob in bytes.

rawFormat int

Integer format tag from the header; 0 on failure.

payloadOffset int

Byte index of the payload; always HeaderSize.

payloadLength int

Payload length in bytes on success; 0 otherwise.

Returns

bool

True when the buffer is long enough, the magic matches, and the payload is non-empty.

Wrap(Format, byte[], int)

Copies payload behind a magic-and-format header.

public static byte[] Wrap(TileCacheBlob.Format format, byte[] payload, int length)

Parameters

format TileCacheBlob.Format

Encoding of the payload bytes.

payload byte[]

Source buffer; only the first length bytes are copied.

length int

Payload length in bytes.

Returns

byte[]

A new buffer of HeaderSize plus length bytes.