<NME> qtfirebasedatabase.h
<BEF> #ifndef QTFIREBASE_DATABASE_H
#define QTFIREBASE_DATABASE_H

#include "qtfirebaseservice.h"
#include "firebase/database.h"
#include <QMutex>

#ifdef QTFIREBASE_BUILD_DATABASE
#include "src/qtfirebase.h"
#if defined(qFirebaseDatabase)
#undef qFirebaseDatabase
#endif
#define qFirebaseDatabase (static_cast<QtFirebaseDatabase*>(QtFirebaseDatabase::instance()))

class QtFirebaseDatabaseRequest;
class QtFirebaseDatabase : public QtFirebaseService
{
    Q_OBJECT
    typedef QSharedPointer<QtFirebaseDatabase> Ptr;
public:
    static QtFirebaseDatabase* instance() {
        if(self == nullptr) {
            self = new QtFirebaseDatabase(nullptr);
            qDebug() << self << "::instance" << "singleton";
        }
        return self;
    }

    enum Error
    {
        ErrorNone = firebase::database::kErrorNone,
        ErrorDisconnected = firebase::database::kErrorDisconnected,
        ErrorExpiredToken = firebase::database::kErrorExpiredToken,
        ErrorInvalidToken = firebase::database::kErrorInvalidToken,
        ErrorMaxRetries = firebase::database::kErrorMaxRetries,
        ErrorNetworkError = firebase::database::kErrorNetworkError,
        ErrorOperationFailed = firebase::database::kErrorOperationFailed,
        ErrorOverriddenBySet = firebase::database::kErrorOverriddenBySet,
        ErrorPermissionDenied = firebase::database::kErrorPermissionDenied,
        ErrorUnavailable = firebase::database::kErrorUnavailable,
        ErrorUnknownError = firebase::database::kErrorUnknownError,
        ErrorWriteCanceled = firebase::database::kErrorWriteCanceled,
        ErrorInvalidVariantType = firebase::database::kErrorInvalidVariantType,
        ErrorConflictingOperationInProgress = firebase::database::kErrorConflictingOperationInProgress,
        ErrorTransactionAbortedByUser = firebase::database::kErrorTransactionAbortedByUser,
    };
    Q_ENUM(Error)

    //TODO implement database related functions
    //(not important to write/read data for now but useful for extended control)
    //https://firebase.google.com/docs/reference/cpp/class/firebase/database/database
private:
    explicit QtFirebaseDatabase(QObject *parent = nullptr);
    void init() override;
    void onFutureEvent(QString eventId, firebase::FutureBase future) override;

    QString futureKey(QtFirebaseDatabaseRequest* request) const;
    QtFirebaseDatabaseRequest* request(const QString& futureKey) const;
    void addFuture(QString requestId, QtFirebaseDatabaseRequest* request, firebase::FutureBase future);
    void unregisterRequest(QtFirebaseDatabaseRequest* request);
    QString prefix() const;
private:
    static QtFirebaseDatabase* self;
    Q_DISABLE_COPY(QtFirebaseDatabase)

    firebase::database::Database* m_db;
    QMap<QString, QtFirebaseDatabaseRequest*> m_requests;
    QMutex m_futureMutex;

    friend class QtFirebaseDatabaseRequest;
};

class QtFirebaseDataSnapshot: public QObject
{
    Q_OBJECT
public:
    QtFirebaseDataSnapshot(const firebase::database::DataSnapshot& snapshot);
public slots:
    bool exists() const;
    QString key() const;
    QVariant value() const;
    QByteArray jsonString() const;
    bool hasChildren() const;
    bool valid() const;

    //not implemented firebase functions
    //
    //currently can be accessed through qt json support (except priority), like
    //QJsonDocument doc = QJsonDocument::fromVariant(request->getSnapshot().value());
    //

    /*
    QtFirebaseDataSnapshot* child(const QString& path);
    size_t childrenCount() const;
    QtFirebaseDataSnapshot getChild(int i);
    QVariant priority() const;
    bool hasChild(const QString& path) const;
    */
private:
    const firebase::database::DataSnapshot& m_snapshot;
};

class QtFirebaseDatabaseRequest;
class QtFirebaseDatabaseQuery: public QObject
{
    Q_OBJECT
public:
    QtFirebaseDatabaseQuery();
public slots:
    QtFirebaseDatabaseQuery* orderByKey();
    QtFirebaseDatabaseQuery* orderByValue();
    QtFirebaseDatabaseQuery* orderByChild(const QString& path);
    QtFirebaseDatabaseQuery* orderByPriority();
    QtFirebaseDatabaseQuery* startAt(QVariant order_value);
    QtFirebaseDatabaseQuery* startAt(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* endAt(QVariant order_value);
    QtFirebaseDatabaseQuery* endAt(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* equalTo(QVariant order_value);
    QtFirebaseDatabaseQuery* equalTo(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* limitToFirst(size_t limit);
    QtFirebaseDatabaseQuery* limitToLast(size_t limit);
    void exec();
signals:
    void run();
private:
    void clear();
    bool valid() const;
    QtFirebaseDatabaseQuery* setQuery(const firebase::database::Query& query);
    firebase::database::Query& query();

    bool m_valid;
    firebase::database::Query m_query;
    friend class QtFirebaseDatabaseRequest;
};

class QtFirebaseDatabaseRequest: public QObject
{
    Q_OBJECT
    Q_PROPERTY(bool running READ running NOTIFY runningChanged)
    Q_PROPERTY(QtFirebaseDataSnapshot* snapshot READ snapshot NOTIFY snapshotChanged)
public:
    QtFirebaseDatabaseRequest();
    ~QtFirebaseDatabaseRequest();
public slots:
    //Data request
    QtFirebaseDatabaseRequest* child(const QString& path = QString());
    QtFirebaseDatabaseRequest* pushChild();
    void setValue(const QVariant& value);
    void exec();
    void updateTree(const QVariant& tree);
    void remove();

    //Filters
    QtFirebaseDatabaseQuery* orderByKey();
    QtFirebaseDatabaseQuery* orderByValue();
    QtFirebaseDatabaseQuery* orderByChild(const QString& path);
    QtFirebaseDatabaseQuery* orderByPriority();
    QtFirebaseDatabaseQuery* startAt(QVariant order_value);
    QtFirebaseDatabaseQuery* startAt(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* endAt(QVariant order_value);
    QtFirebaseDatabaseQuery* endAt(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* equalTo(QVariant order_value);
    QtFirebaseDatabaseQuery* equalTo(QVariant order_value, const QString& child_key);
    QtFirebaseDatabaseQuery* limitToFirst(size_t limit);
    QtFirebaseDatabaseQuery* limitToLast(size_t limit);

    //State
    bool running() const;
    int errorId() const;
    bool hasError() const;
    QString errorMsg() const;

    //Data access
    QString childKey() const;
    QtFirebaseDataSnapshot* snapshot();
public:
    void onFutureEvent(QString eventId, firebase::FutureBase future);
signals:
    void completed(bool success);
    void runningChanged();
    void snapshotChanged();
private slots:
    void onRun();
private:
    void setComplete(bool value);
    void setError(int errId, const QString& msg = QString());
    void clearError();
    QtFirebaseDatabaseQuery m_query;
    bool m_inComplexRequest;
    QtFirebaseDataSnapshot* m_snapshot;
    firebase::database::DatabaseReference m_dbRef;
    QString m_action;
    bool m_complete;
    QString m_pushChildKey;
    int m_errId;
    QString m_errMsg;
};

#endif //QTFIREBASE_BUILD_DATABASE

#endif // QTFIREBASE_DATABASE_H

<MSG> Add QtFirebaseDatabase private member initialization under constructor name

<DFF> @@ -59,6 +59,7 @@ private:
     void addFuture(QString requestId, QtFirebaseDatabaseRequest* request, firebase::FutureBase future);
     void unregisterRequest(QtFirebaseDatabaseRequest* request);
     QString prefix() const;
+
 private:
     static QtFirebaseDatabase* self;
     Q_DISABLE_COPY(QtFirebaseDatabase)

{'commit': 'diff --git a/src/qtfirebasedatabase.cpp b/src/qtfirebasedatabase.cpp\nindex d6ec3ad..64b5e8f 100644\n--- a/src/qtfirebasedatabase.cpp\n+++ b/src/qtfirebasedatabase.cpp\n@@ -5,8 +5,11 @@ namespace db = ::firebase::database;\n \n QtFirebaseDatabase* QtFirebaseDatabase::self = nullptr;\n \n-QtFirebaseDatabase::QtFirebaseDatabase(QObject *parent) : QtFirebaseService(parent),\n-    m_db(nullptr)\n+QtFirebaseDatabase::QtFirebaseDatabase(QObject *parent)\n+    : QtFirebaseService(parent)\n+    , m_db(nullptr)\n+    , m_requests()\n+    , m_futureMutex()\n {\n     startInit();\n }\ndiff --git a/src/qtfirebasedatabase.h b/src/qtfirebasedatabase.h\nindex 53ca7b3..0fc925d 100644\n--- a/src/qtfirebasedatabase.h\n+++ b/src/qtfirebasedatabase.h\n@@ -59,6 +59,7 @@ private:\n     void addFuture(QString requestId, QtFirebaseDatabaseRequest* request, firebase::FutureBase future);\n     void unregisterRequest(QtFirebaseDatabaseRequest* request);\n     QString prefix() const;\n+\n private:\n     static QtFirebaseDatabase* self;\n     Q_DISABLE_COPY(QtFirebaseDatabase)\n', 'commit_subject': 'Add QtFirebaseDatabase private member initialization under constructor name', 'repo_name': 'Larpon/QtFirebase', 'committer': {'name': 'lmp', 'email': 'ecbf240a7b317cfa5006d135d20f29fb92201b14@gmail.com', 'time_sec': '1574850208', 'tz_offset': '60', 'date': {'seconds': '1574850208'}}, 'commit_tree': '26388f8e2cc8c77577517edc9786bef74677f907', 'commit_message': 'Add QtFirebaseDatabase private member initialization under constructor name\n', 'language_name': 'C', 'license': 'mit', 'hunks': '@@ -59,6 +59,7 @@ private:\n     void addFuture(QString requestId, QtFirebaseDatabaseRequest* request, firebase::FutureBase future);\n     void unregisterRequest(QtFirebaseDatabaseRequest* request);\n     QString prefix() const;\n+\n private:\n     static QtFirebaseDatabase* self;\n     Q_DISABLE_COPY(QtFirebaseDatabase)\n', 'addition_count': 1, 'deletion_count': 0, 'src_file': 'a/src/qtfirebasedatabase.h', 'tgt_file': 'b/src/qtfirebasedatabase.h', 'file_extension': '.h', 'before_file': '#ifndef QTFIREBASE_DATABASE_H\n#define QTFIREBASE_DATABASE_H\n\n#include "qtfirebaseservice.h"\n#include "firebase/database.h"\n#include <QMutex>\n\n#ifdef QTFIREBASE_BUILD_DATABASE\n#include "src/qtfirebase.h"\n#if defined(qFirebaseDatabase)\n#undef qFirebaseDatabase\n#endif\n#define qFirebaseDatabase (static_cast<QtFirebaseDatabase*>(QtFirebaseDatabase::instance()))\n\nclass QtFirebaseDatabaseRequest;\nclass QtFirebaseDatabase : public QtFirebaseService\n{\n    Q_OBJECT\n    typedef QSharedPointer<QtFirebaseDatabase> Ptr;\npublic:\n    static QtFirebaseDatabase* instance() {\n        if(self == nullptr) {\n            self = new QtFirebaseDatabase(nullptr);\n            qDebug() << self << "::instance" << "singleton";\n        }\n        return self;\n    }\n\n    enum Error\n    {\n        ErrorNone = firebase::database::kErrorNone,\n        ErrorDisconnected = firebase::database::kErrorDisconnected,\n        ErrorExpiredToken = firebase::database::kErrorExpiredToken,\n        ErrorInvalidToken = firebase::database::kErrorInvalidToken,\n        ErrorMaxRetries = firebase::database::kErrorMaxRetries,\n        ErrorNetworkError = firebase::database::kErrorNetworkError,\n        ErrorOperationFailed = firebase::database::kErrorOperationFailed,\n        ErrorOverriddenBySet = firebase::database::kErrorOverriddenBySet,\n        ErrorPermissionDenied = firebase::database::kErrorPermissionDenied,\n        ErrorUnavailable = firebase::database::kErrorUnavailable,\n        ErrorUnknownError = firebase::database::kErrorUnknownError,\n        ErrorWriteCanceled = firebase::database::kErrorWriteCanceled,\n        ErrorInvalidVariantType = firebase::database::kErrorInvalidVariantType,\n        ErrorConflictingOperationInProgress = firebase::database::kErrorConflictingOperationInProgress,\n        ErrorTransactionAbortedByUser = firebase::database::kErrorTransactionAbortedByUser,\n    };\n    Q_ENUM(Error)\n\n    //TODO implement database related functions\n    //(not important to write/read data for now but useful for extended control)\n    //https://firebase.google.com/docs/reference/cpp/class/firebase/database/database\nprivate:\n    explicit QtFirebaseDatabase(QObject *parent = nullptr);\n    void init() override;\n    void onFutureEvent(QString eventId, firebase::FutureBase future) override;\n\n    QString futureKey(QtFirebaseDatabaseRequest* request) const;\n    QtFirebaseDatabaseRequest* request(const QString& futureKey) const;\n    void addFuture(QString requestId, QtFirebaseDatabaseRequest* request, firebase::FutureBase future);\n    void unregisterRequest(QtFirebaseDatabaseRequest* request);\n    QString prefix() const;\nprivate:\n    static QtFirebaseDatabase* self;\n    Q_DISABLE_COPY(QtFirebaseDatabase)\n\n    firebase::database::Database* m_db;\n    QMap<QString, QtFirebaseDatabaseRequest*> m_requests;\n    QMutex m_futureMutex;\n\n    friend class QtFirebaseDatabaseRequest;\n};\n\nclass QtFirebaseDataSnapshot: public QObject\n{\n    Q_OBJECT\npublic:\n    QtFirebaseDataSnapshot(const firebase::database::DataSnapshot& snapshot);\npublic slots:\n    bool exists() const;\n    QString key() const;\n    QVariant value() const;\n    QByteArray jsonString() const;\n    bool hasChildren() const;\n    bool valid() const;\n\n    //not implemented firebase functions\n    //\n    //currently can be accessed through qt json support (except priority), like\n    //QJsonDocument doc = QJsonDocument::fromVariant(request->getSnapshot().value());\n    //\n\n    /*\n    QtFirebaseDataSnapshot* child(const QString& path);\n    size_t childrenCount() const;\n    QtFirebaseDataSnapshot getChild(int i);\n    QVariant priority() const;\n    bool hasChild(const QString& path) const;\n    */\nprivate:\n    const firebase::database::DataSnapshot& m_snapshot;\n};\n\nclass QtFirebaseDatabaseRequest;\nclass QtFirebaseDatabaseQuery: public QObject\n{\n    Q_OBJECT\npublic:\n    QtFirebaseDatabaseQuery();\npublic slots:\n    QtFirebaseDatabaseQuery* orderByKey();\n    QtFirebaseDatabaseQuery* orderByValue();\n    QtFirebaseDatabaseQuery* orderByChild(const QString& path);\n    QtFirebaseDatabaseQuery* orderByPriority();\n    QtFirebaseDatabaseQuery* startAt(QVariant order_value);\n    QtFirebaseDatabaseQuery* startAt(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* endAt(QVariant order_value);\n    QtFirebaseDatabaseQuery* endAt(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* equalTo(QVariant order_value);\n    QtFirebaseDatabaseQuery* equalTo(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* limitToFirst(size_t limit);\n    QtFirebaseDatabaseQuery* limitToLast(size_t limit);\n    void exec();\nsignals:\n    void run();\nprivate:\n    void clear();\n    bool valid() const;\n    QtFirebaseDatabaseQuery* setQuery(const firebase::database::Query& query);\n    firebase::database::Query& query();\n\n    bool m_valid;\n    firebase::database::Query m_query;\n    friend class QtFirebaseDatabaseRequest;\n};\n\nclass QtFirebaseDatabaseRequest: public QObject\n{\n    Q_OBJECT\n    Q_PROPERTY(bool running READ running NOTIFY runningChanged)\n    Q_PROPERTY(QtFirebaseDataSnapshot* snapshot READ snapshot NOTIFY snapshotChanged)\npublic:\n    QtFirebaseDatabaseRequest();\n    ~QtFirebaseDatabaseRequest();\npublic slots:\n    //Data request\n    QtFirebaseDatabaseRequest* child(const QString& path = QString());\n    QtFirebaseDatabaseRequest* pushChild();\n    void setValue(const QVariant& value);\n    void exec();\n    void updateTree(const QVariant& tree);\n    void remove();\n\n    //Filters\n    QtFirebaseDatabaseQuery* orderByKey();\n    QtFirebaseDatabaseQuery* orderByValue();\n    QtFirebaseDatabaseQuery* orderByChild(const QString& path);\n    QtFirebaseDatabaseQuery* orderByPriority();\n    QtFirebaseDatabaseQuery* startAt(QVariant order_value);\n    QtFirebaseDatabaseQuery* startAt(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* endAt(QVariant order_value);\n    QtFirebaseDatabaseQuery* endAt(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* equalTo(QVariant order_value);\n    QtFirebaseDatabaseQuery* equalTo(QVariant order_value, const QString& child_key);\n    QtFirebaseDatabaseQuery* limitToFirst(size_t limit);\n    QtFirebaseDatabaseQuery* limitToLast(size_t limit);\n\n    //State\n    bool running() const;\n    int errorId() const;\n    bool hasError() const;\n    QString errorMsg() const;\n\n    //Data access\n    QString childKey() const;\n    QtFirebaseDataSnapshot* snapshot();\npublic:\n    void onFutureEvent(QString eventId, firebase::FutureBase future);\nsignals:\n    void completed(bool success);\n    void runningChanged();\n    void snapshotChanged();\nprivate slots:\n    void onRun();\nprivate:\n    void setComplete(bool value);\n    void setError(int errId, const QString& msg = QString());\n    void clearError();\n    QtFirebaseDatabaseQuery m_query;\n    bool m_inComplexRequest;\n    QtFirebaseDataSnapshot* m_snapshot;\n    firebase::database::DatabaseReference m_dbRef;\n    QString m_action;\n    bool m_complete;\n    QString m_pushChildKey;\n    int m_errId;\n    QString m_errMsg;\n};\n\n#endif //QTFIREBASE_BUILD_DATABASE\n\n#endif // QTFIREBASE_DATABASE_H\n', 'message': 'Add QtFirebaseDatabase private member initialization under constructor name\n', 'author_name': 'lmp', 'lang': 'h'}