Subject Re: [Firebird-Architect] Data Stream Encoding
Author Jim Starkey
Geoff Worboys wrote:

>On second thought you have presumably considered such schemes
>and discarded them for some reason. Still I think the code
>would be cleaner without such a huge enumeration.
Sure, there's method to my madness. Consider:

const UCHAR* EncodedDataStream::decode(UCHAR *ptr, Value *value)
const UCHAR *p = ptr;
UCHAR code = *p++;

case edsNull:

case edsIntMinus10:
case edsIntMinus9:
case edsInt30:
case edsInt31:
value->setValue((short) (code - edsInt0));

case edsUtf8Len0:
case edsUtf8Len1:
case edsUtf8Len38:
case edsUtf8Len39:
int len = code - edsUtf8Len0;
value->setString(len, (const char*) p, false);
p += len;

Yes, there are a huge number of a cases. But they fall into relatively
small number of classes, each is which can be handled with a small,
efficient piece of code.

In practice, an encoded data stream will always be prefaced by a version
number. At the expense of maintaining a variety of different historical
encodings, we can tweak the sizes of the various classes as we gain

[Non-text portions of this message have been removed]