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...

List of all members.

Public Member Functions

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


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:
len length 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 VString &  from  )  [inline]

Copy data from another VString.

Parameters:
from The source VString

void Vertica::VString::copy ( const VString *  from  )  [inline]

Copy data from another VString.

Parameters:
from The source VString

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

Copy character data from std::string.

Parameters:
s null-terminated character input data

void Vertica::VString::copy ( const char *  s  )  [inline]

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

Parameters:
s null-terminated character input data

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:
s character input data
len length in bytes, not including the terminating null character

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

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

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

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.

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