SqlData Class Reference

Encapsulates a buffer and SqlTypeMetadata* for SQL typed data. More...

Inherited by SqlFixedLengthType< TYPE >, SqlVarLengthAttachedType, and SqlVarLengthOwnedType.

List of all members.

Public Member Functions

virtual void AttachBuffer (simba_byte *in_buffer, simba_uint32 in_length)
 Attach an unowned buffer, replacing the owned buffer.
void Convert (SqlCData &in_from, IWarningListener *in_warningListener)
 Converts data from in_from into this object. This function only uses the deprecated global converter factory singleton.
virtual void * GetBuffer ()=0
 Returns the attached buffer.
simba_signed_native GetConvertedLength () const
 Based on the last Convert(), returns the amount of bytes that all of the converted data would have taken up without truncation, not including space for a possible null terminator.
simba_uint32 GetLength () const
 Returns length of the buffer in number of bytes.
const SqlTypeMetadataGetMetadata () const
 Retrieve the metadata associated with the SqlData.
SqlTypeMetadataGetMetadata ()
 Retrieve the metadata associated with the SqlData.
bool IsNull () const
 Indicates if the buffer should be treated as holding NULL data.
bool IsNullOrEmpty () const
 Indicates if the buffer holds NULL data or 0-length data.
void SetConvertedLength (simba_signed_native in_convertedLength)
 Set the converted length.
virtual void SetLength (simba_uint32 in_length)
 Sets the length of the buffer in number of bytes.
void SetNull (bool in_isNull)
 Indicates whether or not the buffer should be treated as holding NULL data.
virtual ~SqlData ()
 Destructor.

Protected Member Functions

 SqlData (SqlTypeMetadata *in_metadata)
 Constructor.

Protected Attributes

simba_signed_native m_conversionLength
bool m_isNull
simba_uint32 m_length
SqlTypeMetadatam_metadata

Detailed Description

Encapsulates a buffer and SqlTypeMetadata* for SQL typed data.

The SqlData wraps SDK types which should be accessed via GetBuffer(), and cast to the correct type when extracting data from or putting data into the SqlData.

If working with a character or binary type, then SetLength() must be called prior to copying data into the SqlData buffer to ensure there is sufficient space in the buffer.

The SQL types map to SDK types as follows: SQL type SDK type ====================================================== SQL_BIGINT (signed) simba_int64 SQL_BIGINT (unsigned) simba_uint64 SQL_BINARY simba_byte* SQL_BIT simba_uint8 SQL_CHAR simba_byte* SQL_DATE TDWDate SQL_DECIMAL TDWExactNumericType SQL_DOUBLE simba_double64 SQL_FLOAT simba_double64 SQL_GUID TDWGuid SQL_INTEGER (signed) simba_int32 SQL_INTEGER (unsigned) simba_uint32 SQL_INTERVAL_DAY TDWSingleFieldInterval SQL_INTERVAL_DAY_TO_HOUR TDWDayHourInterval SQL_INTERVAL_DAY_TO_MINUTE TDWDayMinuteInterval SQL_INTERVAL_DAY_TO_SECOND TDWDaySecondInterval SQL_INTERVAL_HOUR TDWSingleFieldInterval SQL_INTERVAL_HOUR_TO_MINUTE TDWHourMinuteInterval SQL_INTERVAL_HOUR_TO_SECOND TDWHourSecondInterval SQL_INTERVAL_MINUTE TDWSingleFieldInterval SQL_INTERVAL_MINUTE_TO_SECOND TDWMinuteSecondInterval SQL_INTERVAL_MONTH TDWSingleFieldInterval SQL_INTERVAL_SECOND TDWSecondInterval SQL_INTERVAL_YEAR TDWSingleFieldInterval SQL_INTERVAL_YEAR_TO_MONTH TDWYearMonthInterval SQL_LONGVARBINARY simba_byte* SQL_LONGVARCHAR simba_byte* SQL_NUMERIC TDWExactNumericType SQL_REAL simba_double32 SQL_SMALLINT (signed) simba_int16 SQL_SMALLINT (unsigned) simba_uint16 SQL_TINYINT (signed) simba_int8 SQL_TINYINT (unsigned) simba_uint8 SQL_TIME TDWTime SQL_TIMESTAMP TDWTimestamp SQL_TYPE_DATE TDWDate SQL_TYPE_TIME TDWTime SQL_TYPE_TIMESTAMP TDWTimestamp SQL_VARBINARY simba_byte* SQL_VARCHAR simba_byte* SQL_WCHAR simba_byte* SQL_WLONGVARCHAR simba_byte* SQL_WVARCHAR simba_byte*


Constructor & Destructor Documentation

virtual ~SqlData (  )  [virtual]

Destructor.

SqlData ( SqlTypeMetadata in_metadata  )  [protected]

Constructor.

Parameters:
in_metadata (NOT OWN)

Member Function Documentation

virtual void AttachBuffer ( simba_byte in_buffer,
simba_uint32  in_length 
) [virtual]

Attach an unowned buffer, replacing the owned buffer.

This also sets the length. It has no effect on fixed length types.

This is only valid for SQLData whose metadata contains the TDW_BUFFER_ATTACHED value for GetBufferOwnership().

The default implementation throws SupportException("InvalidBufferStrategyOperation");

Parameters:
in_buffer Buffer to attach. May be NULL only for in_length 0. (NOT OWN)
in_length Length of in_buffer.

Reimplemented in SqlVarLengthAttachedType, and SqlVarLengthOwnedType.

void Convert ( SqlCData in_from,
IWarningListener in_warningListener 
)

Converts data from in_from into this object. This function only uses the deprecated global converter factory singleton.

Parameters:
in_from 
in_warningListener The warning listener to post warnings to. (NOT OWN)
Exceptions:
ErrorException if there is an error performing the conversion.
virtual void* GetBuffer (  )  [pure virtual]

Returns the attached buffer.

Note that if this object represents variable length data, SetLength() _must_ be called before calling GetBuffer() to populate the object with data. Failing to do so will likely result in buffer overruns and heap corruption.

Returns:
The attached buffer. (NOT OWN)

Implemented in SqlFixedLengthType< TYPE >, SqlVarLengthAttachedType, and SqlVarLengthOwnedType.

simba_signed_native GetConvertedLength (  )  const

Based on the last Convert(), returns the amount of bytes that all of the converted data would have taken up without truncation, not including space for a possible null terminator.

simba_uint32 GetLength (  )  const [inline]

Returns length of the buffer in number of bytes.

This will be the value set using SetLength() for variable-length types, and a constant value for fixed-length types.

Returns:
The length of the buffer in number of bytes.
const SqlTypeMetadata* GetMetadata (  )  const [inline]

Retrieve the metadata associated with the SqlData.

Returns:
The metadata associated with the SqlData. (NOT OWN)
SqlTypeMetadata* GetMetadata (  )  [inline]

Retrieve the metadata associated with the SqlData.

Returns:
The metadata associated with the SqlData. (NOT OWN)
bool IsNull (  )  const [inline]

Indicates if the buffer should be treated as holding NULL data.

Returns:
True if the data is NULL; false otherwise.
bool IsNullOrEmpty (  )  const [inline]

Indicates if the buffer holds NULL data or 0-length data.

Returns:
True if the data is NULL or 0-length; false otherwise.
void SetConvertedLength ( simba_signed_native  in_convertedLength  )  [inline]

Set the converted length.

Parameters:
in_convertedLength The converted length, in bytes.
virtual void SetLength ( simba_uint32  in_length  )  [virtual]

Sets the length of the buffer in number of bytes.

This method has no effect for fixed length types.

Parameters:
in_length The length in bytes to set the buffer to.

Reimplemented in SqlVarLengthAttachedType, and SqlVarLengthOwnedType.

void SetNull ( bool  in_isNull  )  [inline]

Indicates whether or not the buffer should be treated as holding NULL data.

Parameters:
in_isNull 

Member Data Documentation

bool m_isNull [protected]
simba_uint32 m_length [protected]

The documentation for this class was generated from the following file:

Generated on Wed May 17 14:21:19 2017 for SimbaEngine 10.1.3.1011 by simba