OTL 4.0, OTL Long String, Long Unicode String  classes

OTL Long String, Long Unicode String classes

These classes are used in operations with Large Objects (LOB). In OTL 4.0, otl_long_string can hold a LOB of any type as well as RAW / BINARY:
otl_long_unicode_string is specialized for Unicode character based large strings. otl_long_unicode_string can hold the following data types: In the case if Unicode OTL is enabled by #define OTL_UNICODE, otl_long_string needs to be used for Oracle LONG RAWs, BLOBs, MS SQL IMAGEs, DB2 BLOBs, etc (large binary strings, generally speaking), because they still remain the large byte strings, without any character semantic attached.

OTL 4.0 defines the following bind variable data types for manipulating LOBs:

Large Objects (LOBs) and NULLs

Behavior of LOBs is slightly different from the other table column data types as far as NULLs are concerned:
class otl_long_string{
public:
Function / data member
Description
unsigned char* v;
Pointer to the LOB value. In other words, the field is a pointer to the LOB buffer.
otl_long_string(...);

Parameter

Description
const int buffer_size=32760 It defines the size of the LOB buffer. By default, the size is 32760.
const int input_length=0 It defines the actual length of the string on the input. If this parameter is used, then the set_len() function does not need to be called.

General constructor. It creates an otl_long_string instance: allocates memory for the LOB buffer and sets internal variables. In addition to setting the size of otl_long_string, the otl_connect::set_max_long_size() needs to be called with the same or a greater size.
otl_long_string(...);
Parameter
Description

const void* external_buffer

Pointer to an external buffer
const int buffer_size Buffer size defines the size of the external buffer for the otl_long_string.
const int input_length=0 Input length is the actual length of the string on the input. If this parameter is used, then there is no need to call the set_len() function.

General constructor. It creates an otl_long_string instance: it sets the v field to the value of external_buffer and sets internal variables. In case if this constructor is called, memory for the LOB buffer is not allocated, the address of an external buffer is used instead. This constructor is provided for more efficient manipulation of LOBs. If it is critical for performance or memory reasons, this constructor can be used for passing the address of a user defined buffer into the otl_stream operations with LOBs.
void set_len(const int len=0);
This function sets the dynamic length of the LOB. The function needs to be called before writing the LOB into the otl_stream.
void set_last_piece
(const bool last_piece=false);
When an otl_long_string is used with an otl_lob_stream and OTL/OCI8i/9i/10g/11g, this function indicates that the otl_string_string is the last piece / chunk in a sequence of LOB chunks being written into the otl_lob_stream. The function exists for OTL/ODBC/DB2-CLI but it does not have any effect.
int len();
This function returns the dynamic length of the LOB. The function needs to be called after reading the LOB from the otl_stream
unsigned char& operator[](int ndx);

const unsigned char& operator[](int ndx) const;
These operators allow the user to access individual bytes of the LOB.
otl_long_string& operator=
(const otl_long_string&);
Assignment operator
otl_long_string
(const otl_long_string&);
Copy constructor
}; // end of otl_long_string

class otl_long_unicode_string: public otl_long_string{
public:
Function / data member
Description
otl_long_unicode_string(...);
Parameter
Description
const int buffer_size=32760 defines the size of the LOB buffer.
const int input_length=0 defines the actual length of the string on the input. If this parameter is used, then the set_len() function does not need to be called.

General constructor. It creates an otl_long_unicode_string instance: allocates memory for the LOB buffer and sets internal variables.  By default, the size is 32760 Unicode characters. In addition to setting the size of otl_long_unicode_string, the otl_connect::set_max_long_size() needs to be called with the same or a greater size.Note: all sizes for Unicode strings are given not in bytes but in Unicode characters (2 bytes per character times 2 to accommodate a possible surrogate character).
otl_long_unicode_string(...);
Parameter
Description
const void* external_buffer Pointer to the external buffer
const int buffer_size defines the size of the external buffer for the otl_long_unicode_string.
const int input_length=0 the actual length of the string on the input. If this parameter is used, then there is no need to call the set_len() function.

General constructor. It creates an otl_long_unicode_string instance: it saves the value of external_buffer and sets internal variables. In case if this constructor is called, memory for the LOB buffer is not allocated, the address of an external buffer is used instead. This constructor is provided for more efficient manipulation of LOBs. If it is critical for performance or memory reasons, this constructor can be used for passing the address of a user defined buffer into the otl_stream operations with LOBs.
void set_len(const int len=0);
This function sets the dynamic length of the LOB in Unicode characters (2 bytes per each). The function needs to called before writing the LOB into the otl_stream
int len(void);
This function returns the dynimac length of the LOB in Unicode characters (2 bytes per character). The function needs to be called after reading the LOB from the otl_stream
unsigned short& operator[](int ndx);

const unsigned short& operator[](int ndx) const;
These operators allow the user to access individual Unicode characters of the LOB.
otl_long_unicode_string& operator=
(const otl_long_unicode_string&);
Assignment operator
otl_long_unicode_string
(const otl_long_unicode_string&);
Copy constructor

}; // end of otl_long_unicode_string

Prev NextContentsGo Home

Copyright © 1996-2023, Sergei Kuchin, email: skuchin@gmail.com, skuchin@gmail.com .

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.