IccBuf constructors

There are several forms of the IccBuf constructor, used when creating IccBuf objects.

Some examples are shown here.
IccBuf buffer;
This creates an 'internal' and 'extensible' data area that has an initial length of zero. When data is assigned to the object the data area length is automatically extended to accommodate the data being assigned.
IccBuf buffer(50);
This creates an 'internal' and 'extensible' data area that has an initial length of 50 bytes. The data length is zero until data is assigned to the object. If 50 bytes of data are assigned to the object, both the data length and the data area length return a value of 50. When more than 50 bytes of data are assigned into the object, the data area length is automatically (that is, without further intervention) extended to accommodate the data.
IccBuf buffer(50, IccBuf::fixed);
This creates an 'internal' and 'fixed' data area that has a length of 50 bytes. If an attempt is made to assign more than 50 bytes of data into the object, the data is truncated and an exception is thrown to notify the application of the error situation.
struct MyRecordStruct
{
short id;
short code;
char data(30);
char rating;
};
MyRecordStruct myRecord;
IccBuf buffer(sizeof(MyRecordStruct), &myRecord);
This creates an IccBuf object that uses an 'external' data area called myRecord. By definition, an 'external' data area is also 'fixed'. Data can be assigned using the methods on the IccBuf object or using the myRecord structure directly.
IccBuf buffer("Hello World");
This creates an 'internal' and 'extensible' data area that has a length equal to the length of the string "Hello World". The string is copied into the object's data area. This initial data assignment can then be changed using one of the manipulation methods (such as insert , cut , or replace ) provided.
IccBuf buffer("Hello World");
buffer << " out there";
IccBuf buffer2(buffer);

Here the copy constructor creates the second buffer with almost the same attributes as the first; the exception is the data area ownership attribute – the second object always contains an 'internal' data area that is a copy of the data area in the first. In the given example buffer2 contains "Hello World out there" and has both data area length and data length of 21.



hbfr004.html | Timestamp icon Last updated: Monday, 5 June 2017