moved redundant read value code into query_result_reader
This commit is contained in:
@@ -32,106 +32,4 @@ bool postgres_result_reader::fetch()
|
||||
return ++row_index_ < row_count_;
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, char &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, short &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, int &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, long &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, long long int &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, unsigned char &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, unsigned short &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, unsigned int &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, unsigned long &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, unsigned long long int &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, bool &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, float &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, double &value)
|
||||
{
|
||||
sql::to_value(value, PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index)));
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, char *value, size_t s)
|
||||
{
|
||||
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
|
||||
|
||||
size_t len = strlen(value);
|
||||
if (len > (size_t)s) {
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(val, s, value, s);
|
||||
#else
|
||||
strncpy(val, value, s);
|
||||
#endif
|
||||
val[s-1] = '\n';
|
||||
} else {
|
||||
#ifdef _MSC_VER
|
||||
strcpy_s(val, s, value);
|
||||
#else
|
||||
strcpy(val, value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, std::string &value)
|
||||
{
|
||||
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
|
||||
if (strlen(val) != 0) {
|
||||
value.assign(val);
|
||||
}
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char *id, size_t index, std::string &value, size_t s)
|
||||
{
|
||||
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
|
||||
if (strlen(val) != 0) {
|
||||
value.assign(val);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user