C++ SDK Documentation  9.0
Vertica::VString Class Reference

Representation of a String in Vertica. All character data is internally encoded as UTF-8 characters and is not NULL terminated. More...

Collaboration diagram for Vertica::VString:
Collaboration graph

Public Member Functions

void alloc (vsize len)
 Allocate the VString's internal buffer and initialize to 'len' 0 bytes. More...
 
int compare (const VString *other) const
 Compares this VString to another. More...
 
void copy (const char *s, vsize len)
 Copy character data from C string to the VString's internal buffer. More...
 
void copy (const char *s)
 Copy character data from null terminated C string to the VString's internal buffer. More...
 
void copy (const std::string &s)
 Copy character data from std::string. More...
 
void copy (const VString *from)
 Copy data from another VString. More...
 
void copy (const VString &from)
 Copy data from another VString. More...
 
const char * data () const
 Provides a read-only pointer to this VString's internal data. More...
 
char * data ()
 Provides a writeable pointer to this VString's internal data. More...
 
int equal (const VString *other) const
 Indicates whether some other VString is equal to this one. More...
 
bool isNull () const
 Indicates if this VString contains the SQL NULL value. More...
 
vsize length () const
 Returns the length of this VString. More...
 
void setNull ()
 Sets this VString to the SQL NULL value.
 
std::string str () const
 Provides a copy of this VString's data as a std::string. More...
 

Detailed Description

Representation of a String in Vertica. All character data is internally encoded as UTF-8 characters and is not NULL terminated.

Member Function Documentation

void Vertica::VString::alloc ( vsize  len)
inline

Allocate the VString's internal buffer and initialize to 'len' 0 bytes.

The VString is allocated and set to 'len' zero bytes. It is the caller's responsibility to not provide a value of 'len' that is larger than the maximum size of this VString

Parameters
lenlength in bytes
int Vertica::VString::compare ( const VString other) const
inline

Compares this VString to another.

Returns
-1 if this < other, 0 if equal, 1 if this > other (just like memcmp)
Note
SQL NULL compares greater than anything else; two SQL NULLs are considered equal
void Vertica::VString::copy ( const char *  s,
vsize  len 
)
inline

Copy character data from C string to the VString's internal buffer.

Data is copied from s into this VString. It is the caller's responsibility to not provide a value of 'len' that is larger than the maximum size of this VString

Parameters
scharacter input data
lenlength in bytes, not including the terminating null character
void Vertica::VString::copy ( const char *  s)
inline

Copy character data from null terminated C string to the VString's internal buffer.

Parameters
snull-terminated character input data

Referenced by copy().

void Vertica::VString::copy ( const std::string &  s)
inline

Copy character data from std::string.

Parameters
snull-terminated character input data

Referenced by copy().

void Vertica::VString::copy ( const VString from)
inline

Copy data from another VString.

Parameters
fromThe source VString
void Vertica::VString::copy ( const VString from)
inline

Copy data from another VString.

Parameters
fromThe source VString

Referenced by copy().

const char* Vertica::VString::data ( ) const
inline

Provides a read-only pointer to this VString's internal data.

Returns
the read only character data for this string, as a pointer.
Note
The returned string is not null terminated
char* Vertica::VString::data ( )
inline

Provides a writeable pointer to this VString's internal data.

Returns
the writeable character data for this string, as a pointer.
Note
The returned string is not null terminated
int Vertica::VString::equal ( const VString other) const
inline

Indicates whether some other VString is equal to this one.

Returns
-1 if both are SQL NULL, 0 if not equal, 1 if equal so you can easily consider two NULL values to be equal to each other, or not
bool Vertica::VString::isNull ( ) const
inline

Indicates if this VString contains the SQL NULL value.

Returns
true if this string contains the SQL NULL value, false otherwise

Referenced by Vertica::VerticaBlock::addCol(), and copy().

vsize Vertica::VString::length ( ) const
inline

Returns the length of this VString.

Returns
the length of the string, in bytes. Does not include any extra space for null characters.

Referenced by Vertica::VerticaBlock::addCol().

std::string Vertica::VString::str ( ) const
inline

Provides a copy of this VString's data as a std::string.

Returns
a std::string copy of the data in this VString

Referenced by Vertica::VerticaBlock::addCol().