binarystring.hxx
#ifndef PQXX_H_BINARYSTRING
#define PQXX_H_BINARYSTRING
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include <memory>
#include <string>
#include "pqxx/result.hxx"
namespace pqxx
{
class PQXX_LIBEXPORT binarystring
{
public:
using char_type = unsigned char;
using value_type = std::char_traits<char_type>::char_type;
using size_type = size_t;
using difference_type = long;
using const_reference = const value_type &;
using const_pointer = const value_type *;
using const_iterator = const_pointer;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
binarystring(const binarystring &) =default;
explicit binarystring(const field &); //[t62]
explicit binarystring(const std::string &);
binarystring(const void *, size_t);
size_type size() const noexcept { return m_size; } //[t62]
size_type length() const noexcept { return size(); } //[t62]
bool empty() const noexcept { return size()==0; } //[t62]
const_iterator begin() const noexcept { return data(); } //[t62]
const_iterator cbegin() const noexcept { return begin(); }
const_iterator end() const noexcept { return data()+m_size; } //[t62]
const_iterator cend() const noexcept { return end(); }
const_reference front() const noexcept { return *begin(); } //[t62]
const_reference back() const noexcept //[t62]
{ return *(data()+m_size-1); }
const_reverse_iterator rbegin() const //[t62]
{ return const_reverse_iterator{end()}; }
const_reverse_iterator crbegin() const { return rbegin(); }
const_reverse_iterator rend() const //[t62]
{ return const_reverse_iterator{begin()}; }
const_reverse_iterator crend() const { return rend(); }
const value_type *data() const noexcept {return m_buf.get();} //[t62]
const_reference operator[](size_type i) const noexcept //[t62]
{ return data()[i]; }
PQXX_PURE bool operator==(const binarystring &) const noexcept; //[t62]
bool operator!=(const binarystring &rhs) const noexcept //[t62]
{ return not operator==(rhs); }
binarystring &operator=(const binarystring &);
const_reference at(size_type) const; //[t62]
void swap(binarystring &); //[t62]
const char *get() const noexcept //[t62]
{ return reinterpret_cast<const char *>(m_buf.get()); }
std::string str() const; //[t62]
private:
using smart_pointer_type = std::shared_ptr<value_type>;
static smart_pointer_type make_smart_pointer(unsigned char *buf=nullptr)
{
return smart_pointer_type{
buf,
internal::freemallocmem_templated<unsigned char>};
}
smart_pointer_type m_buf;
size_type m_size;
};
}
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::binarystring::char_type
unsigned char char_type
Definition: binarystring.hxx:56
pqxx::binarystring::empty
bool empty() const noexcept
Definition: binarystring.hxx:83
pqxx::binarystring::begin
const_iterator begin() const noexcept
Definition: binarystring.hxx:85
pqxx::internal
Private namespace for libpqxx's internal use; do not access.
Definition: connection_base.hxx:43
pqxx::binarystring::rend
const_reverse_iterator rend() const
Definition: binarystring.hxx:97
pqxx::binarystring::const_reference
const value_type & const_reference
Definition: binarystring.hxx:60
pqxx::binarystring::size_type
size_t size_type
Definition: binarystring.hxx:58
pqxx::binarystring::at
const_reference at(size_type) const
Index contained string, checking for valid index.
Definition: binarystring.cxx:122
pqxx::binarystring::value_type
std::char_traits< char_type >::char_type value_type
Definition: binarystring.hxx:57
pqxx::binarystring::operator!=
bool operator!=(const binarystring &rhs) const noexcept
Definition: binarystring.hxx:108
pqxx::binarystring::rbegin
const_reverse_iterator rbegin() const
Definition: binarystring.hxx:94
pqxx::binarystring::end
const_iterator end() const noexcept
Definition: binarystring.hxx:87
pqxx::binarystring::str
std::string str() const
Read as regular C++ string (may include null characters)
Definition: binarystring.cxx:147
pqxx::binarystring::const_iterator
const_pointer const_iterator
Definition: binarystring.hxx:62
pqxx::binarystring::front
const_reference front() const noexcept
Definition: binarystring.hxx:90
pqxx::binarystring::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: binarystring.hxx:63
pqxx::binarystring::crbegin
const_reverse_iterator crbegin() const
Definition: binarystring.hxx:96
pqxx::field
Reference to a field in a result set.
Definition: field.hxx:49
pqxx::binarystring::swap
void swap(binarystring &)
Swap contents with other binarystring.
Definition: binarystring.cxx:136
pqxx::binarystring::binarystring
binarystring(const binarystring &)=default
pqxx::binarystring::size
size_type size() const noexcept
Size of converted string in bytes.
Definition: binarystring.hxx:80
pqxx::binarystring
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
Definition: binarystring.hxx:53
pqxx::binarystring::operator=
binarystring & operator=(const binarystring &)
Definition: binarystring.cxx:114
pqxx::binarystring::back
const_reference back() const noexcept
Definition: binarystring.hxx:91
pqxx::binarystring::cbegin
const_iterator cbegin() const noexcept
Definition: binarystring.hxx:86
pqxx::binarystring::get
const char * get() const noexcept
Raw character buffer (no terminating zero is added)
Definition: binarystring.hxx:123
pqxx::binarystring::operator==
PQXX_PURE bool operator==(const binarystring &) const noexcept
Definition: binarystring.cxx:107
pqxx::binarystring::operator[]
const_reference operator[](size_type i) const noexcept
Definition: binarystring.hxx:104
pqxx::binarystring::crend
const_reverse_iterator crend() const
Definition: binarystring.hxx:99
pqxx::to_string
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.cxx:451
pqxx::binarystring::cend
const_iterator cend() const noexcept
Definition: binarystring.hxx:88
pqxx::binarystring::const_pointer
const value_type * const_pointer
Definition: binarystring.hxx:61
pqxx::binarystring::length
size_type length() const noexcept
Size of converted string in bytes.
Definition: binarystring.hxx:82
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
pqxx::binarystring::data
const value_type * data() const noexcept
Unescaped field contents.
Definition: binarystring.hxx:102
pqxx::binarystring::difference_type
long difference_type
Definition: binarystring.hxx:59