SourceMod SDK  1.7
SourceMod::IResultRow Class Referenceabstract

Represents a one database result row. More...

#include <public/IDBDriver.h>

Public Member Functions

virtual DBResult GetString (unsigned int columnId, const char **pString, size_t *length)=0
 Retrieves a database field result as a string. More...
 
virtual DBResult CopyString (unsigned int columnId, char *buffer, size_t maxlength, size_t *written)=0
 Retrieves a database field result as a string, using a user-supplied buffer. If the field is NULL, an empty string will be copied. More...
 
virtual DBResult GetFloat (unsigned int columnId, float *pFloat)=0
 Retrieves a database field result as a float. More...
 
virtual DBResult GetInt (unsigned int columnId, int *pInt)=0
 Retrieves a database field result as an integer. More...
 
virtual bool IsNull (unsigned int columnId)=0
 Returns whether or not a field is NULL. More...
 
virtual size_t GetDataSize (unsigned int columnId)=0
 Returns the size of a field (text/raw/blob) in bytes. For strings, this returned size will not include the null terminator. More...
 
virtual DBResult GetBlob (unsigned int columnId, const void **pData, size_t *length)=0
 Retrieves field data as a raw bitstream. The pointer returned will become invalid after advancing to the next row. More...
 
virtual DBResult CopyBlob (unsigned int columnId, void *buffer, size_t maxlength, size_t *written)=0
 Copies field data as a raw bitstream. More...
 

Detailed Description

Represents a one database result row.

Note that type mismatches will only occur when type safety is being enforced. So far this is only the case for prepared statements in MySQL and SQLite.

Also, it is worth noting that retrieving as raw data will never cause a type mismatch.

Member Function Documentation

virtual DBResult SourceMod::IResultRow::CopyBlob ( unsigned int  columnId,
void *  buffer,
size_t  maxlength,
size_t *  written 
)
pure virtual

Copies field data as a raw bitstream.

Parameters
columnIdColumn to use, starting from 0.
bufferPointer to copy the data to. If the data is NULL, no data will be copied.
maxlengthMaximum length of the buffer.
writtenOptional pointer to store the number of bytes written.
Returns
A DBResult return code.
virtual DBResult SourceMod::IResultRow::CopyString ( unsigned int  columnId,
char *  buffer,
size_t  maxlength,
size_t *  written 
)
pure virtual

Retrieves a database field result as a string, using a user-supplied buffer. If the field is NULL, an empty string will be copied.

Parameters
columnIdColumn to use, starting from 0.
bufferBuffer to store string in.
maxlengthMaximum length of the buffer.
writtenOptional pointer to store the number of bytes written, excluding the null terminator.
Returns
A DBResult return code.
virtual DBResult SourceMod::IResultRow::GetBlob ( unsigned int  columnId,
const void **  pData,
size_t *  length 
)
pure virtual

Retrieves field data as a raw bitstream. The pointer returned will become invalid after advancing to the next row.

Parameters
columnIdColumn to use, starting from 0.
pDataPointer to store the raw bit stream. If the data is NULL, a NULL pointer will be returned.
lengthPointer to store the data length.
Returns
A DBResult return code.
virtual size_t SourceMod::IResultRow::GetDataSize ( unsigned int  columnId)
pure virtual

Returns the size of a field (text/raw/blob) in bytes. For strings, this returned size will not include the null terminator.

When used on fields that are not of variable length, the size returned will be the number of bytes required to store the internal data. Note that the data size will correspond to the ACTUAL data type, not the COLUMN type.

Parameters
columnIdColumn to use, starting from 0.
Returns
Number of bytes required to store the data, or 0 on failure.
virtual DBResult SourceMod::IResultRow::GetFloat ( unsigned int  columnId,
float *  pFloat 
)
pure virtual

Retrieves a database field result as a float.

For NULL entries, the returned float value will be 0.0.

Parameters
columnIdColumn to use, starting from 0.
pFloatPointer to a floating point number to set.
Returns
A DBResult return code.
virtual DBResult SourceMod::IResultRow::GetInt ( unsigned int  columnId,
int *  pInt 
)
pure virtual

Retrieves a database field result as an integer.

For NULL entries, the returned integer value will be 0.

Parameters
columnIdColumn to use, starting from 0.
pIntPointer to an integer number to set.
Returns
A DBResult return code.
virtual DBResult SourceMod::IResultRow::GetString ( unsigned int  columnId,
const char **  pString,
size_t *  length 
)
pure virtual

Retrieves a database field result as a string.

For NULL values, the resulting string pointer will be non-NULL but empty. The pointer returned will become invalid after advancing to the next row.

Parameters
columnIdColumn to use, starting from 0.
pStringPointer to store a pointer to the string.
lengthOptional pointer to store the string length.
Returns
A DBResult return code.
virtual bool SourceMod::IResultRow::IsNull ( unsigned int  columnId)
pure virtual

Returns whether or not a field is NULL.

Parameters
columnIdColumn to use, starting from 0.
Returns
True if field is NULL, false otherwise.

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