00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "pqxx/compiler-public.hxx"
00019 #include "pqxx/compiler-internal-pre.hxx"
00020
00021 #include <string>
00022
00023 #include "pqxx/result"
00024
00025
00026 namespace pqxx
00027 {
00028
00030
00057 class PQXX_LIBEXPORT binarystring : internal::PQAlloc<unsigned char>
00058 {
00059
00060 public:
00061 typedef content_type char_type;
00062 typedef PGSTD::char_traits<char_type>::char_type value_type;
00063 typedef size_t size_type;
00064 typedef long difference_type;
00065 typedef const value_type &const_reference;
00066 typedef const value_type *const_pointer;
00067 typedef const_pointer const_iterator;
00068
00069 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00070 typedef PGSTD::reverse_iterator<const_iterator> const_reverse_iterator;
00071 #endif
00072
00073 private:
00074 typedef internal::PQAlloc<value_type> super;
00075
00076 public:
00078
00081 explicit binarystring(const result::field &F);
00082
00084 size_type size() const throw () { return m_size; }
00086 size_type length() const throw () { return size(); }
00087 bool empty() const throw () { return size()==0; }
00088
00089 const_iterator begin() const throw () { return data(); }
00090 const_iterator end() const throw () { return data()+m_size; }
00091
00092 const_reference front() const throw () { return *begin(); }
00093 const_reference back() const throw () { return *(data()+m_size-1); }
00094
00095 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00096 const_reverse_iterator rbegin() const
00097 { return const_reverse_iterator(end()); }
00098 const_reverse_iterator rend() const
00099 { return const_reverse_iterator(begin()); }
00100 #endif
00101
00103 const value_type *data() const throw () {return super::c_ptr();}
00104
00105 const_reference operator[](size_type i) const throw ()
00106 { return data()[i]; }
00107
00108 bool operator==(const binarystring &) const throw ();
00109 bool operator!=(const binarystring &rhs) const throw ()
00110 { return !operator==(rhs); }
00111
00113 const_reference at(size_type) const;
00114
00116 void swap(binarystring &);
00117
00119
00122 const char *c_ptr() const throw ()
00123 {
00124 return reinterpret_cast<char *>(super::c_ptr());
00125 }
00126
00128
00135 const PGSTD::string &str() const;
00136
00137 private:
00138 size_type m_size;
00139 mutable PGSTD::string m_str;
00140 };
00141
00142
00149
00150
00154 PGSTD::string PQXX_LIBEXPORT escape_binary(const PGSTD::string &bin);
00156
00160 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[]);
00162
00166 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[], size_t len);
00168
00172 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[]);
00174
00178 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[], size_t len);
00179
00185 }
00186
00187 #include "pqxx/compiler-internal-post.hxx"