21 #include "pqxx/compiler-public.hxx" 30 #ifdef PQXX_TR1_HEADERS 36 #include "pqxx/strconv" 272 #include <pqxx/internal/libpq-forward.hxx> 358 template<typename T=PGSTD::
string, typename CONT=PGSTD::vector<T> >
365 explicit items(
const T &t) : CONT() { this->push_back(t); }
366 items(
const T &t1,
const T &t2) : CONT()
367 { this->push_back(t1); this->push_back(t2); }
368 items(
const T &t1,
const T &t2,
const T &t3) : CONT()
369 { this->push_back(t1); this->push_back(t2); this->push_back(t3); }
370 items(
const T &t1,
const T &t2,
const T &t3,
const T &t4) : CONT()
377 items(
const T&t1,
const T&t2,
const T&t3,
const T&t4,
const T&t5):CONT()
403 typename ITER::value_type
operator()(ITER i)
const {
return *i; }
416 template<
typename ITER,
typename ACCESS>
inline 426 for (++begin; begin != end; ++begin)
441 template<
typename ITER>
inline PGSTD::string
447 template<
typename OBJ>
inline PGSTD::string
453 template<
typename CONTAINER>
inline PGSTD::string
477 void PQXX_LIBEXPORT
freepqmem(
const void *)
throw ();
490 #ifdef PQXX_HAVE_SHARED_PTR 493 template<
typename T,
void (*DELETER)(T *) = freepqmem_templated<T> >
497 typedef T content_type;
498 PQAlloc()
throw () : m_ptr() {}
500 explicit PQAlloc(T *t) : m_ptr(t, DELETER) {}
502 T *
get()
const throw () {
return m_ptr.get(); }
509 T *operator->()
const throw () {
return m_ptr.
get(); }
510 T &operator*()
const throw () {
return *m_ptr; }
511 void reset()
throw () { m_ptr.reset(); }
512 void swap(
PQAlloc &other)
throw () { m_ptr.swap(other.m_ptr); }
515 PQXXTR1::shared_ptr<T> m_ptr;
518 #else // !PQXX_HAVE_SHARED_PTR 524 refcount *
volatile m_l, *
volatile m_r;
534 bool loseref()
throw ();
558 template<
typename T,
void (*DELETER)(T *) = freepqmem_templated<T> >
575 explicit PQAlloc(T *obj)
throw () : m_Obj(obj), m_rc() {}
587 operator bool()
const throw () {
return m_Obj != 0; }
597 if (!m_Obj)
throw PGSTD::logic_error(
"Null pointer dereferenced");
604 T &
operator*()
const throw (PGSTD::logic_error) {
return *operator->(); }
609 T *
get()
const throw () {
return m_Obj; }
611 void reset() throw () { loseref(); }
614 void makeref(T *p)
throw () { m_Obj = p; }
616 void makeref(
const PQAlloc &rhs)
throw ()
623 void loseref()
throw ()
625 if (m_rc.
loseref() && m_Obj) DELETER(m_Obj);
629 void redoref(
const PQAlloc &rhs)
throw ()
630 {
if (rhs.m_Obj != m_Obj) { loseref(); makeref(rhs); } }
631 void redoref(T *obj)
throw ()
632 {
if (obj != m_Obj) { loseref(); makeref(obj); } }
635 #endif // PQXX_HAVE_SHARED_PTR 650 T *
get()
const throw () {
return m_ptr; }
652 template<
typename INDEX> T &
operator[](INDEX i)
const throw ()
675 namedclass(
const PGSTD::string &Classname,
const PGSTD::string &Name=
"") :
676 m_Classname(Classname),
681 const PGSTD::string &
name()
const throw () {
return m_Name; }
682 const PGSTD::string &
classname()
const throw () {
return m_Classname;}
683 PGSTD::string description()
const;
686 PGSTD::string m_Classname, m_Name;
698 template<
typename GUEST>
704 GUEST *
get()
const throw () {
return m_Guest; }
708 CheckUniqueRegistration(G, m_Guest);
714 CheckUniqueUnregistration(G, m_Guest);
746 cstring PQXX_LIBEXPORT
strerror_wrapper(
int err,
char buf[], PGSTD::size_t len)
755 template<
typename T>
inline PGSTD::ptrdiff_t
distance(T first, T last)
757 #ifdef PQXX_HAVE_DISTANCE 758 return PGSTD::distance(first, last);
762 for (d=0; first != last; ++d) ++first;
Descriptor of library's thread-safety model.
Definition: util.hxx:280
Result set containing data returned by a query or command.
Definition: result.hxx:81
unique()
Definition: util.hxx:702
~PQAlloc()
Definition: util.hxx:568
PQAlloc()
Definition: util.hxx:566
bool safe_query_cancel
Is canceling queries thread-safe?
Definition: util.hxx:306
void CheckUniqueUnregistration(const namedclass *New, const namedclass *Old)
Definition: util.cxx:177
void swap(PQAlloc &rhs)
Definition: util.hxx:577
T & operator*() const
Definition: util.hxx:651
scoped_array(T *t)
Definition: util.hxx:647
long result_difference_type
Definition: util.hxx:471
Ensure proper opening/closing of GUEST objects related to a "host" object.
Definition: util.hxx:699
void freemallocmem_templated(P *p)
Definition: util.hxx:484
void sleep_seconds(int)
Sleep for the given number of seconds.
Definition: util.cxx:205
std::ptrdiff_t distance(T first, T last)
Wrapper for std::distance; not all platforms have std::distance().
Definition: util.hxx:755
PQAlloc(const PQAlloc &rhs)
Definition: util.hxx:567
scoped_array()
Definition: util.hxx:645
const std::string & classname() const
Definition: util.hxx:682
T * get() const
Obtain underlying pointer.
Definition: util.hxx:609
void makeref(refcount &)
Create additional reference based on existing refcount object.
Definition: util.cxx:124
bool safe_kerberos
Is Kerberos thread-safe?
Definition: util.hxx:323
ITER::value_type operator()(ITER i) const
Definition: util.hxx:403
long difference_type
Definition: util.hxx:643
const char sql_rollback_work[]
Definition: util.cxx:54
size_t size_type
Definition: util.hxx:642
items(const T &t1, const T &t2, const T &t3)
Definition: util.hxx:368
items(const T &t1, const T &t2, const T &t3, const T &t4, const T &t5)
Definition: util.hxx:377
const char sql_commit_work[]
Definition: util.cxx:53
Container of items with easy contents initialization and string rendering.
Definition: util.hxx:359
PQAlloc & operator=(const PQAlloc &rhs)
Definition: util.hxx:570
void freepqmem_templated(P *p)
Definition: util.hxx:478
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:417
items(const T &t1, const T &t2, const T &t3, const T &t4)
Definition: util.hxx:370
items(const T &t)
Create items list with one element.
Definition: util.hxx:365
bool safe_libpq
Is the underlying libpq build thread-safe?
Definition: util.hxx:300
unsigned long result_size_type
Definition: util.hxx:470
bool have_safe_strerror
Does standard C library have a thread-safe alternative to strerror?
Definition: util.hxx:290
void CheckUniqueRegistration(const namedclass *New, const namedclass *Old)
Definition: util.cxx:162
items(const T &t1, const T &t2)
Definition: util.hxx:366
T * operator->() const
Dereference pointer.
Definition: util.hxx:595
items()
Create empty items list.
Definition: util.hxx:363
const std::string & name() const
Definition: util.hxx:681
items & operator()(const T &t)
Add element to items list.
Definition: util.hxx:389
Reference-counted smart pointer to libpq-allocated object.
Definition: util.hxx:559
void freemallocmem(const void *)
Definition: util.cxx:199
Functor: dereference iterator.
Definition: util.hxx:401
cstring strerror_wrapper(int err, char buf[], std::size_t len)
Human-readable description for error code, possibly using given buffer.
Definition: util.cxx:253
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.hxx:467
T & operator*() const
Dereference pointer.
Definition: util.hxx:604
PQAlloc(T *obj)
Assume ownership of a pointer.
Definition: util.hxx:575
void reset()
Definition: util.hxx:611
bool operator!() const
Is this pointer null?
Definition: util.hxx:590
void freepqmem(const void *)
Definition: util.cxx:193
T content_type
Definition: util.hxx:564
std::string description
A human-readable description of any thread-safety issues.
Definition: util.hxx:326
items(const CONT &c)
Copy container.
Definition: util.hxx:386
thread_safety_model describe_thread_safety()
Describe thread safety available in this build.
Definition: util.cxx:57
const char sql_begin_work[]
Commonly used SQL commands.
Definition: util.cxx:52
const char * cstring
Work around problem with library export directives and pointers.
Definition: util.hxx:734
void Unregister(GUEST *G)
Definition: util.hxx:712
scoped_array(size_type n)
Definition: util.hxx:646
The home of all libpqxx classes, functions, templates, etc.
Definition: basic_connection.hxx:35
void Register(GUEST *G)
Definition: util.hxx:706
scoped_array & operator=(T *t)
Definition: util.hxx:655
namedclass(const std::string &Classname, const std::string &Name="")
Definition: util.hxx:675
T & operator[](INDEX i) const
Definition: util.hxx:652
bool safe_result_copy
Are copies of pqxx::result and pqxx::binarystring objects thread-safe?
Definition: util.hxx:314
T operator()(T *i) const
Definition: util.hxx:405
const oid oid_none
The "null" oid.
Definition: util.hxx:333
bool loseref()
Drop this reference; return whether we were the last reference.
Definition: util.cxx:133
~scoped_array()
Definition: util.hxx:648