Main Table of Contents


Table of Contents

class PtBlob
PtBlob: class summary
PtBlob::PtBlob()
PtBlob::~PtBlob()
PtBlob::Append()
PtBlob::CopyFrom()
PtBlob::CopyTo()
PtBlob::Cut()
PtBlob::Expand()
PtBlob::Length()
PtBlob::Resize()
PtBlob::Search()
PtBlob::Seek()
PtBlob::SetTo()
PtBlob::operator = ()
PtBlob::operator += ()
PtBlob::operator == ()
PtBlob::operator != ()

class PtBlob


Intro
PtBlob: class summary
PtBlob::PtBlob()
PtBlob::~PtBlob()
PtBlob::Append()
PtBlob::CopyFrom()
PtBlob::CopyTo()
PtBlob::Cut()
PtBlob::Expand()
PtBlob::Length()
PtBlob::Resize()
PtBlob::Search()
PtBlob::Seek()
PtBlob::SetTo()
PtBlob::operator = ()
PtBlob::operator += ()
PtBlob::operator == ()
PtBlob::operator != ()

The term BLOB is an acronym for "Binary Large Object." A BLOB contains a series of bytes. BLOBs can contain any kind of data, and the size of a BLOB is limited only by RAM. BLOBs can be used to store scanned images, sound samples, word processing files, C++ source code, or just about anything else you want to have in the database. BLOBs can use up disk space fast. If you store a 10 meg image in your database then you will need 10 meg disk space. You might want to compress your data before storing it in a BLOB. POET does not compress the data for you because different kinds of data require different compression schemes. For instance, Lempel-Ziv-Welch compression is very effective for text strings, but almost useless for high quality grey scale images - however, it can be effective for lower quality grey scale images! (footnote #1) JPEG is very good for grey scale images, but can only be used when some data loss is permissable. Run length encoding schemes are useful for black/white scanned images, but not very helpful for strings. Because compression algorithms are highly content-specific we have decided not to try to implement a general purpose compression algorithm. Here is some code that writes data to a BLOB and reads it out again:

char str[] = "this is a text, this is only a text....";
PtBlob Blob;
int len = strlen(str) + 1;
Blob.SetTo(str, len); // fill it with some data
char *p;
p = Blob.Seek(0); // position 0 in the BLOB

This example is contrived. If your string is short enough you should usually store it in a PtString. A PtBlob is useful primarily for larger amounts of data.

If your programming environment does not use flat 32 bit addressing then PtBlob:: Seek() always returns a normalized pointer. You can safely access up to 64K - 16 bytes beyond this pointer under 16-bit Windows or DOS; you need to use huge data pointers if you want to access data blocks greater than 64 K, which is the maximum size for a data segment. The data for a PtBlob is always kept in a linear region in memory, so you can set a pointer to the start of a Blob and access the Blob's data using this pointer. However, you need to keep a few things in mind: DOS and 16-bit Windows systems will need to use huge pointers to access regions more than 64K-16 beyond a pointer.

If you change the data for a Blob directly through a pointer then the Blob's administrative structures are not updated. This is generally a no-no. Huge pointers are a portability problem since they exist only on Intel-based computers. You can declare huge pointers portably by using the constant PtHUGE, which is defined in bks.hxx. On Intel machines PtHUGE is defined as huge, on other machines it is defined as an empty string. This lets you make declarations like this:

char PtHUGE* p;

On a DOS or 16-bit Windows system this evaluates to:

char huge* p;

On any other system this evaluates to:

char * p;

footnote #1: This fact caused some amusing problems for a company that manufactured scanners for the desktop market. They used to use Lempel-Ziv-Welch to store scanned images. An early version of a scanner had poor grey level resolution, and the images compressed to 25% of the original size. A later version had much better grey level resolution, and the images compressed to 96% of the original size.


PtBlob: class summary


Intro

Files to include Class declaration Base class
poet.hxx ptblob.hxx none

Member functions:

constructor PtBlob();
destructor ~PtBlob();
Append PtBlob& Append(void* data, long Length);
CopyFrom PtBlob CopyFrom(long Start, long Length);
CopyTo PtBlob& CopyTo(PtBlob& Source, long Start, long Length);
Cut PtBlob& Cut(long Start, long Length);
Expand PtBlob& Expand(long Length);
Length long Length();
Resize void Resize(unsigned long NewSize);
Search long Search(PtBlob& blob);
Seek char* Seek(long Start, long Length);
SetTo PtBlob& SetTo(void* Data, long Length);
operator!= int operator != (PtBlob& ThatBlob);
operator+= PtBlob& operator += (PtBlob& NewStuff);
operator= PtBlob& operator = (const PtBlob& blob);
operator== int operator == (PtBlob& ThatBlob);

PtBlob::PtBlob()


Intro

Declaration:

PtBlob::PtBlob() PtBlob::PtBlob(PtBlob& Blob) PtBlob::PtBlob(void* Data, long Length) PtBlob::PtBlob(long Length )

Description:

Constructors. The exact semantics of the constructor depends on its parameters. The PtBlob object allocates its own memory for its contents.

Parameters:

PtBlob() Creates an empty BLOB
PtBlob(PtBlob& Blob) Copy constructor - creates a second BLOB with the same contents as the first one.
PtBlob(void* Data, long Length) Creates a BLOB which contains the first Length bytes of Data
PtBlob(long Length) Creates a BLOB with Length bytes of uninitialized data.

PtBlob::~PtBlob()


Intro

Declaration:

PtBlob::~PtBlob()

Description:

Destructor.


PtBlob::Append()


Intro

Declaration:

PtBlob& PtBlob::Append(void* data, long Length) PtBlob& PtBlob::Append(PtBlob blob)

Description:

Appends bytes to the BLOB. Returns the BLOB.


PtBlob::CopyFrom()


Intro

Declaration:

PtBlob PtBlob::CopyFrom(long Start, long Length)

Description:

Creates a new BLOB containing a range of bytes from the BLOB. Returns the new BLOB.


PtBlob::CopyTo()


Intro

Declaration:

PtBlob& PtBlob::CopyTo(PtBlob& Source, long Start, long Length)

Description:

Copies a range of bytes from the Source BLOB to this BLOB. If the BLOB is not large enough to hold the new data then it is truncated to the current length of the BLOB.

Returns the BLOB.


PtBlob::Cut()


Intro

Declaration:

PtBlob& PtBlob::Cut(long Start, long Length)

Description:

Cuts a range of bytes from the BLOB. Starting with offset Start, Length bytes are removed from the BLOB.

Returns the BLOB.


PtBlob::Expand()


Intro

Declaration:

PtBlob& PtBlob::Expand(long Length)

Description:

Increases the size of the BLOB. Returns the BLOB.


PtBlob::Length()


Intro

Declaration:

long PtBlob::Length()

Description:

Returns the current length of the BLOB.


PtBlob::Resize()


Intro

Declaration:

void PtBlob::Resize(unsigned long newSize)

Description:

Resize the BLOB to the given length .


PtBlob::Search()


Intro

Declaration:

long PtBlob::Search(PtBlob& Target)

Description:

Searches the BLOB for a range of bytes which exactly match the bytes found in Target.

Returns the offset at which this range of bytes is found, or -1 if it is not found.


PtBlob::Seek()


Intro

Declaration:

char* PtBlob::Seek(long Offset, long Length = 1)

Description:

Returns a pointer to the data starting at Offset in the BLOB. If the Offset is not within the Blob then Seek returns 0. You can check to make sure that the BLOB holds the bytes you intend to read by specifying Length. If Offset + Length exceeds the length of the BLOB then Seek returns 0.


PtBlob::SetTo()


Intro

Declaration:

PtBlob& PtBlob::SetTo(void* data, long Length)

Description:

Replaces the current contents of the BLOB with a range of bytes. Returns the BLOB.


PtBlob::operator = ()


Intro

Declaration:

PtBlob& PtBlob::operator = (PtBlob& Source)

Description:

Sets the contents of the BLOB to the contents of the Source. Returns the BLOB.


PtBlob::operator += ()


Intro

Declaration:

void PtBlob::operator += (PtBlob& NewBytes)

Description:

Appends the data from NewBytes to the current BLOB.


PtBlob::operator == ()


Intro

Declaration:

int PtBlob::operator == (PtBlob& ThatBlob)

Description:

Compares this BLOB to ThatBlob using a bit comparison. If every bit in this BLOB matches the corresponding bit of ThatBlob then the two BLOBS are considered identical.

Returns 0 if the two BLOBs differ, or a nonzero value if they are identical.


PtBlob::operator != ()


Intro

Declaration:

int PtBlob::operator != (PtBlob& ThatBlob)

Description:

Compares this BLOB to ThatBlob using a bit comparison. If any bit in this BLOB does not match the corresponding bit of ThatBlob then the two BLOBS are considered different.

Returns:

-1 this BLOB < ThatBlob
0 this BLOB == ThatBlob
1 this BLOB > ThatBlob

Copyright (c) 1996 POET Software, Inc. All rights reserved. Reproduction in whole or in part in any form or medium without the express permission of POET Software, Inc. is prohibited.