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 : PQAlloc<unsigned char>
00042 {
00043
00044 public:
00045 typedef unsigned char char_type;
00046 typedef PGSTD::char_traits<char_type>::char_type value_type;
00047 typedef size_t size_type;
00048 typedef ptrdiff_t difference_type;
00049 typedef const value_type &const_reference;
00050 typedef const value_type *const_pointer;
00051 typedef const_pointer const_iterator;
00052 typedef PGSTD::reverse_iterator<const_iterator> const_reverse_iterator;
00053
00054 private:
00055 typedef PQAlloc<value_type> super;
00056
00057 public:
00059
00062 explicit binarystring(const result::field &F);
00063
00065 size_type size() const throw () { return m_size; }
00066 size_type length() const throw () { return size(); }
00067 bool empty() const throw () { return size()==0; }
00068
00069 const_iterator begin() const throw () { return data(); }
00070 const_iterator end() const throw () { return data()+m_size; }
00071
00072 const_reverse_iterator rbegin() const
00073 { return const_reverse_iterator(end()); }
00074 const_reverse_iterator rend() const
00075 { return const_reverse_iterator(begin()); }
00076
00078 const value_type *data() const throw () {return super::c_ptr();}
00079
00080 const_reference operator[](size_type i) const throw ()
00081 { return data()[i]; }
00082
00083 const_reference at(size_type n) const;
00084
00086 const char *c_ptr() const throw ()
00087 {
00088 return reinterpret_cast<char *>(super::c_ptr());
00089 }
00090
00092
00094 const PGSTD::string &str() const;
00095
00096 private:
00097 size_type m_size;
00098 mutable PGSTD::string m_str;
00099 };
00100
00101
00103 PGSTD::string escape_binary(const PGSTD::string &bin);
00105 PGSTD::string escape_binary(const char bin[]);
00107 PGSTD::string escape_binary(const char bin[], size_t len);
00109 PGSTD::string escape_binary(const unsigned char bin[]);
00111 PGSTD::string escape_binary(const unsigned char bin[], size_t len);
00112
00113
00114 }
00115