21 #include "pqxx/compiler-public.hxx"
31 #include "pqxx/strconv"
259 #include <pqxx/internal/libpq-forward.hxx>
345 template<typename T=std::
string, typename CONT=std::vector<T> >
352 explicit items(
const T &t) : CONT() { this->push_back(t); }
353 items(
const T &t1,
const T &t2) : CONT()
354 { this->push_back(t1); this->push_back(t2); }
355 items(
const T &t1,
const T &t2,
const T &t3) : CONT()
356 { this->push_back(t1); this->push_back(t2); this->push_back(t3); }
357 items(
const T &t1,
const T &t2,
const T &t3,
const T &t4) : CONT()
364 items(
const T&t1,
const T&t2,
const T&t3,
const T&t4,
const T&t5):CONT()
390 typename ITER::value_type
operator()(ITER i)
const {
return *i; }
403 template<
typename ITER,
typename ACCESS>
inline
413 for (++begin; begin != end; ++begin)
428 template<
typename ITER>
inline std::string
434 template<
typename OBJ>
inline std::string
440 template<
typename CONTAINER>
inline std::string
464 PQXX_LIBEXPORT
void freepqmem(
const void *) PQXX_NOEXCEPT;
470 PQXX_LIBEXPORT
void freemallocmem(
const void *) PQXX_NOEXCEPT;
477 #ifdef PQXX_HAVE_SHARED_PTR
480 template<
typename T,
void (*DELETER)(T *) = freepqmem_templated<T> >
485 PQAlloc() PQXX_NOEXCEPT : m_ptr() {}
487 explicit PQAlloc(T *t) : m_ptr(t, DELETER) {}
489 T *
get()
const PQXX_NOEXCEPT {
return m_ptr.get(); }
496 #if __cplusplus >= 201103L
501 T *
operator->() const PQXX_NOEXCEPT {
return m_ptr.get(); }
502 T &
operator*() const PQXX_NOEXCEPT {
return *m_ptr; }
503 void reset() PQXX_NOEXCEPT { m_ptr.reset(); }
504 void swap(
PQAlloc &other) PQXX_NOEXCEPT { m_ptr.swap(other.m_ptr); }
507 std::shared_ptr<T> m_ptr;
510 #else // !PQXX_HAVE_SHARED_PTR
516 refcount *
volatile m_l, *
volatile m_r;
523 void makeref(
refcount &) PQXX_NOEXCEPT;
526 bool loseref() PQXX_NOEXCEPT;
550 template<
typename T,
void (*DELETER)(T *) = freepqmem_templated<T> >
563 {redoref(rhs);
return *
this;}
568 explicit PQAlloc(T *obj) PQXX_NOEXCEPT : m_Obj(obj), m_rc() {}
578 operator bool() const PQXX_NOEXCEPT {
return m_Obj != 0; }
588 if (!m_Obj)
throw std::logic_error(
"Null pointer dereferenced");
600 T *
get()
const PQXX_NOEXCEPT {
return m_Obj; }
602 void reset() PQXX_NOEXCEPT { loseref(); }
605 void makeref(T *p) PQXX_NOEXCEPT { m_Obj = p; }
607 void makeref(
const PQAlloc &rhs) PQXX_NOEXCEPT
614 void loseref() PQXX_NOEXCEPT
616 if (m_rc.
loseref() && m_Obj) DELETER(m_Obj);
620 void redoref(
const PQAlloc &rhs) PQXX_NOEXCEPT
621 {
if (rhs.m_Obj != m_Obj) { loseref(); makeref(rhs); } }
622 void redoref(T *obj) PQXX_NOEXCEPT
623 {
if (obj != m_Obj) { loseref(); makeref(obj); } }
626 #endif // PQXX_HAVE_SHARED_PTR
632 namedclass(
const std::string &Classname,
const std::string &Name=
"") :
633 m_Classname(Classname),
638 const std::string &
name() const PQXX_NOEXCEPT {
return m_Name; }
640 {
return m_Classname;}
641 std::string description()
const;
644 std::string m_Classname, m_Name;
656 template<
typename GUEST>
662 GUEST *
get()
const PQXX_NOEXCEPT {
return m_Guest; }
713 template<
typename T>
inline std::ptrdiff_t
distance(T first, T last)
715 #ifdef PQXX_HAVE_DISTANCE
716 return std::distance(first, last);
720 for (d=0; first != last; ++d) ++first;
const oid oid_none
The "null" oid.
Definition: util.hxx:320
std::string separated_list(const std::string &sep, ITER begin, ITER end, ACCESS access)
Access iterators using ACCESS functor, returning separator-separated list.
Definition: util.hxx:404
long result_difference_type
Definition: util.hxx:458
Container of items with easy contents initialization and string rendering.
Definition: util.hxx:346
void sleep_seconds(int)
Sleep for the given number of seconds.
Definition: util.cxx:192
void swap(PQAlloc &rhs) PQXX_NOEXCEPT
Definition: util.hxx:570
void freemallocmem_templated(P *p) PQXX_NOEXCEPT
Definition: util.hxx:471
std::ptrdiff_t distance(T first, T last)
Wrapper for std::distance; not all platforms have std::distance().
Definition: util.hxx:713
const char sql_rollback_work[]
Definition: util.cxx:53
void makeref(refcount &) PQXX_NOEXCEPT
Create additional reference based on existing refcount object.
Definition: util.cxx:111
PQAlloc(const PQAlloc &rhs) PQXX_NOEXCEPT
Definition: util.hxx:559
items & operator()(const T &t)
Add element to items list.
Definition: util.hxx:376
Functor: dereference iterator.
Definition: util.hxx:388
const std::string & name() const PQXX_NOEXCEPT
Definition: util.hxx:638
bool safe_result_copy
Are copies of pqxx::result and pqxx::binarystring objects thread-safe?
Definition: util.hxx:301
items(const T &t)
Create items list with one element.
Definition: util.hxx:352
PQAlloc(T *obj) PQXX_NOEXCEPT
Assume ownership of a pointer.
Definition: util.hxx:568
bool safe_query_cancel
Is canceling queries thread-safe?
Definition: util.hxx:293
void Register(GUEST *G)
Definition: util.hxx:664
bool have_safe_strerror
Does standard C library have a thread-safe alternative to strerror?
Definition: util.hxx:277
void freemallocmem(const void *) PQXX_NOEXCEPT
Definition: util.cxx:186
const char * cstring
Work around problem with library export directives and pointers.
Definition: util.hxx:692
void freepqmem_templated(P *p) PQXX_NOEXCEPT
Definition: util.hxx:465
items(const T &t1, const T &t2, const T &t3)
Definition: util.hxx:355
bool operator!() const PQXX_NOEXCEPT
Is this pointer null?
Definition: util.hxx:581
Descriptor of library's thread-safety model.
Definition: util.hxx:267
bool safe_libpq
Is the underlying libpq build thread-safe?
Definition: util.hxx:287
T * operator->() const
Dereference pointer.
Definition: util.hxx:586
bool loseref() PQXX_NOEXCEPT
Drop this reference; return whether we were the last reference.
Definition: util.cxx:120
items(const CONT &c)
Copy container.
Definition: util.hxx:373
namedclass(const std::string &Classname, const std::string &Name="")
Definition: util.hxx:632
items(const T &t1, const T &t2, const T &t3, const T &t4, const T &t5)
Definition: util.hxx:364
cstring strerror_wrapper(int err, char buf[], std::size_t len) PQXX_NOEXCEPT
Human-readable description for error code, possibly using given buffer.
Definition: util.cxx:240
ITER::value_type operator()(ITER i) const
Definition: util.hxx:390
std::string description
A human-readable description of any thread-safety issues.
Definition: util.hxx:313
T & operator*() const
Dereference pointer.
Definition: util.hxx:595
~PQAlloc() PQXX_NOEXCEPT
Definition: util.hxx:560
PQAlloc() PQXX_NOEXCEPT
Definition: util.hxx:558
thread_safety_model describe_thread_safety() PQXX_NOEXCEPT
Describe thread safety available in this build.
Definition: util.cxx:56
bool safe_kerberos
Is Kerberos thread-safe?
Definition: util.hxx:310
unique()
Definition: util.hxx:660
items()
Create empty items list.
Definition: util.hxx:350
unsigned long result_size_type
Definition: util.hxx:457
void CheckUniqueUnregistration(const namedclass *New, const namedclass *Old)
Definition: util.cxx:164
T content_type
Definition: util.hxx:556
void freepqmem(const void *) PQXX_NOEXCEPT
Definition: util.cxx:180
const char sql_commit_work[]
Definition: util.cxx:52
PQAlloc & operator=(const PQAlloc &rhs) PQXX_NOEXCEPT
Definition: util.hxx:562
Ensure proper opening/closing of GUEST objects related to a "host" object.
Definition: util.hxx:657
const std::string & classname() const PQXX_NOEXCEPT
Definition: util.hxx:639
const char sql_begin_work[]
Commonly used SQL commands.
Definition: util.cxx:51
void CheckUniqueRegistration(const namedclass *New, const namedclass *Old)
Definition: util.cxx:149
items(const T &t1, const T &t2, const T &t3, const T &t4)
Definition: util.hxx:357
void Unregister(GUEST *G)
Definition: util.hxx:670
Result set containing data returned by a query or command.
Definition: result.hxx:78
items(const T &t1, const T &t2)
Definition: util.hxx:353
T operator()(T *i) const
Definition: util.hxx:392
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.hxx:464
Reference-counted smart pointer to libpq-allocated object.
Definition: util.hxx:551
void reset() PQXX_NOEXCEPT
Definition: util.hxx:602