00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "pqxx/libcompiler.h"
00019
00020 #include <string>
00021
00022 #include "pqxx/result"
00023
00024
00025 namespace pqxx
00026 {
00027
00029
00041 class PQXX_LIBEXPORT binarystring : internal::PQAlloc<unsigned char>
00042 {
00043
00044 public:
00045 typedef content_type char_type;
00046 typedef PGSTD::char_traits<char_type>::char_type value_type;
00047 typedef size_t size_type;
00048 typedef long difference_type;
00049 typedef const value_type &const_reference;
00050 typedef const value_type *const_pointer;
00051 typedef const_pointer const_iterator;
00052
00053 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00054 typedef PGSTD::reverse_iterator<const_iterator> const_reverse_iterator;
00055 #endif
00056
00057 private:
00058 typedef internal::PQAlloc<value_type> super;
00059
00060 public:
00062
00065 explicit binarystring(const result::field &F);
00066
00068 size_type size() const throw () { return m_size; }
00070 size_type length() const throw () { return size(); }
00071 bool empty() const throw () { return size()==0; }
00072
00073 const_iterator begin() const throw () { return data(); }
00074 const_iterator end() const throw () { return data()+m_size; }
00075
00076 const_reference front() const throw () { return *begin(); }
00077 const_reference back() const throw () { return *(data()+m_size-1); }
00078
00079 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00080 const_reverse_iterator rbegin() const
00081 { return const_reverse_iterator(end()); }
00082 const_reverse_iterator rend() const
00083 { return const_reverse_iterator(begin()); }
00084 #endif
00085
00087 const value_type *data() const throw () {return super::c_ptr();}
00088
00089 const_reference operator[](size_type i) const throw ()
00090 { return data()[i]; }
00091
00092 bool operator==(const binarystring &) const throw ();
00093 bool operator!=(const binarystring &rhs) const throw ()
00094 { return !operator==(rhs); }
00095
00097 const_reference at(size_type) const;
00098
00100 void swap(binarystring &);
00101
00103
00106 const char *c_ptr() const throw ()
00107 {
00108 return reinterpret_cast<char *>(super::c_ptr());
00109 }
00110
00112
00114 const PGSTD::string &str() const;
00115
00116 private:
00117 size_type m_size;
00118 mutable PGSTD::string m_str;
00119 };
00120
00121
00123 PGSTD::string PQXX_LIBEXPORT escape_binary(const PGSTD::string &bin);
00125 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[]);
00127 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[], size_t len);
00129 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[]);
00131 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[], size_t len);
00132
00133
00134 }
00135