binarystring.hxx
/*-------------------------------------------------------------------------
*
* FILE
* pqxx/binarystring.hxx
*
* DESCRIPTION
* Representation for raw, binary data.
* DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/binarystring instead.
*
* Copyright (c) 2003-2013, Jeroen T. Vermeulen <jtv@xs4all.nl>
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this mistake,
* or contact the author.
*
*-------------------------------------------------------------------------
*/
#ifndef PQXX_H_BINARYSTRING
#define PQXX_H_BINARYSTRING
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include <string>
#include "pqxx/result"
namespace pqxx
{
class PQXX_LIBEXPORT binarystring :
internal::PQAlloc<
unsigned char,
pqxx::internal::freemallocmem_templated<unsigned char> >
{
public:
typedef content_type char_type;
typedef PGSTD::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;
#ifdef PQXX_HAVE_REVERSE_ITERATOR
typedef PGSTD::reverse_iterator<const_iterator> const_reverse_iterator;
#endif
private:
typedef internal::PQAlloc<
value_type,
pqxx::internal::freemallocmem_templated<unsigned char> >
super;
public:
explicit binarystring(const field &); //[t62]
explicit binarystring(const PGSTD::string &);
binarystring(const void *, size_t);
size_type size() const throw () { return m_size; } //[t62]
size_type length() const throw () { return size(); } //[t62]
bool empty() const throw () { return size()==0; } //[t62]
const_iterator begin() const throw () { return data(); } //[t62]
const_iterator end() const throw () { return data()+m_size; } //[t62]
const_reference front() const throw () { return *begin(); } //[t62]
const_reference back() const throw () { return *(data()+m_size-1); } //[t62]
#ifdef PQXX_HAVE_REVERSE_ITERATOR
const_reverse_iterator rbegin() const //[t62]
{ return const_reverse_iterator(end()); }
const_reverse_iterator rend() const //[t62]
{ return const_reverse_iterator(begin()); }
#endif
const value_type *data() const throw () {return super::get();} //[t62]
const_reference operator[](size_type i) const throw () //[t62]
{ return data()[i]; }
bool PQXX_PURE operator==(const binarystring &) const throw (); //[t62]
bool operator!=(const binarystring &rhs) const throw () //[t62]
{ return !operator==(rhs); }
const_reference at(size_type) const; //[t62]
void swap(binarystring &); //[t62]
const char *get() const throw () //[t62]
{
return reinterpret_cast<const char *>(super::get());
}
PGSTD::string str() const; //[t62]
private:
size_type m_size;
};
PGSTD::string PQXX_LIBEXPORT escape_binary(const PGSTD::string &bin);
PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[]);
PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[], size_t len);
PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[]);
PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[], size_t len);
}
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::field
Reference to a field in a result set.
Definition: field.hxx:43
pqxx::binarystring::length
size_type length() const
Size of converted string in bytes.
Definition: binarystring.hxx:99
pqxx::binarystring::operator!=
bool operator!=(const binarystring &rhs) const
Definition: binarystring.hxx:122
pqxx::binarystring::operator[]
const_reference operator[](size_type i) const
Definition: binarystring.hxx:118
pqxx::binarystring::begin
const_iterator begin() const
Definition: binarystring.hxx:102
pqxx::binarystring::difference_type
long difference_type
Definition: binarystring.hxx:68
pqxx::binarystring::empty
bool empty() const
Definition: binarystring.hxx:100
pqxx::binarystring::data
const value_type * data() const
Unescaped field contents.
Definition: binarystring.hxx:116
pqxx::escape_binary
std::string escape_binary(const std::string &bin)
Escape binary string for inclusion in SQL.
Definition: binarystring.cxx:241
pqxx::binarystring
Definition: binarystring.hxx:59
pqxx::binarystring::const_reference
const value_type & const_reference
Definition: binarystring.hxx:69
pqxx::binarystring::const_pointer
const value_type * const_pointer
Definition: binarystring.hxx:70
pqxx::binarystring::end
const_iterator end() const
Definition: binarystring.hxx:103
pqxx::binarystring::size
size_type size() const
Size of converted string in bytes.
Definition: binarystring.hxx:97
pqxx::binarystring::front
const_reference front() const
Definition: binarystring.hxx:105
pqxx::internal::PQAlloc
Reference-counted smart pointer to libpq-allocated object.
Definition: util.hxx:559
pqxx::binarystring::size_type
size_t size_type
Definition: binarystring.hxx:67
pqxx::internal::PQAlloc< unsigned char, pqxx::internal::freemallocmem_templated< unsigned char > >::content_type
unsigned char content_type
Definition: util.hxx:564
pqxx::binarystring::back
const_reference back() const
Definition: binarystring.hxx:106
pqxx::binarystring::value_type
std::char_traits< char_type >::char_type value_type
Definition: binarystring.hxx:66
pqxx::binarystring::char_type
content_type char_type
Definition: binarystring.hxx:65
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: basic_connection.hxx:35
pqxx::binarystring::const_iterator
const_pointer const_iterator
Definition: binarystring.hxx:71