LCOV - code coverage report
Current view: top level - core/db/sqlite - SPSqliteDriver.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2024-05-12 00:16:13 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2021-2022 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023-2024 Stappler LLC <admin@stappler.dev>
       4             : 
       5             : Permission is hereby granted, free of charge, to any person obtaining a copy
       6             : of this software and associated documentation files (the "Software"), to deal
       7             : in the Software without restriction, including without limitation the rights
       8             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9             : copies of the Software, and to permit persons to whom the Software is
      10             : furnished to do so, subject to the following conditions:
      11             : 
      12             : The above copyright notice and this permission notice shall be included in
      13             : all copies or substantial portions of the Software.
      14             : 
      15             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21             : THE SOFTWARE.
      22             : **/
      23             : 
      24             : #ifndef STAPPLER_DB_SQLITE_SPSQLITEDRIVER_H_
      25             : #define STAPPLER_DB_SQLITE_SPSQLITEDRIVER_H_
      26             : 
      27             : #include "SPSqlDriver.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::db::sqlite {
      30             : 
      31             : struct DriverHandle;
      32             : 
      33             : class Driver : public sql::Driver {
      34             : public:
      35             :         static Driver *open(pool_t *, ApplicationInterface *, StringView path = StringView());
      36             : 
      37             :         virtual ~Driver();
      38             : 
      39             :         virtual bool init(Handle handle, const Vector<StringView> &) override;
      40             : 
      41             :         virtual void performWithStorage(Handle handle, const Callback<void(const db::Adapter &)> &cb) const override;
      42             :         virtual BackendInterface *acquireInterface(Handle handle, pool_t *) const override;
      43             : 
      44             :         virtual Handle connect(const Map<StringView, StringView> &) const override;
      45             :         virtual void finish(Handle) const override;
      46             : 
      47             :         virtual Connection getConnection(Handle h) const override;
      48             : 
      49             :         virtual bool isValid(Handle) const override;
      50             :         virtual bool isValid(Connection) const override;
      51             :         virtual bool isIdle(Connection) const override;
      52             : 
      53             :         virtual Time getConnectionTime(Handle) const override;
      54             : 
      55           0 :         virtual bool isNotificationsSupported() const override { return false; }
      56             : 
      57             :         StringView getDbName(Handle) const;
      58             :         Value getInfo(Connection, int) const;
      59             : 
      60             :         void setUserId(Handle, int64_t) const;
      61             : 
      62             :         uint64_t insertWord(Handle, StringView) const;
      63             : 
      64             : protected:
      65             :         Driver(pool_t *, ApplicationInterface *, StringView);
      66             : 
      67             :         bool _init = false;
      68             : };
      69             : 
      70             : class ResultCursor : public db::ResultCursor {
      71             : public:
      72             :         static bool statusIsSuccess(int x);
      73             : 
      74             :         ResultCursor(const Driver *d, Driver::Connection, Driver::Result res, int);
      75             : 
      76             :         virtual ~ResultCursor();
      77             :         virtual bool isBinaryFormat(size_t field) const override;
      78             :         BackendInterface::StorageType getType(size_t field) const;
      79             :         virtual bool isNull(size_t field) const override;
      80             :         virtual StringView toString(size_t field) const override;
      81             :         virtual BytesView toBytes(size_t field) const override;
      82             :         virtual int64_t toInteger(size_t field) const override;
      83             :         virtual double toDouble(size_t field) const override;
      84             :         virtual bool toBool(size_t field) const override;
      85             :         virtual Value toTypedData(size_t field) const override;
      86             :         virtual Value toCustomData(size_t field, const FieldCustom *) const override;
      87             :         virtual int64_t toId() const override;
      88             :         virtual StringView getFieldName(size_t field) const override;
      89             :         virtual bool isSuccess() const override;
      90             :         virtual bool isEmpty() const override;
      91             :         virtual bool isEnded() const override;
      92             :         virtual size_t getFieldsCount() const override;
      93             :         virtual size_t getAffectedRows() const override;
      94             :         virtual size_t getRowsHint() const override;
      95             :         virtual Value getInfo() const override;
      96             :         virtual bool next() override;
      97             :         virtual void reset() override;
      98             :         virtual void clear() override;
      99             :         int getError() const;
     100             : 
     101             : public:
     102             :         const Driver *driver = nullptr;
     103             :         Driver::Connection conn = Driver::Connection(nullptr);
     104             :         Driver::Result result = Driver::Result(nullptr);
     105             :         int err = 0;
     106             : };
     107             : 
     108             : }
     109             : 
     110             : #endif /* STAPPLER_DB_SQLITE_SPSQLITEDRIVER_H_ */

Generated by: LCOV version 1.14