1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2011 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef DRIZZLED_PLUGIN_CLIENT_CACHED_H
23
#define DRIZZLED_PLUGIN_CLIENT_CACHED_H
26
#include <drizzled/plugin/client/concurrent.h>
27
#include <drizzled/sql/result_set.h>
29
#include <boost/scoped_ptr.hpp>
40
class Cached : public Concurrent
44
sql::ResultSet *_result_set;
47
Cached(sql::ResultSet &rs) :
55
virtual bool sendFields(List<Item> *list)
57
List<Item>::iterator it(list->begin());
66
item->make_field(&field);
69
_result_set->createRow();
74
virtual void sendError(drizzled::error_t error_code, const char *error_message)
76
sql::Exception tmp(error_message, error_code);
77
_result_set->pushException(tmp);
80
virtual void checkRowEnd(void)
82
if (++column % max_column == 0)
84
_result_set->createRow();
90
virtual bool store(Field *from)
95
char buff[MAX_FIELD_WIDTH];
96
String str(buff, sizeof(buff), &my_charset_bin);
97
from->val_str_internal(&str);
99
return store(str.ptr(), str.length());
102
virtual bool store(void)
104
_result_set->setColumnNull(currentColumn());
111
virtual bool store(int32_t from)
115
tmp= boost::lexical_cast<std::string>(from);
116
_result_set->setColumn(currentColumn(), tmp);
122
virtual bool store(uint32_t from)
126
tmp= boost::lexical_cast<std::string>(from);
127
_result_set->setColumn(currentColumn(), tmp);
133
virtual bool store(int64_t from)
137
tmp= boost::lexical_cast<std::string>(from);
138
_result_set->setColumn(currentColumn(), tmp);
144
virtual bool store(uint64_t from)
148
tmp= boost::lexical_cast<std::string>(from);
149
_result_set->setColumn(currentColumn(), tmp);
155
virtual bool store(double from, uint32_t decimals, String *buffer)
157
buffer->set_real(from, decimals, &my_charset_bin);
158
return store(buffer->ptr(), buffer->length());
161
virtual bool store(const char *from, size_t length)
163
_result_set->setColumn(currentColumn(), std::string(from, length));
169
inline uint32_t currentColumn() const
171
return column % max_column;
175
} /* namespace client */
176
} /* namespace plugin */
177
} /* namespace drizzled */
179
#endif /* DRIZZLED_PLUGIN_CLIENT_CACHED_H */