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
00056 class PQXX_LIBEXPORT binarystring : internal::PQAlloc<unsigned char>
00057 {
00058
00059 public:
00060 typedef content_type char_type;
00061 typedef PGSTD::char_traits<char_type>::char_type value_type;
00062 typedef size_t size_type;
00063 typedef long difference_type;
00064 typedef const value_type &const_reference;
00065 typedef const value_type *const_pointer;
00066 typedef const_pointer const_iterator;
00067
00068 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00069 typedef PGSTD::reverse_iterator<const_iterator> const_reverse_iterator;
00070 #endif
00071
00072 private:
00073 typedef internal::PQAlloc<value_type> super;
00074
00075 public:
00077
00080 explicit binarystring(const result::field &F);
00081
00083 size_type size() const throw () { return m_size; }
00085 size_type length() const throw () { return size(); }
00086 bool empty() const throw () { return size()==0; }
00087
00088 const_iterator begin() const throw () { return data(); }
00089 const_iterator end() const throw () { return data()+m_size; }
00090
00091 const_reference front() const throw () { return *begin(); }
00092 const_reference back() const throw () { return *(data()+m_size-1); }
00093
00094 #ifdef PQXX_HAVE_REVERSE_ITERATOR
00095 const_reverse_iterator rbegin() const
00096 { return const_reverse_iterator(end()); }
00097 const_reverse_iterator rend() const
00098 { return const_reverse_iterator(begin()); }
00099 #endif
00100
00102 const value_type *data() const throw () {return super::c_ptr();}
00103
00104 const_reference operator[](size_type i) const throw ()
00105 { return data()[i]; }
00106
00107 bool operator==(const binarystring &) const throw ();
00108 bool operator!=(const binarystring &rhs) const throw ()
00109 { return !operator==(rhs); }
00110
00112 const_reference at(size_type) const;
00113
00115 void swap(binarystring &);
00116
00118
00121 const char *c_ptr() const throw ()
00122 {
00123 return reinterpret_cast<char *>(super::c_ptr());
00124 }
00125
00127
00134 const PGSTD::string &str() const;
00135
00136 private:
00137 size_type m_size;
00138 mutable PGSTD::string m_str;
00139 };
00140
00141
00146
00147
00151 PGSTD::string PQXX_LIBEXPORT escape_binary(const PGSTD::string &bin);
00153
00157 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[]);
00159
00163 PGSTD::string PQXX_LIBEXPORT escape_binary(const char bin[], size_t len);
00165
00169 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[]);
00171
00175 PGSTD::string PQXX_LIBEXPORT escape_binary(const unsigned char bin[], size_t len);
00177
00178
00179 }
00180
00181 #include "pqxx/compiler-internal-post.hxx"