11 #ifndef _MARIADB_DATA_HPP_ 12 #define _MARIADB_DATA_HPP_ 19 template <
typename Type>
32 create(data, static_cast<u32>(count));
48 if (
m_data == 0)
return false;
51 m_size =
sizeof(Type) * count;
68 Type*
data =
new Type[count];
70 if (data == 0)
return false;
78 m_size =
sizeof(Type) * count;
108 inline Type*
get()
const {
return m_data; }
113 inline operator Type*() {
return m_data; }
114 inline operator Type*()
const {
return m_data; }
119 std::streamsize
read(char_type* buffer, std::streamsize
size) {
120 const std::streamsize amount =
static_cast<std::streamsize
>(
m_size -
m_position);
121 const std::streamsize result = std::min(size, amount);
129 return size ? -1 : 0;
132 std::streamsize
write(char_type* buffer, std::streamsize
size) {
133 const std::streamsize amount =
static_cast<std::streamsize
>(
m_size -
m_position);
134 const std::streamsize result = std::min(size, amount);
142 return size ? -1 : 0;
145 std::streampos
seek(std::streampos offset, std::ios_base::seekdir seekdir) {
148 if (seekdir == std::ios_base::beg)
150 else if (seekdir == std::ios_base::cur)
152 else if (seekdir == std::ios_base::end)
155 throw std::ios_base::failure(
"Bad seek direction");
157 if (pos < 0 || pos >
m_size)
throw std::ios_base::failure(
"Bad seek offset");
170 typedef std::shared_ptr< ::mariadb::data<char> >
data_ref;
data(const Type *data, size_t count)
std::basic_iostream< ::mariadb::data< char > > data_stream
std::streamsize write(char_type *buffer, std::streamsize size)
std::streamsize read(char_type *buffer, std::streamsize size)
std::shared_ptr< ::mariadb::data< char > > data_ref
std::streampos seek(std::streampos offset, std::ios_base::seekdir seekdir)
bool create(const Type *data, u32 count)
std::string string() const