diff options
author | AGaliuzov <AGaliuzov@luxoft.com> | 2016-06-23 05:30:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-23 05:30:34 -0700 |
commit | 833cac1b1de464f53d5709904a4ee24634be2936 (patch) | |
tree | eceabb5046166e9b3d3a02fcd76496f88a177390 /src/components/utils/include/utils | |
parent | 405c303a9ef5238c659374785c4bbdc1140ca564 (diff) | |
parent | 48692790e4819261878eed1525d391bdde149ff4 (diff) | |
download | sdl_core-833cac1b1de464f53d5709904a4ee24634be2936.tar.gz |
Merge pull request #618 from Kozoriz/feature/Cover_resumption_with_unit_tests
Cover resumption with unit tests
Diffstat (limited to 'src/components/utils/include/utils')
-rw-r--r-- | src/components/utils/include/utils/json_utils.h | 2 | ||||
-rw-r--r-- | src/components/utils/include/utils/qdb_wrapper/sql_database_impl.h (renamed from src/components/utils/include/utils/qdb_wrapper/sql_database.h) | 32 | ||||
-rw-r--r-- | src/components/utils/include/utils/sql_qt_wrapper/sql_database_impl.h (renamed from src/components/utils/include/utils/sql_qt_wrapper/sql_database.h) | 17 | ||||
-rw-r--r-- | src/components/utils/include/utils/sql_wrapper.h | 18 | ||||
-rw-r--r-- | src/components/utils/include/utils/sqlite_wrapper/sql_database_impl.h (renamed from src/components/utils/include/utils/sqlite_wrapper/sql_database.h) | 56 |
5 files changed, 61 insertions, 64 deletions
diff --git a/src/components/utils/include/utils/json_utils.h b/src/components/utils/include/utils/json_utils.h index f437049a82..2f7d398592 100644 --- a/src/components/utils/include/utils/json_utils.h +++ b/src/components/utils/include/utils/json_utils.h @@ -256,6 +256,8 @@ class JsonValueRef { JsonValueRef Append(const JsonValue& value); + void RemoveMember(const char* key); + void Clear(); bool IsValid() const; diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_database.h b/src/components/utils/include/utils/qdb_wrapper/sql_database_impl.h index 0130e6cf53..bdcc0929f1 100644 --- a/src/components/utils/include/utils/qdb_wrapper/sql_database.h +++ b/src/components/utils/include/utils/qdb_wrapper/sql_database_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,11 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_H_ -#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_H_ +#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_IMPL_H_ +#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_IMPL_H_ #include <qdb/qdb.h> #include <string> +#include "utils/sql_database.h" #include "qdb_wrapper/sql_error.h" #include "utils/lock.h" @@ -46,45 +47,45 @@ class SQLQuery; /** * Represents a connection to a database. */ -class SQLDatabase { +class SQLDatabaseImpl : public SQLDatabase { public: - explicit SQLDatabase(const std::string& db_name); - ~SQLDatabase(); + explicit SQLDatabaseImpl(const std::string& db_name); + ~SQLDatabaseImpl(); /** * Opens connection to the temporary in-memory database * @return true if successfully */ - bool Open(); + bool Open() OVERRIDE; /** * Closes connection to the database */ - void Close(); + void Close() OVERRIDE; /** * Begins a transaction on the database * @return true if successfully */ - bool BeginTransaction(); + bool BeginTransaction() OVERRIDE; /** * Commits a transaction to the database * @return true if successfully */ - bool CommitTransaction(); + bool CommitTransaction() OVERRIDE; /** * Rolls back a transaction on the database * @return true if successfully */ - bool RollbackTransaction(); + bool RollbackTransaction() OVERRIDE; /** * Gets information about the last error that occurred on the database * @return last error */ - SQLError LastError() const; + SQLError LastError() const OVERRIDE; /** * @brief HasErrors Indicate the status of the last executed operation. @@ -98,12 +99,13 @@ class SQLDatabase { */ bool Backup(); - protected: + std::string get_path() const OVERRIDE; + /** * Gets connection to the SQLite database * @return pointer to connection */ - qdb_hdl_t* conn() const; + qdb_hdl_t* conn() const OVERRIDE; private: /** @@ -139,4 +141,4 @@ class SQLDatabase { } // namespace dbms } // namespace utils -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_DATABASE_IMPL_H_ diff --git a/src/components/utils/include/utils/sql_qt_wrapper/sql_database.h b/src/components/utils/include/utils/sql_qt_wrapper/sql_database_impl.h index d12c4381d4..92d8bc5425 100644 --- a/src/components/utils/include/utils/sql_qt_wrapper/sql_database.h +++ b/src/components/utils/include/utils/sql_qt_wrapper/sql_database_impl.h @@ -1,5 +1,5 @@ -#ifndef SRC_COMPONENTS_POLICY_SQLITE_WRAPPER_INCLUDE_SQL_QT_WRAPPER_SQL_DATABASE -#define SRC_COMPONENTS_POLICY_SQLITE_WRAPPER_INCLUDE_SQL_QT_WRAPPER_SQL_DATABASE +#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_QT_WRAPPER_SQL_DATABASE_IMPL_H_ +#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_QT_WRAPPER_SQL_DATABASE_IMPL_H_ #include <string> @@ -7,6 +7,7 @@ #include "utils/lock.h" #include "utils/sql_qt_wrapper/sql_error.h" +#include "utils/sql_database.h" namespace utils { namespace dbms { @@ -14,12 +15,12 @@ namespace dbms { /** * Represents a connection to a database. */ -class SQLDatabase { +class SQLDatabaseImpl : public SQLDatabase { public: - SQLDatabase(); - SQLDatabase(const std::string& database_path, - const std::string& connection_name); - ~SQLDatabase(); + SQLDatabaseImpl(); + SQLDatabaseImpl(const std::string& database_path, + const std::string& connection_name); + ~SQLDatabaseImpl(); /** * Opens connection to the temporary in-memory database @@ -105,4 +106,4 @@ class SQLDatabase { } // namespace dbms } // namespace utils -#endif // SRC_COMPONENTS_POLICY_SQLITE_WRAPPER_INCLUDE_SQL_QT_WRAPPER_SQL_DATABASE +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_QT_WRAPPER_SQL_DATABASE_IMPL_H_ diff --git a/src/components/utils/include/utils/sql_wrapper.h b/src/components/utils/include/utils/sql_wrapper.h index 4ed7b4e3f3..41e8ad381c 100644 --- a/src/components/utils/include/utils/sql_wrapper.h +++ b/src/components/utils/include/utils/sql_wrapper.h @@ -30,18 +30,18 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_ -#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_ +#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_WRAPPER_H_ +#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_WRAPPER_H_ #if __QNX__ -#include "qdb_wrapper/sql_database.h" -#include "qdb_wrapper/sql_query.h" +#include "utils/qdb_wrapper/sql_database_impl.h" +#include "utils/qdb_wrapper/sql_query.h" #elif defined QT_PORT -#include "sql_qt_wrapper/sql_database.h" -#include "sql_qt_wrapper/sql_query.h" +#include "utils/sql_qt_wrapper/sql_database_impl.h" +#include "utils/sql_qt_wrapper/sql_query.h" #else // __QNX__ -#include "sqlite_wrapper/sql_database.h" -#include "sqlite_wrapper/sql_query.h" +#include "utils/sqlite_wrapper/sql_database_impl.h" +#include "utils/sqlite_wrapper/sql_query.h" #endif // __QNX__ -#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQL_WRAPPER_H_ diff --git a/src/components/utils/include/utils/sqlite_wrapper/sql_database.h b/src/components/utils/include/utils/sqlite_wrapper/sql_database_impl.h index 5fd3de5fa1..d9984604a9 100644 --- a/src/components/utils/include/utils/sqlite_wrapper/sql_database.h +++ b/src/components/utils/include/utils/sqlite_wrapper/sql_database_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,97 +30,94 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_H_ -#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_H_ +#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_IMPL_H_ +#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_IMPL_H_ #include <string> + +#include "utils/sql_database.h" #include "utils/sqlite_wrapper/sql_error.h" #include "utils/lock.h" -struct sqlite3; - namespace utils { namespace dbms { - -class SQLQuery; - /** * Represents a connection to a database. */ -class SQLDatabase { +class SQLDatabaseImpl : public SQLDatabase { public: - SQLDatabase(); - SQLDatabase(const std::string& database_path, - const std::string& connection_name); - ~SQLDatabase(); + SQLDatabaseImpl(); + explicit SQLDatabaseImpl(const std::string& filename); + ~SQLDatabaseImpl(); /** * Opens connection to the temporary in-memory database * @return true if successfully */ - bool Open(); + bool Open() OVERRIDE; /** * Closes connection to the database */ - void Close(); + void Close() OVERRIDE; /** * Begins a transaction on the database * @return true if successfully */ - bool BeginTransaction(); + bool BeginTransaction() OVERRIDE; /** * Commits a transaction to the database * @return true if successfully */ - bool CommitTransaction(); + bool CommitTransaction() OVERRIDE; /** * Rolls back a transaction on the database * @return true if successfully */ - bool RollbackTransaction(); + bool RollbackTransaction() OVERRIDE; /** * Gets information about the last error that occurred on the database * @return last error */ - SQLError LastError() const; + SQLError LastError() const OVERRIDE; /** * @brief HasErrors Indicate the status of the last executed operation. * * @return true in case last operation has any errors, false otherwise. */ - bool HasErrors() const; + bool HasErrors() const OVERRIDE; + + void set_path(const std::string& path) OVERRIDE; /** * @brief get_path databse location path. * * @return the path to the database location */ - std::string get_path() const; + std::string get_path() const OVERRIDE; /** * Checks if database is read/write * @return true if database is read/write */ - bool IsReadWrite(); + bool IsReadWrite() OVERRIDE; /** * Call backup for opened DB */ - bool Backup(); + bool Backup() OVERRIDE; - protected: #ifndef QT_PORT /** * Gets connection to the SQLite database * @return pointer to connection */ - sqlite3* conn() const; + sqlite3* conn() const OVERRIDE; #endif // QT_PORT private: @@ -139,12 +136,7 @@ class SQLDatabase { /** * The filename of database */ - const std::string database_path_; - - /** - * The database connection name - */ - const std::string connection_name_; + std::string database_name_; int error_; @@ -161,4 +153,4 @@ class SQLDatabase { } // namespace dbms } // namespace utils -#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_H_ +#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_IMPL_H_ |