|
|
@@ -0,0 +1,478 @@
|
|
|
+#include "MySQLResultSetImpl.h"
|
|
|
+#include "MySQLResultSetMetaDataImpl.h"
|
|
|
+#include <stdexcept>
|
|
|
+#include <sstream>
|
|
|
+
|
|
|
+
|
|
|
+namespace MySQL {
|
|
|
+
|
|
|
+MySQLResultSetImpl::MySQLResultSetImpl()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+MySQLResultSetImpl::MySQLResultSetImpl(const std::shared_ptr<sql::ResultSet>& pResultSet) :
|
|
|
+ m_pResultSet(pResultSet)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+MySQLResultSetImpl::~MySQLResultSetImpl()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Absolute(int row)
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->absolute(row);
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::AfterLast()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->afterLast();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::BeforeFirst()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->beforeFirst();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::CancelRowUpdates()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->cancelRowUpdates();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::ClearWarnings()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->clearWarnings();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::Close()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->close();
|
|
|
+}
|
|
|
+
|
|
|
+uint32_t MySQLResultSetImpl::FindColumn(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->findColumn(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::First()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->first();
|
|
|
+}
|
|
|
+
|
|
|
+std::istream* MySQLResultSetImpl::Blob(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getBlob(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+std::istream* MySQLResultSetImpl::Blob(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getBlob(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Boolean(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getBoolean(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Boolean(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getBoolean(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+int MySQLResultSetImpl::Concurrency()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getConcurrency();
|
|
|
+}
|
|
|
+
|
|
|
+std::string MySQLResultSetImpl::CursorName()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getCursorName();
|
|
|
+}
|
|
|
+
|
|
|
+long double MySQLResultSetImpl::Double(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getDouble(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+long double MySQLResultSetImpl::Double(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getDouble(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+int MySQLResultSetImpl::FetchDirection()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getFetchDirection();
|
|
|
+}
|
|
|
+
|
|
|
+size_t MySQLResultSetImpl::FetchSize()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getFetchSize();
|
|
|
+}
|
|
|
+
|
|
|
+int MySQLResultSetImpl::Holdability()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getHoldability();
|
|
|
+}
|
|
|
+
|
|
|
+int32_t MySQLResultSetImpl::Int(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getInt(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+int32_t MySQLResultSetImpl::Int(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getInt(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+uint32_t MySQLResultSetImpl::UInt(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getUInt(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+uint32_t MySQLResultSetImpl::UInt(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getUInt(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+int64_t MySQLResultSetImpl::Int64(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getInt64(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+int64_t MySQLResultSetImpl::Int64(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getInt64(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+uint64_t MySQLResultSetImpl::UInt64(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getUInt64(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+uint64_t MySQLResultSetImpl::UInt64(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getUInt64(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+std::shared_ptr<MySQLResultSetMetaDataImpl> MySQLResultSetImpl::MetaData() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return std::make_shared<MySQLResultSetMetaDataImpl>(m_pResultSet->getMetaData());
|
|
|
+}
|
|
|
+
|
|
|
+size_t MySQLResultSetImpl::Row() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getRow();
|
|
|
+}
|
|
|
+/*
|
|
|
+RowID* MySQLResultSetImpl::RowId(uint32_t columnIndex)
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getRowId(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+RowID* MySQLResultSetImpl::RowId(const std::string & columnLabel)
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getRowId(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+const Statement* Statement() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getStatement();
|
|
|
+}
|
|
|
+*/
|
|
|
+std::string MySQLResultSetImpl::String(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getString(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+std::string MySQLResultSetImpl::String(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getString(columnLabel);
|
|
|
+}
|
|
|
+/*
|
|
|
+enum_type MySQLResultSetImpl::Type() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->getType();
|
|
|
+}
|
|
|
+*/
|
|
|
+void MySQLResultSetImpl::Warnings()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->getWarnings();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::InsertRow()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->insertRow();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsAfterLast() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isAfterLast();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsBeforeFirst() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isBeforeFirst();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsClosed() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isClosed();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsFirst() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isFirst();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsLast() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isLast();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsNull(uint32_t columnIndex) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isNull(columnIndex);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::IsNull(const std::string& columnLabel) const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->isNull(columnLabel);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Last()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->last();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Next()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->next();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::MoveToCurrentRow()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->moveToCurrentRow();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::MoveToInsertRow()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->moveToInsertRow();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Previous()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->previous();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::RefreshRow()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->refreshRow();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::Relative(int rows)
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->relative(rows);
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::RowDeleted()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->rowDeleted();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::RowInserted()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->rowInserted();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::RowUpdated()
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->rowUpdated();
|
|
|
+}
|
|
|
+
|
|
|
+void MySQLResultSetImpl::FetchSize(size_t rows)
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ m_pResultSet->setFetchSize(rows);
|
|
|
+}
|
|
|
+
|
|
|
+size_t MySQLResultSetImpl::RowsCount() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->rowsCount();
|
|
|
+}
|
|
|
+
|
|
|
+bool MySQLResultSetImpl::WasNull() const
|
|
|
+{
|
|
|
+ if (!m_pResultSet)
|
|
|
+ throw std::runtime_error("Empty Result");
|
|
|
+
|
|
|
+ return m_pResultSet->wasNull();
|
|
|
+}
|
|
|
+
|
|
|
+} // namespace MySQL
|