Modify some type names to meet the Google Style (#291)
This commit is contained in:
parent
dbf20200fc
commit
a71e37d86e
|
@ -60,7 +60,8 @@ template <typename C>
|
|||
class IOThreadStorage : public trantor::NonCopyable
|
||||
{
|
||||
public:
|
||||
using InitCallback = std::function<void(C &, size_t)>;
|
||||
using ValueType = C;
|
||||
using InitCallback = std::function<void(ValueType &, size_t)>;
|
||||
|
||||
template <typename... Args>
|
||||
IOThreadStorage(Args &&... args)
|
||||
|
@ -93,14 +94,14 @@ class IOThreadStorage : public trantor::NonCopyable
|
|||
*
|
||||
* This function may only be called in a request handler
|
||||
*/
|
||||
inline C &getThreadData()
|
||||
inline ValueType &getThreadData()
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
return _storage[idx];
|
||||
}
|
||||
|
||||
inline const C &getThreadData() const
|
||||
inline const ValueType &getThreadData() const
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
|
@ -112,39 +113,46 @@ class IOThreadStorage : public trantor::NonCopyable
|
|||
*
|
||||
* This function may only be called in a request handler
|
||||
*/
|
||||
inline void setThreadData(const C &newData)
|
||||
inline void setThreadData(const ValueType &newData)
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
_storage[idx] = newData;
|
||||
}
|
||||
|
||||
inline void setThreadData(C &&newData)
|
||||
inline void setThreadData(ValueType &&newData)
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
_storage[idx] = std::move(newData);
|
||||
}
|
||||
|
||||
inline C *operator->()
|
||||
inline ValueType *operator->()
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
return &_storage[idx];
|
||||
}
|
||||
|
||||
inline C &operator*()
|
||||
inline ValueType &operator*()
|
||||
{
|
||||
return getThreadData();
|
||||
}
|
||||
|
||||
inline const C &operator*() const
|
||||
inline const ValueType *operator->() const
|
||||
{
|
||||
size_t idx = app().getCurrentThreadIndex();
|
||||
assert(idx < _storage.size());
|
||||
return &_storage[idx];
|
||||
}
|
||||
|
||||
inline const ValueType &operator*() const
|
||||
{
|
||||
return getThreadData();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<C> _storage;
|
||||
std::vector<ValueType> _storage;
|
||||
};
|
||||
|
||||
} // namespace drogon
|
||||
|
|
|
@ -121,7 +121,7 @@ void HttpRequestParser::reset()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto req = _requestsPool.back();
|
||||
auto req = std::move(_requestsPool.back());
|
||||
_requestsPool.pop_back();
|
||||
_request = std::move(req);
|
||||
_request->setCreationDate(trantor::Date::now());
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace orm
|
|||
class Field
|
||||
{
|
||||
public:
|
||||
using size_type = unsigned long;
|
||||
using SizeType = unsigned long;
|
||||
|
||||
/// Column name
|
||||
const char *name() const;
|
||||
|
@ -189,7 +189,7 @@ class Field
|
|||
}
|
||||
|
||||
protected:
|
||||
Result::size_type _row;
|
||||
Result::SizeType _row;
|
||||
/**
|
||||
* Column number
|
||||
* You'd expect this to be a size_t, but due to the way reverse iterators
|
||||
|
@ -197,7 +197,7 @@ class Field
|
|||
*/
|
||||
long _column;
|
||||
friend class Row;
|
||||
Field(const Row &row, Row::size_type columnNum) noexcept;
|
||||
Field(const Row &row, Row::SizeType columnNum) noexcept;
|
||||
|
||||
private:
|
||||
const Result _result;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#ifdef _WIN32
|
||||
#define noexcept _NOEXCEPT
|
||||
#endif
|
||||
|
@ -45,10 +46,10 @@ enum class SqlStatus
|
|||
* number:
|
||||
*
|
||||
* @code
|
||||
* for (result::size_type i=0; i < R.size(); ++i) Process(R[i]);
|
||||
* for (Result::SizeType i=0; i < R.size(); ++i) Process(R[i]);
|
||||
* @endcode
|
||||
*
|
||||
* Result sets in libpqxx are lightweight, reference-counted wrapper objects
|
||||
* Result sets in libpqxx are lightweight, Reference-counted wrapper objects
|
||||
* which are relatively small and cheap to copy. Think of a result object as
|
||||
* a "smart pointer" to an underlying result set.
|
||||
*/
|
||||
|
@ -58,19 +59,19 @@ class Result
|
|||
Result(const ResultImplPtr &ptr) : _resultPtr(ptr)
|
||||
{
|
||||
}
|
||||
using difference_type = long;
|
||||
using size_type = unsigned long;
|
||||
using reference = Row;
|
||||
using DifferenceType = long;
|
||||
using SizeType = unsigned long;
|
||||
using Reference = Row;
|
||||
using ConstIterator = ConstResultIterator;
|
||||
using Iterator = ConstIterator;
|
||||
using row_size_type = unsigned long;
|
||||
using field_size_type = unsigned long;
|
||||
using RowSizeType = unsigned long;
|
||||
using FieldSizeType = unsigned long;
|
||||
|
||||
using ConstReverseIterator = ConstReverseResultIterator;
|
||||
using ReverseIterator = ConstReverseIterator;
|
||||
|
||||
size_type size() const noexcept;
|
||||
size_type capacity() const noexcept
|
||||
SizeType size() const noexcept;
|
||||
SizeType capacity() const noexcept
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
@ -89,18 +90,18 @@ class Result
|
|||
return size() == 0;
|
||||
}
|
||||
|
||||
reference front() const noexcept;
|
||||
reference back() const noexcept;
|
||||
Reference front() const noexcept;
|
||||
Reference back() const noexcept;
|
||||
|
||||
reference operator[](size_type index) const;
|
||||
reference at(size_type index) const;
|
||||
Reference operator[](SizeType index) const;
|
||||
Reference at(SizeType index) const;
|
||||
void swap(Result &) noexcept;
|
||||
|
||||
/// Number of columns in result.
|
||||
row_size_type columns() const noexcept;
|
||||
RowSizeType columns() const noexcept;
|
||||
|
||||
/// Name of column with this number (throws exception if it doesn't exist)
|
||||
const char *columnName(row_size_type number) const;
|
||||
const char *columnName(RowSizeType number) const;
|
||||
|
||||
/// If command was @c INSERT, @c UPDATE, or @c DELETE: number of affected
|
||||
/// rows
|
||||
|
@ -108,7 +109,7 @@ class Result
|
|||
* @return Number of affected rows if last command was @c INSERT, @c UPDATE,
|
||||
* or @c DELETE; zero for all other commands.
|
||||
*/
|
||||
size_type affectedRows() const noexcept;
|
||||
SizeType affectedRows() const noexcept;
|
||||
|
||||
/// For Mysql, Sqlite3 databases, return the auto-incrementing primary key
|
||||
/// after inserting
|
||||
|
@ -128,18 +129,18 @@ class Result
|
|||
friend class Field;
|
||||
friend class Row;
|
||||
/// Number of given column (throws exception if it doesn't exist).
|
||||
row_size_type columnNumber(const char colName[]) const;
|
||||
RowSizeType columnNumber(const char colName[]) const;
|
||||
/// Number of given column (throws exception if it doesn't exist).
|
||||
row_size_type columnNumber(const std::string &name) const
|
||||
RowSizeType columnNumber(const std::string &name) const
|
||||
{
|
||||
return columnNumber(name.c_str());
|
||||
}
|
||||
/// Get the column oid, for postgresql database
|
||||
int oid(row_size_type column) const noexcept;
|
||||
int oid(RowSizeType column) const noexcept;
|
||||
|
||||
const char *getValue(size_type row, row_size_type column) const;
|
||||
bool isNull(size_type row, row_size_type column) const;
|
||||
field_size_type getLength(size_type row, row_size_type column) const;
|
||||
const char *getValue(SizeType row, RowSizeType column) const;
|
||||
bool isNull(SizeType row, RowSizeType column) const;
|
||||
FieldSizeType getLength(SizeType row, RowSizeType column) const;
|
||||
|
||||
protected:
|
||||
Result()
|
||||
|
@ -156,8 +157,7 @@ inline void swap(Result &one, Result &two) noexcept
|
|||
namespace std
|
||||
{
|
||||
template <>
|
||||
inline void swap<drogon::orm::Result>(drogon::orm::Result &one,
|
||||
drogon::orm::Result &two) noexcept
|
||||
inline void swap(drogon::orm::Result &one, drogon::orm::Result &two) noexcept
|
||||
{
|
||||
one.swap(two);
|
||||
}
|
||||
|
|
|
@ -26,16 +26,17 @@ namespace orm
|
|||
class ConstResultIterator
|
||||
: public std::iterator<std::random_access_iterator_tag,
|
||||
const Row,
|
||||
Result::difference_type,
|
||||
Result::DifferenceType,
|
||||
ConstResultIterator,
|
||||
Row>,
|
||||
protected Row
|
||||
{
|
||||
public:
|
||||
using pointer = const Row *;
|
||||
using reference = Row;
|
||||
using size_type = Result::size_type;
|
||||
using difference_type = Result::difference_type;
|
||||
using reference = const Row &;
|
||||
using value_type = const Row;
|
||||
using size_type = Result::SizeType;
|
||||
using difference_type = Result::DifferenceType;
|
||||
// ConstResultIterator(const Row &t) noexcept : Row(t) {}
|
||||
|
||||
pointer operator->()
|
||||
|
@ -44,7 +45,7 @@ class ConstResultIterator
|
|||
}
|
||||
reference operator*()
|
||||
{
|
||||
return Row(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConstResultIterator operator++(int);
|
||||
|
@ -97,7 +98,7 @@ class ConstResultIterator
|
|||
|
||||
private:
|
||||
friend class Result;
|
||||
ConstResultIterator(const Result &r, size_type index) noexcept
|
||||
ConstResultIterator(const Result &r, SizeType index) noexcept
|
||||
: Row(r, index)
|
||||
{
|
||||
}
|
||||
|
@ -111,8 +112,8 @@ class ConstReverseResultIterator : private ConstResultIterator
|
|||
using iterator_type::difference_type;
|
||||
using iterator_type::iterator_category;
|
||||
using iterator_type::pointer;
|
||||
using value_type = iterator_type::value_type;
|
||||
using reference = iterator_type::reference;
|
||||
using iterator_type::value_type;
|
||||
using iterator_type::reference;
|
||||
|
||||
ConstReverseResultIterator(const ConstReverseResultIterator &rhs)
|
||||
: ConstResultIterator(rhs)
|
||||
|
|
|
@ -44,19 +44,19 @@ class ConstReverseRowIterator;
|
|||
class Row
|
||||
{
|
||||
public:
|
||||
using size_type = unsigned long;
|
||||
using reference = Field;
|
||||
using SizeType = unsigned long;
|
||||
using Reference = Field;
|
||||
using ConstIterator = ConstRowIterator;
|
||||
using Iterator = ConstIterator;
|
||||
using ConstReverseIterator = ConstReverseRowIterator;
|
||||
|
||||
using difference_type = long;
|
||||
using DifferenceType = long;
|
||||
|
||||
reference operator[](size_type index) const;
|
||||
reference operator[](const char columnName[]) const;
|
||||
reference operator[](const std::string &columnName) const;
|
||||
size_type size() const;
|
||||
size_type capacity() const noexcept
|
||||
Reference operator[](SizeType index) const;
|
||||
Reference operator[](const char columnName[]) const;
|
||||
Reference operator[](const std::string &columnName) const;
|
||||
SizeType size() const;
|
||||
SizeType capacity() const noexcept
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class Row
|
|||
long _index = 0;
|
||||
size_t _end = 0;
|
||||
friend class Result;
|
||||
Row(const Result &r, size_type index) noexcept;
|
||||
Row(const Result &r, SizeType index) noexcept;
|
||||
};
|
||||
|
||||
} // namespace orm
|
||||
|
|
|
@ -25,16 +25,17 @@ namespace orm
|
|||
{
|
||||
class ConstRowIterator : public std::iterator<std::random_access_iterator_tag,
|
||||
const Field,
|
||||
Row::difference_type,
|
||||
Row::DifferenceType,
|
||||
ConstRowIterator,
|
||||
Field>,
|
||||
protected Field
|
||||
{
|
||||
public:
|
||||
using pointer = const Field *;
|
||||
using reference = Field;
|
||||
using size_type = Row::size_type;
|
||||
using difference_type = Row::difference_type;
|
||||
using reference = const Field &;
|
||||
using value_type = const Field;
|
||||
using size_type = Row::SizeType;
|
||||
using difference_type = Row::DifferenceType;
|
||||
// ConstRowIterator(const Field &t) noexcept : Field(t) {}
|
||||
|
||||
pointer operator->()
|
||||
|
@ -43,7 +44,7 @@ class ConstRowIterator : public std::iterator<std::random_access_iterator_tag,
|
|||
}
|
||||
reference operator*()
|
||||
{
|
||||
return Field(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConstRowIterator operator++(int);
|
||||
|
@ -96,7 +97,7 @@ class ConstRowIterator : public std::iterator<std::random_access_iterator_tag,
|
|||
|
||||
private:
|
||||
friend class Row;
|
||||
ConstRowIterator(const Row &r, size_type column) noexcept : Field(r, column)
|
||||
ConstRowIterator(const Row &r, SizeType column) noexcept : Field(r, column)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -109,8 +110,8 @@ class ConstReverseRowIterator : private ConstRowIterator
|
|||
using iterator_type::difference_type;
|
||||
using iterator_type::iterator_category;
|
||||
using iterator_type::pointer;
|
||||
using value_type = iterator_type::value_type;
|
||||
using reference = iterator_type::reference;
|
||||
using iterator_type::reference;
|
||||
using iterator_type::value_type;
|
||||
|
||||
ConstReverseRowIterator(const ConstReverseRowIterator &rhs)
|
||||
: ConstRowIterator(rhs)
|
||||
|
|
|
@ -196,7 +196,7 @@ class CallbackHolder : public CallbackHolderBase
|
|||
// ; // value =
|
||||
// (*row)[sizeof...(Values)].asArray<VectorTypeTraits<ValueType>::ItemsType>();
|
||||
value =
|
||||
makeValue<ValueType>((*row)[(Row::size_type)sizeof...(Values)]);
|
||||
makeValue<ValueType>((*row)[(Row::SizeType)sizeof...(Values)]);
|
||||
}
|
||||
|
||||
run(row, isNull, std::forward<Values>(values)..., std::move(value));
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
using namespace drogon::orm;
|
||||
Field::Field(const Row &row, Row::size_type columnNum) noexcept
|
||||
: _row(Result::size_type(row._index)),
|
||||
Field::Field(const Row &row, Row::SizeType columnNum) noexcept
|
||||
: _row(Result::SizeType(row._index)),
|
||||
_column(columnNum),
|
||||
_result(row._result)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ using namespace drogon::orm;
|
|||
|
||||
Result::ConstIterator Result::begin() const noexcept
|
||||
{
|
||||
return ConstIterator(*this, (size_type)0);
|
||||
return ConstIterator(*this, (SizeType)0);
|
||||
}
|
||||
Result::ConstIterator Result::cbegin() const noexcept
|
||||
{
|
||||
|
@ -60,22 +60,22 @@ Result::ConstIterator Result::ConstReverseIterator::base() const noexcept
|
|||
return ++tmp;
|
||||
}
|
||||
|
||||
Result::reference Result::front() const noexcept
|
||||
Result::Reference Result::front() const noexcept
|
||||
{
|
||||
return Row(*this, 0);
|
||||
}
|
||||
|
||||
Result::reference Result::back() const noexcept
|
||||
Result::Reference Result::back() const noexcept
|
||||
{
|
||||
return Row(*this, size() - 1);
|
||||
}
|
||||
|
||||
Result::reference Result::operator[](size_type index) const
|
||||
Result::Reference Result::operator[](SizeType index) const
|
||||
{
|
||||
assert(index < size());
|
||||
return Row(*this, index);
|
||||
}
|
||||
Result::reference Result::at(size_type index) const
|
||||
Result::Reference Result::at(SizeType index) const
|
||||
{
|
||||
return operator[](index);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ ConstReverseResultIterator ConstReverseResultIterator::operator--(int)
|
|||
return old;
|
||||
}
|
||||
|
||||
Result::size_type Result::size() const noexcept
|
||||
Result::SizeType Result::size() const noexcept
|
||||
{
|
||||
return _resultPtr->size();
|
||||
}
|
||||
|
@ -115,33 +115,33 @@ void Result::swap(Result &other) noexcept
|
|||
{
|
||||
_resultPtr.swap(other._resultPtr);
|
||||
}
|
||||
Result::row_size_type Result::columns() const noexcept
|
||||
Result::RowSizeType Result::columns() const noexcept
|
||||
{
|
||||
return _resultPtr->columns();
|
||||
}
|
||||
const char *Result::columnName(Result::row_size_type number) const
|
||||
const char *Result::columnName(Result::RowSizeType number) const
|
||||
{
|
||||
return _resultPtr->columnName(number);
|
||||
}
|
||||
Result::size_type Result::affectedRows() const noexcept
|
||||
Result::SizeType Result::affectedRows() const noexcept
|
||||
{
|
||||
return _resultPtr->affectedRows();
|
||||
}
|
||||
Result::row_size_type Result::columnNumber(const char colName[]) const
|
||||
Result::RowSizeType Result::columnNumber(const char colName[]) const
|
||||
{
|
||||
return _resultPtr->columnNumber(colName);
|
||||
}
|
||||
const char *Result::getValue(Result::size_type row,
|
||||
Result::row_size_type column) const
|
||||
const char *Result::getValue(Result::SizeType row,
|
||||
Result::RowSizeType column) const
|
||||
{
|
||||
return _resultPtr->getValue(row, column);
|
||||
}
|
||||
bool Result::isNull(Result::size_type row, Result::row_size_type column) const
|
||||
bool Result::isNull(Result::SizeType row, Result::RowSizeType column) const
|
||||
{
|
||||
return _resultPtr->isNull(row, column);
|
||||
}
|
||||
Result::field_size_type Result::getLength(Result::size_type row,
|
||||
Result::row_size_type column) const
|
||||
Result::FieldSizeType Result::getLength(Result::SizeType row,
|
||||
Result::RowSizeType column) const
|
||||
{
|
||||
return _resultPtr->getLength(row, column);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ const std::string &Result::sql() const noexcept
|
|||
return _resultPtr->sql();
|
||||
}
|
||||
|
||||
int Result::oid(row_size_type column) const noexcept
|
||||
int Result::oid(RowSizeType column) const noexcept
|
||||
{
|
||||
return _resultPtr->oid(column);
|
||||
}
|
|
@ -26,15 +26,15 @@ class ResultImpl : public trantor::NonCopyable, public Result
|
|||
ResultImpl(const std::string &query) : _query(query)
|
||||
{
|
||||
}
|
||||
virtual size_type size() const noexcept = 0;
|
||||
virtual row_size_type columns() const noexcept = 0;
|
||||
virtual const char *columnName(row_size_type Number) const = 0;
|
||||
virtual size_type affectedRows() const noexcept = 0;
|
||||
virtual row_size_type columnNumber(const char colName[]) const = 0;
|
||||
virtual const char *getValue(size_type row, row_size_type column) const = 0;
|
||||
virtual bool isNull(size_type row, row_size_type column) const = 0;
|
||||
virtual field_size_type getLength(size_type row,
|
||||
row_size_type column) const = 0;
|
||||
virtual SizeType size() const noexcept = 0;
|
||||
virtual RowSizeType columns() const noexcept = 0;
|
||||
virtual const char *columnName(RowSizeType Number) const = 0;
|
||||
virtual SizeType affectedRows() const noexcept = 0;
|
||||
virtual RowSizeType columnNumber(const char colName[]) const = 0;
|
||||
virtual const char *getValue(SizeType row, RowSizeType column) const = 0;
|
||||
virtual bool isNull(SizeType row, RowSizeType column) const = 0;
|
||||
virtual FieldSizeType getLength(SizeType row,
|
||||
RowSizeType column) const = 0;
|
||||
virtual const std::string &sql() const
|
||||
{
|
||||
return _query;
|
||||
|
@ -43,7 +43,7 @@ class ResultImpl : public trantor::NonCopyable, public Result
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int oid(row_size_type column) const
|
||||
virtual int oid(RowSizeType column) const
|
||||
{
|
||||
(void)column;
|
||||
return 0;
|
||||
|
|
|
@ -18,28 +18,28 @@
|
|||
#include <drogon/orm/RowIterator.h>
|
||||
|
||||
using namespace drogon::orm;
|
||||
Row::Row(const Result &r, size_type index) noexcept
|
||||
Row::Row(const Result &r, SizeType index) noexcept
|
||||
: _result(r), _index(long(index)), _end(r.columns())
|
||||
{
|
||||
}
|
||||
Row::size_type Row::size() const
|
||||
Row::SizeType Row::size() const
|
||||
{
|
||||
return _end;
|
||||
}
|
||||
Row::reference Row::operator[](size_type index) const
|
||||
Row::Reference Row::operator[](SizeType index) const
|
||||
{
|
||||
if (index >= _end)
|
||||
throw RangeError("The indwx out of range");
|
||||
return Field(*this, index);
|
||||
}
|
||||
|
||||
Row::reference Row::operator[](const char columnName[]) const
|
||||
Row::Reference Row::operator[](const char columnName[]) const
|
||||
{
|
||||
auto N = _result.columnNumber(columnName);
|
||||
return Field(*this, N);
|
||||
}
|
||||
|
||||
Row::reference Row::operator[](const std::string &columnName) const
|
||||
Row::Reference Row::operator[](const std::string &columnName) const
|
||||
{
|
||||
return operator[](columnName.c_str());
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace orm
|
|||
Result makeResult(
|
||||
const std::shared_ptr<MYSQL_RES> &r = std::shared_ptr<MYSQL_RES>(nullptr),
|
||||
const std::string &query = "",
|
||||
Result::size_type affectedRows = 0,
|
||||
Result::SizeType affectedRows = 0,
|
||||
unsigned long long insertId = 0)
|
||||
{
|
||||
return Result(std::shared_ptr<MysqlResultImpl>(
|
||||
|
|
|
@ -18,26 +18,26 @@
|
|||
|
||||
using namespace drogon::orm;
|
||||
|
||||
Result::size_type MysqlResultImpl::size() const noexcept
|
||||
Result::SizeType MysqlResultImpl::size() const noexcept
|
||||
{
|
||||
return _rowsNum;
|
||||
}
|
||||
Result::row_size_type MysqlResultImpl::columns() const noexcept
|
||||
Result::RowSizeType MysqlResultImpl::columns() const noexcept
|
||||
{
|
||||
return _fieldNum;
|
||||
}
|
||||
const char *MysqlResultImpl::columnName(row_size_type number) const
|
||||
const char *MysqlResultImpl::columnName(RowSizeType number) const
|
||||
{
|
||||
assert(number < _fieldNum);
|
||||
if (_fieldArray)
|
||||
return _fieldArray[number].name;
|
||||
return "";
|
||||
}
|
||||
Result::size_type MysqlResultImpl::affectedRows() const noexcept
|
||||
Result::SizeType MysqlResultImpl::affectedRows() const noexcept
|
||||
{
|
||||
return _affectedRows;
|
||||
}
|
||||
Result::row_size_type MysqlResultImpl::columnNumber(const char colName[]) const
|
||||
Result::RowSizeType MysqlResultImpl::columnNumber(const char colName[]) const
|
||||
{
|
||||
if (!_fieldMapPtr)
|
||||
return -1;
|
||||
|
@ -47,7 +47,7 @@ Result::row_size_type MysqlResultImpl::columnNumber(const char colName[]) const
|
|||
return (*_fieldMapPtr)[col];
|
||||
return -1;
|
||||
}
|
||||
const char *MysqlResultImpl::getValue(size_type row, row_size_type column) const
|
||||
const char *MysqlResultImpl::getValue(SizeType row, RowSizeType column) const
|
||||
{
|
||||
if (_rowsNum == 0 || _fieldNum == 0)
|
||||
return NULL;
|
||||
|
@ -55,12 +55,12 @@ const char *MysqlResultImpl::getValue(size_type row, row_size_type column) const
|
|||
assert(column < _fieldNum);
|
||||
return (*_rowsPtr)[row].first[column];
|
||||
}
|
||||
bool MysqlResultImpl::isNull(size_type row, row_size_type column) const
|
||||
bool MysqlResultImpl::isNull(SizeType row, RowSizeType column) const
|
||||
{
|
||||
return getValue(row, column) == NULL;
|
||||
}
|
||||
Result::field_size_type MysqlResultImpl::getLength(size_type row,
|
||||
row_size_type column) const
|
||||
Result::FieldSizeType MysqlResultImpl::getLength(SizeType row,
|
||||
RowSizeType column) const
|
||||
{
|
||||
if (_rowsNum == 0 || _fieldNum == 0)
|
||||
return 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ class MysqlResultImpl : public ResultImpl
|
|||
public:
|
||||
MysqlResultImpl(const std::shared_ptr<MYSQL_RES> &r,
|
||||
const std::string &query,
|
||||
size_type affectedRows,
|
||||
SizeType affectedRows,
|
||||
unsigned long long insertId) noexcept
|
||||
: ResultImpl(query),
|
||||
_result(r),
|
||||
|
@ -44,8 +44,8 @@ class MysqlResultImpl : public ResultImpl
|
|||
if (_fieldNum > 0)
|
||||
{
|
||||
_fieldMapPtr = std::make_shared<
|
||||
std::unordered_map<std::string, row_size_type>>();
|
||||
for (row_size_type i = 0; i < _fieldNum; i++)
|
||||
std::unordered_map<std::string, RowSizeType>>();
|
||||
for (RowSizeType i = 0; i < _fieldNum; i++)
|
||||
{
|
||||
std::string fieldName = _fieldArray[i].name;
|
||||
std::transform(fieldName.begin(),
|
||||
|
@ -72,27 +72,26 @@ class MysqlResultImpl : public ResultImpl
|
|||
}
|
||||
}
|
||||
}
|
||||
virtual size_type size() const noexcept override;
|
||||
virtual row_size_type columns() const noexcept override;
|
||||
virtual const char *columnName(row_size_type number) const override;
|
||||
virtual size_type affectedRows() const noexcept override;
|
||||
virtual row_size_type columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual bool isNull(size_type row, row_size_type column) const override;
|
||||
virtual field_size_type getLength(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual SizeType size() const noexcept override;
|
||||
virtual RowSizeType columns() const noexcept override;
|
||||
virtual const char *columnName(RowSizeType number) const override;
|
||||
virtual SizeType affectedRows() const noexcept override;
|
||||
virtual RowSizeType columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual bool isNull(SizeType row, RowSizeType column) const override;
|
||||
virtual FieldSizeType getLength(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual unsigned long long insertId() const noexcept override;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<MYSQL_RES> _result;
|
||||
const Result::size_type _rowsNum;
|
||||
const Result::SizeType _rowsNum;
|
||||
const MYSQL_FIELD *_fieldArray;
|
||||
const Result::row_size_type _fieldNum;
|
||||
const size_type _affectedRows;
|
||||
const Result::RowSizeType _fieldNum;
|
||||
const SizeType _affectedRows;
|
||||
const unsigned long long _insertId;
|
||||
std::shared_ptr<std::unordered_map<std::string, row_size_type>>
|
||||
_fieldMapPtr;
|
||||
std::shared_ptr<std::unordered_map<std::string, RowSizeType>> _fieldMapPtr;
|
||||
std::shared_ptr<std::vector<std::pair<char **, std::vector<unsigned long>>>>
|
||||
_rowsPtr;
|
||||
};
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
using namespace drogon::orm;
|
||||
|
||||
Result::size_type PostgreSQLResultImpl::size() const noexcept
|
||||
Result::SizeType PostgreSQLResultImpl::size() const noexcept
|
||||
{
|
||||
return _result ? PQntuples(_result.get()) : 0;
|
||||
}
|
||||
Result::row_size_type PostgreSQLResultImpl::columns() const noexcept
|
||||
Result::RowSizeType PostgreSQLResultImpl::columns() const noexcept
|
||||
{
|
||||
auto ptr = const_cast<PGresult *>(_result.get());
|
||||
return ptr ? Result::row_size_type(PQnfields(ptr)) : 0;
|
||||
return ptr ? Result::RowSizeType(PQnfields(ptr)) : 0;
|
||||
}
|
||||
const char *PostgreSQLResultImpl::columnName(row_size_type number) const
|
||||
const char *PostgreSQLResultImpl::columnName(RowSizeType number) const
|
||||
{
|
||||
auto ptr = const_cast<PGresult *>(_result.get());
|
||||
if (ptr)
|
||||
|
@ -37,14 +37,14 @@ const char *PostgreSQLResultImpl::columnName(row_size_type number) const
|
|||
}
|
||||
throw "nullptr result"; // The program will never execute here
|
||||
}
|
||||
Result::size_type PostgreSQLResultImpl::affectedRows() const noexcept
|
||||
Result::SizeType PostgreSQLResultImpl::affectedRows() const noexcept
|
||||
{
|
||||
char *str = PQcmdTuples(_result.get());
|
||||
if (str == nullptr || str[0] == '\0')
|
||||
return 0;
|
||||
return atol(str);
|
||||
}
|
||||
Result::row_size_type PostgreSQLResultImpl::columnNumber(
|
||||
Result::RowSizeType PostgreSQLResultImpl::columnNumber(
|
||||
const char colName[]) const
|
||||
{
|
||||
auto ptr = const_cast<PGresult *>(_result.get());
|
||||
|
@ -58,22 +58,22 @@ Result::row_size_type PostgreSQLResultImpl::columnNumber(
|
|||
}
|
||||
throw "nullptr result"; // The program will never execute here
|
||||
}
|
||||
const char *PostgreSQLResultImpl::getValue(size_type row,
|
||||
row_size_type column) const
|
||||
const char *PostgreSQLResultImpl::getValue(SizeType row,
|
||||
RowSizeType column) const
|
||||
{
|
||||
return PQgetvalue(_result.get(), int(row), int(column));
|
||||
}
|
||||
bool PostgreSQLResultImpl::isNull(size_type row, row_size_type column) const
|
||||
bool PostgreSQLResultImpl::isNull(SizeType row, RowSizeType column) const
|
||||
{
|
||||
return PQgetisnull(_result.get(), int(row), int(column)) != 0;
|
||||
}
|
||||
Result::field_size_type PostgreSQLResultImpl::getLength(
|
||||
size_type row,
|
||||
row_size_type column) const
|
||||
Result::FieldSizeType PostgreSQLResultImpl::getLength(
|
||||
SizeType row,
|
||||
RowSizeType column) const
|
||||
{
|
||||
return PQgetlength(_result.get(), int(row), int(column));
|
||||
}
|
||||
int PostgreSQLResultImpl::oid(row_size_type column) const
|
||||
int PostgreSQLResultImpl::oid(RowSizeType column) const
|
||||
{
|
||||
return PQftype(_result.get(), (int)column);
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ class PostgreSQLResultImpl : public ResultImpl
|
|||
: ResultImpl(query), _result(r)
|
||||
{
|
||||
}
|
||||
virtual size_type size() const noexcept override;
|
||||
virtual row_size_type columns() const noexcept override;
|
||||
virtual const char *columnName(row_size_type number) const override;
|
||||
virtual size_type affectedRows() const noexcept override;
|
||||
virtual row_size_type columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual bool isNull(size_type row, row_size_type column) const override;
|
||||
virtual field_size_type getLength(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual int oid(row_size_type column) const override;
|
||||
virtual SizeType size() const noexcept override;
|
||||
virtual RowSizeType columns() const noexcept override;
|
||||
virtual const char *columnName(RowSizeType number) const override;
|
||||
virtual SizeType affectedRows() const noexcept override;
|
||||
virtual RowSizeType columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual bool isNull(SizeType row, RowSizeType column) const override;
|
||||
virtual FieldSizeType getLength(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual int oid(RowSizeType column) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PGresult> _result;
|
||||
|
|
|
@ -18,24 +18,24 @@
|
|||
|
||||
using namespace drogon::orm;
|
||||
|
||||
Result::size_type Sqlite3ResultImpl::size() const noexcept
|
||||
Result::SizeType Sqlite3ResultImpl::size() const noexcept
|
||||
{
|
||||
return _result.size();
|
||||
}
|
||||
Result::row_size_type Sqlite3ResultImpl::columns() const noexcept
|
||||
Result::RowSizeType Sqlite3ResultImpl::columns() const noexcept
|
||||
{
|
||||
return _result.empty() ? 0 : _result[0].size();
|
||||
}
|
||||
const char *Sqlite3ResultImpl::columnName(row_size_type number) const
|
||||
const char *Sqlite3ResultImpl::columnName(RowSizeType number) const
|
||||
{
|
||||
assert(number < _columnNames.size());
|
||||
return _columnNames[number].c_str();
|
||||
}
|
||||
Result::size_type Sqlite3ResultImpl::affectedRows() const noexcept
|
||||
Result::SizeType Sqlite3ResultImpl::affectedRows() const noexcept
|
||||
{
|
||||
return _affectedRows;
|
||||
}
|
||||
Result::row_size_type Sqlite3ResultImpl::columnNumber(
|
||||
Result::RowSizeType Sqlite3ResultImpl::columnNumber(
|
||||
const char colName[]) const
|
||||
{
|
||||
auto name = std::string(colName);
|
||||
|
@ -47,18 +47,18 @@ Result::row_size_type Sqlite3ResultImpl::columnNumber(
|
|||
}
|
||||
throw std::string("there is no column named ") + colName;
|
||||
}
|
||||
const char *Sqlite3ResultImpl::getValue(size_type row,
|
||||
row_size_type column) const
|
||||
const char *Sqlite3ResultImpl::getValue(SizeType row,
|
||||
RowSizeType column) const
|
||||
{
|
||||
auto col = _result[row][column];
|
||||
return col ? col->c_str() : nullptr;
|
||||
}
|
||||
bool Sqlite3ResultImpl::isNull(size_type row, row_size_type column) const
|
||||
bool Sqlite3ResultImpl::isNull(SizeType row, RowSizeType column) const
|
||||
{
|
||||
return !_result[row][column];
|
||||
}
|
||||
Result::field_size_type Sqlite3ResultImpl::getLength(size_type row,
|
||||
row_size_type column) const
|
||||
Result::FieldSizeType Sqlite3ResultImpl::getLength(SizeType row,
|
||||
RowSizeType column) const
|
||||
{
|
||||
auto col = _result[row][column];
|
||||
return col ? col->length() : 0;
|
||||
|
|
|
@ -33,16 +33,16 @@ class Sqlite3ResultImpl : public ResultImpl
|
|||
: ResultImpl(query)
|
||||
{
|
||||
}
|
||||
virtual size_type size() const noexcept override;
|
||||
virtual row_size_type columns() const noexcept override;
|
||||
virtual const char *columnName(row_size_type number) const override;
|
||||
virtual size_type affectedRows() const noexcept override;
|
||||
virtual row_size_type columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual bool isNull(size_type row, row_size_type column) const override;
|
||||
virtual field_size_type getLength(size_type row,
|
||||
row_size_type column) const override;
|
||||
virtual SizeType size() const noexcept override;
|
||||
virtual RowSizeType columns() const noexcept override;
|
||||
virtual const char *columnName(RowSizeType number) const override;
|
||||
virtual SizeType affectedRows() const noexcept override;
|
||||
virtual RowSizeType columnNumber(const char colName[]) const override;
|
||||
virtual const char *getValue(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual bool isNull(SizeType row, RowSizeType column) const override;
|
||||
virtual FieldSizeType getLength(SizeType row,
|
||||
RowSizeType column) const override;
|
||||
virtual unsigned long long insertId() const noexcept override;
|
||||
|
||||
private:
|
||||
|
|
2
trantor
2
trantor
|
@ -1 +1 @@
|
|||
Subproject commit 01d39264350bb972c8c91df6f7055a27b2e8050f
|
||||
Subproject commit 07771f6c19a7baba33d069cd8c9b1a65281faac4
|
Loading…
Reference in New Issue