libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::binarystring Class Reference

#include <binarystring.hxx>

Inheritance diagram for pqxx::binarystring:
Collaboration diagram for pqxx::binarystring:

Public Types

typedef content_type char_type
 
typedef const_pointer const_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef long difference_type
 
typedef size_t size_type
 
typedef PGSTD::char_traits
< char_type >::char_type 
value_type
 

Public Member Functions

 binarystring (const field &)
 Read and unescape bytea field. More...
 
 binarystring (const PGSTD::string &)
 Copy binary data from std::string. More...
 
 binarystring (const void *, size_t)
 Copy binary data of given length straight out of memory. More...
 
const_reference at (size_type) const
 Index contained string, checking for valid index. More...
 
const_reference back () const throw ()
 
const_iterator begin () const throw ()
 
const value_typedata () const throw ()
 Unescaped field contents. More...
 
bool empty () const throw ()
 
const_iterator end () const throw ()
 
const_reference front () const throw ()
 
const char * get () const throw ()
 Raw character buffer (no terminating zero is added) More...
 
size_type length () const throw ()
 Size of converted string in bytes. More...
 
bool operator!= (const binarystring &rhs) const throw ()
 
bool PQXX_PURE operator== (const binarystring &) const throw ()
 
const_reference operator[] (size_type i) const throw ()
 
size_type size () const throw ()
 Size of converted string in bytes. More...
 
PGSTD::string str () const
 Read as regular C++ string (may include null characters) More...
 
void swap (binarystring &)
 Swap contents with other binarystring. More...
 

Private Types

typedef const unsigned char content_type
 
typedef internal::PQAlloc
< value_type,
pqxx::internal::freemallocmem_templated
< const unsigned char > > 
super
 

Private Member Functions

 operator bool () const throw ()
 Is this pointer non-null? More...
 
bool operator! () const throw ()
 Is this pointer null? More...
 
const unsigned char & operator* () const throw (PGSTD::logic_error)
 Dereference pointer. More...
 
const unsigned char * operator-> () const throw (PGSTD::logic_error)
 Dereference pointer. More...
 
void reset () throw ()
 
void swap (PQAlloc &rhs) throw ()
 

Private Attributes

size_type m_size
 

Related Functions

(Note that these are not member functions.)

PGSTD::string PQXX_LIBEXPORT escape_binary (const PGSTD::string &bin)
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const char bin[])
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const char bin[], size_t len)
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const unsigned char bin[])
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const unsigned char bin[], size_t len)
 Escape binary string for inclusion in SQL. More...
 

Member Typedef Documentation

typedef const unsigned char pqxx::internal::PQAlloc< const unsigned char , DELETER >::content_type
inherited

Constructor & Destructor Documentation

pqxx::binarystring::binarystring ( const field )
explicit

Read and unescape bytea field.

The field will be zero-terminated, even if the original bytea field isn't.

Parameters
Fthe field to read; must be a bytea field
pqxx::binarystring::binarystring ( const PGSTD::string &  )
explicit

Copy binary data from std::string.

pqxx::binarystring::binarystring ( const void *  ,
size_t   
)

Copy binary data of given length straight out of memory.

Member Function Documentation

const_reference pqxx::binarystring::at ( size_type  ) const

Index contained string, checking for valid index.

const_reference pqxx::binarystring::back ( ) const throw ()
inline
const_iterator pqxx::binarystring::begin ( ) const throw ()
inline
const value_type* pqxx::binarystring::data ( ) const throw ()
inline

Unescaped field contents.

bool pqxx::binarystring::empty ( ) const throw ()
inline
const_iterator pqxx::binarystring::end ( ) const throw ()
inline
const_reference pqxx::binarystring::front ( ) const throw ()
inline
const char* pqxx::binarystring::get ( ) const throw ()
inline

Raw character buffer (no terminating zero is added)

Warning
No terminating zero is added! If the binary data did not end in a null character, you will not find one here.
size_type pqxx::binarystring::length ( ) const throw ()
inline

Size of converted string in bytes.

pqxx::internal::PQAlloc< const unsigned char , DELETER >::operator bool ( ) const throw ()
inlineinherited

Is this pointer non-null?

bool pqxx::internal::PQAlloc< const unsigned char , DELETER >::operator! ( ) const throw ()
inlineinherited

Is this pointer null?

bool pqxx::binarystring::operator!= ( const binarystring rhs) const throw ()
inline
const unsigned char & pqxx::internal::PQAlloc< const unsigned char , DELETER >::operator* ( ) const throw (PGSTD::logic_error)
inlineinherited

Dereference pointer.

Throws a logic_error if the pointer is null.

const unsigned char * pqxx::internal::PQAlloc< const unsigned char , DELETER >::operator-> ( ) const throw (PGSTD::logic_error)
inlineinherited

Dereference pointer.

Throws a logic_error if the pointer is null.

bool PQXX_PURE pqxx::binarystring::operator== ( const binarystring ) const throw ()
const_reference pqxx::binarystring::operator[] ( size_type  i) const throw ()
inline
void pqxx::internal::PQAlloc< const unsigned char , DELETER >::reset ( ) throw ()
inlineinherited
size_type pqxx::binarystring::size ( ) const throw ()
inline

Size of converted string in bytes.

PGSTD::string pqxx::binarystring::str ( ) const

Read as regular C++ string (may include null characters)

Warning
libpqxx releases before 3.1 stored the string and returned a reference to it. This is no longer the case! It now creates and returns a new string object. Avoid repeated use of this function; retrieve your string once and keep it in a local variable. Also, do not expect to be able to compare the string's address to that of an earlier invocation.

Referenced by pqxx::internal::statement_parameters::add_binary_param().

Here is the caller graph for this function:

void pqxx::binarystring::swap ( binarystring )

Swap contents with other binarystring.

void pqxx::internal::PQAlloc< const unsigned char , DELETER >::swap ( PQAlloc< const unsigned char, pqxx::internal::freemallocmem_templated< const unsigned char > > &  rhs) throw ()
inlineinherited

Member Data Documentation

size_type pqxx::binarystring::m_size
private

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