mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
codebase formatting
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@@ -20,12 +21,10 @@ void ThrowSqliteError(sqlite3* db_handle, std::string_view action);
|
|||||||
SqliteDatabaseHandle OpenDatabase(const std::filesystem::path& path);
|
SqliteDatabaseHandle OpenDatabase(const std::filesystem::path& path);
|
||||||
|
|
||||||
void ExecSql(const SqliteDatabaseHandle& db_handle, std::string_view sql,
|
void ExecSql(const SqliteDatabaseHandle& db_handle, std::string_view sql,
|
||||||
const char* action);
|
const char* action);
|
||||||
|
|
||||||
void RollbackTransactionNoThrow(const SqliteDatabaseHandle& db_handle) noexcept;
|
void RollbackTransactionNoThrow(const SqliteDatabaseHandle& db_handle) noexcept;
|
||||||
|
|
||||||
} // namespace sqlite_export_service_internal
|
} // namespace sqlite_export_service_internal
|
||||||
|
|
||||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_CONNECTION_HELPERS_H_
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_CONNECTION_HELPERS_H_
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
/* Umbrella header for backward compatibility. */
|
/* Umbrella header for backward compatibility. */
|
||||||
|
|
||||||
#include "services/sqlite_handle_types.h"
|
|
||||||
#include "services/sqlite_connection_helpers.h"
|
#include "services/sqlite_connection_helpers.h"
|
||||||
|
#include "services/sqlite_handle_types.h"
|
||||||
#include "services/sqlite_statement_helpers.h"
|
#include "services/sqlite_statement_helpers.h"
|
||||||
|
|
||||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_EXPORT_SERVICE_HELPERS_H_
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_EXPORT_SERVICE_HELPERS_H_
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
@@ -33,4 +34,3 @@ struct BindParam {
|
|||||||
} // namespace sqlite_export_service_internal
|
} // namespace sqlite_export_service_internal
|
||||||
|
|
||||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_HANDLE_TYPES_H_
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_HANDLE_TYPES_H_
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @file services/sqlite_statement_helpers.h
|
* @file services/sqlite_statement_helpers.h
|
||||||
* @brief Declarations for statement-level SQLite helper functions and constants.
|
* @brief Declarations for statement-level SQLite helper functions and
|
||||||
|
* constants.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -112,4 +114,3 @@ std::string SerializeVector(const std::vector<std::string>& str_vec);
|
|||||||
} // namespace sqlite_export_service_internal
|
} // namespace sqlite_export_service_internal
|
||||||
|
|
||||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_STATEMENT_HELPERS_H_
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_SQLITE_STATEMENT_HELPERS_H_
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ static std::string FormatLocalLanguageCodes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GBNF grammar for structured brewery JSON output.
|
// GBNF grammar for structured brewery JSON output.
|
||||||
// @TODO move to a separate gbnf file if it grows in complexity or is shared across modules.
|
// @TODO move to a separate gbnf file if it grows in complexity or is shared
|
||||||
|
// across modules.
|
||||||
static constexpr std::string_view kBreweryJsonGrammar = R"json_brewery(
|
static constexpr std::string_view kBreweryJsonGrammar = R"json_brewery(
|
||||||
root ::= thought-block "{" ws "\"name_en\"" ws ":" ws string ws "," ws "\"description_en\"" ws ":" ws string ws "," ws "\"name_local\"" ws ":" ws string ws "," ws "\"description_local\"" ws ":" ws string ws "}" ws
|
root ::= thought-block "{" ws "\"name_en\"" ws ":" ws string ws "," ws "\"description_en\"" ws ":" ws string ws "," ws "\"name_local\"" ws ":" ws string ws "," ws "\"description_local\"" ws ":" ws string ws "}" ws
|
||||||
thought-block ::= [^{]*
|
thought-block ::= [^{]*
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "services/sqlite_export_service.h"
|
#include "services/sqlite_export_service.h"
|
||||||
#include "services/sqlite_export_service_helpers.h"
|
#include "services/sqlite_export_service_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
void SqliteExportService::Finalize() {
|
void SqliteExportService::Finalize() {
|
||||||
if (db_handle_ == nullptr) {
|
if (db_handle_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ void SqliteDatabaseDeleter::operator()(sqlite3* handle) const noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqliteStatementDeleter::operator()(sqlite3_stmt* statement) const noexcept {
|
void SqliteStatementDeleter::operator()(
|
||||||
|
sqlite3_stmt* statement) const noexcept {
|
||||||
if (statement != nullptr) {
|
if (statement != nullptr) {
|
||||||
sqlite3_finalize(statement);
|
sqlite3_finalize(statement);
|
||||||
}
|
}
|
||||||
@@ -23,7 +24,6 @@ void ThrowSqliteError(sqlite3* db_handle, std::string_view action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SqliteDatabaseHandle OpenDatabase(const std::filesystem::path& path) {
|
SqliteDatabaseHandle OpenDatabase(const std::filesystem::path& path) {
|
||||||
|
|
||||||
sqlite3* raw_handle = nullptr;
|
sqlite3* raw_handle = nullptr;
|
||||||
const int result = sqlite3_open(path.string().c_str(), &raw_handle);
|
const int result = sqlite3_open(path.string().c_str(), &raw_handle);
|
||||||
|
|
||||||
@@ -54,7 +54,8 @@ void ExecSql(const SqliteDatabaseHandle& db_handle, std::string_view sql,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RollbackTransactionNoThrow(const SqliteDatabaseHandle& db_handle) noexcept {
|
void RollbackTransactionNoThrow(
|
||||||
|
const SqliteDatabaseHandle& db_handle) noexcept {
|
||||||
if (!db_handle) {
|
if (!db_handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -63,4 +64,3 @@ void RollbackTransactionNoThrow(const SqliteDatabaseHandle& db_handle) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sqlite_export_service_internal
|
} // namespace sqlite_export_service_internal
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include "services/sqlite_statement_helpers.h"
|
#include "services/sqlite_statement_helpers.h"
|
||||||
#include "services/sqlite_connection_helpers.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <memory>
|
|
||||||
#include <limits>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
|
#include <cstring>
|
||||||
|
#include <limits>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "services/sqlite_connection_helpers.h"
|
||||||
|
|
||||||
namespace sqlite_export_service_internal {
|
namespace sqlite_export_service_internal {
|
||||||
|
|
||||||
@@ -95,4 +96,3 @@ std::string SerializeVector(const std::vector<std::string>& str_vec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sqlite_export_service_internal
|
} // namespace sqlite_export_service_internal
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "services/sqlite_export_service.h"
|
#include "services/sqlite_export_service.h"
|
||||||
#include "services/sqlite_export_service_helpers.h"
|
#include "services/sqlite_export_service_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
void SqliteExportService::InitializeSchema() const {
|
void SqliteExportService::InitializeSchema() const {
|
||||||
sqlite_export_service_internal::ExecSql(
|
sqlite_export_service_internal::ExecSql(
|
||||||
db_handle_, sqlite_export_service_internal::kCreateLocationsTableSql,
|
db_handle_, sqlite_export_service_internal::kCreateLocationsTableSql,
|
||||||
@@ -46,7 +45,6 @@ void SqliteExportService::RollbackAndCloseNoThrow() noexcept {
|
|||||||
location_cache_.clear();
|
location_cache_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SqliteExportService::Initialize() {
|
void SqliteExportService::Initialize() {
|
||||||
if (db_handle_ != nullptr) {
|
if (db_handle_ != nullptr) {
|
||||||
throw std::runtime_error("SQLite export service is already initialized");
|
throw std::runtime_error("SQLite export service is already initialized");
|
||||||
|
|||||||
Reference in New Issue
Block a user