pqxx::binarystring Class Reference

`#include <binarystring.hxx>`

Inheritance diagram for pqxx::binarystring:

## Public Types

typedef content_type | char_type
typedef std::char_traits< char_type >::char_type | value_type
typedef size_t | size_type
typedef long | difference_type
typedef const value_type & | const_reference
typedef const value_type * | const_pointer
typedef const_pointer | const_iterator

## Public Member Functions

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

## Related Functions

(Note that these are not member functions.)
std::string | escape_binary (const std::string &bin)
| Escape binary string for inclusion in SQL. More...
std::string | escape_binary (const char bin[])
| Escape binary string for inclusion in SQL. More...
std::string | escape_binary (const char bin[], size_t len)
| Escape binary string for inclusion in SQL. More...
std::string | escape_binary (const unsigned char bin[])
| Escape binary string for inclusion in SQL. More...
std::string | escape_binary (const unsigned char bin[], size_t len)
| Escape binary string for inclusion in SQL. More...

## Member Typedef Documentation

## char_type

typedef content_type pqxx::binarystring::char_type

## const_iterator

typedef const_pointer pqxx::binarystring::const_iterator

## const_pointer

typedef const value_type* pqxx::binarystring::const_pointer

## const_reference

typedef const value_type& pqxx::binarystring::const_reference

## difference_type

typedef long pqxx::binarystring::difference_type

## size_type

typedef size_t pqxx::binarystring::size_type

## value_type

typedef std::char_traits<char_type>::char_type pqxx::binarystring::value_type

## Constructor & Destructor Documentation

## binarystring() [1/3]

pqxx::binarystring::binarystring | ( | const field & | F | ) |

explicit

Read and unescape bytea field.

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

Parameters

  F | the field to read; must be a bytea field

References pqxx::field::c_str(), pqxx::internal::PQAlloc< T, DELETER >::operator=(), and pqxx::field::size().

## binarystring() [2/3]

pqxx::binarystring::binarystring | ( | const std::string & | s | ) |

explicit

Copy binary data from std::string.

References pqxx::internal::PQAlloc< T, DELETER >::operator=().

## binarystring() [3/3]

pqxx::binarystring::binarystring | ( | const void * | binary_data,
|  | size_t | len
| ) |  |

Copy binary data of given length straight out of memory.

References pqxx::internal::PQAlloc< T, DELETER >::operator=().

## Member Function Documentation

## at()

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

Index contained string, checking for valid index.

References data(), and pqxx::to_string().

## back()

const_reference pqxx::binarystring::back | ( |  | ) | const
throw | ( |
| ) |  |

## begin()

const_iterator pqxx::binarystring::begin | ( |  | ) | const
throw | ( |
| ) |  |

## data()

const value_type* pqxx::binarystring::data | ( |  | ) | const
throw | ( |
| ) |  |

Unescaped field contents.

Referenced by at(), operator==(), and pqxx::connection_base::quote().

## empty()

bool pqxx::binarystring::empty | ( |  | ) | const
throw | ( |
| ) |  |

## end()

const_iterator pqxx::binarystring::end | ( |  | ) | const
throw | ( |
| ) |  |

## front()

const_reference pqxx::binarystring::front | ( |  | ) | const
throw | ( |
| ) |  |

## get()

const char* pqxx::binarystring::get | ( |  | ) | const
throw | ( |
| ) |  |

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.

References pqxx::escape_binary().

## length()

size_type pqxx::binarystring::length | ( |  | ) | const
throw | ( |
| ) |  |

Size of converted string in bytes.

## operator!=()

bool pqxx::binarystring::operator!= | ( | const binarystring & | rhs | ) | const
throw | ( |
| ) |  |

## operator==()

bool pqxx::binarystring::operator== | ( | const binarystring & | rhs | ) | const
throw | ( |
| ) |  |

References data(), and size().

## operator[]()

const_reference pqxx::binarystring::operator[] | ( | size_type | i | ) | const
throw | ( |
| ) |  |

## size()

size_type pqxx::binarystring::size | ( |  | ) | const
throw | ( |
| ) |  |

Size of converted string in bytes.

Referenced by operator==(), and pqxx::connection_base::quote().

## str()

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.

## swap()

void pqxx::binarystring::swap | ( | binarystring & | rhs | ) |

Swap contents with other binarystring.

References pqxx::internal::PQAlloc< T, DELETER >::swap().

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

- binarystring.hxx
- binarystring.cxx