Skip to content

Commit 078f30d

Browse files
committed
chore: lint cpp
1 parent 8ce124a commit 078f30d

5 files changed

Lines changed: 20 additions & 31 deletions

File tree

package/cpp/NitroSQLiteException.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
#include <exception>
44
#include <iostream>
5-
#include <string>
65
#include <optional>
6+
#include <string>
77

88
const std::string NITRO_SQLITE_EXCEPTION_PREFIX = "[NativeNitroSQLiteException]";
99

10-
1110
enum NitroSQLiteExceptionType {
1211
UnknownError,
1312
DatabaseCannotBeOpened,

package/cpp/operations.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "operations.hpp"
22
#include "NitroSQLiteException.hpp"
33
#include "logs.hpp"
4+
#include "specs/HybridNitroSQLiteQueryResult.hpp"
45
#include "utils.hpp"
56
#include <NitroModules/ArrayBuffer.hpp>
67
#include <cmath>
@@ -11,7 +12,6 @@
1112
#include <sqlite3.h>
1213
#include <sstream>
1314
#include <unistd.h>
14-
#include "specs/HybridNitroSQLiteQueryResult.hpp"
1515

1616
using namespace facebook;
1717
using namespace margelo::nitro;
@@ -123,7 +123,7 @@ void bindStatement(sqlite3_stmt* statement, const SQLiteQueryParams& values) {
123123
}
124124

125125
std::shared_ptr<HybridNitroSQLiteQueryResult> sqliteExecute(const std::string& dbName, const std::string& query,
126-
const std::optional<SQLiteQueryParams>& params) {
126+
const std::optional<SQLiteQueryParams>& params) {
127127
if (dbMap.count(dbName) == 0) {
128128
throw NitroSQLiteException::DatabaseNotOpen(dbName);
129129
}
@@ -286,4 +286,3 @@ SQLiteOperationResult sqliteExecuteLiteral(const std::string& dbName, const std:
286286
}
287287

288288
} // namespace margelo::rnnitrosqlite
289-

package/cpp/operations.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include "types.hpp"
43
#include "specs/HybridNitroSQLiteQueryResult.hpp"
4+
#include "types.hpp"
55

66
namespace margelo::rnnitrosqlite {
77

@@ -16,7 +16,8 @@ void sqliteAttachDb(const std::string& mainDBName, const std::string& docPath, c
1616

1717
void sqliteDetachDb(const std::string& mainDBName, const std::string& alias);
1818

19-
std::shared_ptr<HybridNitroSQLiteQueryResult> sqliteExecute(const std::string& dbName, const std::string& query, const std::optional<SQLiteQueryParams>& params);
19+
std::shared_ptr<HybridNitroSQLiteQueryResult> sqliteExecute(const std::string& dbName, const std::string& query,
20+
const std::optional<SQLiteQueryParams>& params);
2021

2122
SQLiteOperationResult sqliteExecuteLiteral(const std::string& dbName, const std::string& query);
2223

package/cpp/specs/HybridNitroSQLite.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <map>
1111
#include <string>
1212
#include <vector>
13-
#include "HybridNitroSQLiteQueryResult.hpp"
1413

1514
namespace margelo::nitro::rnnitrosqlite {
1615

@@ -52,7 +51,7 @@ void HybridNitroSQLite::detach(const std::string& mainDbName, const std::string&
5251
};
5352

5453
std::shared_ptr<HybridNitroSQLiteQueryResultSpec> HybridNitroSQLite::execute(const std::string& dbName, const std::string& query,
55-
const std::optional<SQLiteQueryParams>& params) {
54+
const std::optional<SQLiteQueryParams>& params) {
5655
return sqliteExecute(dbName, query, params);
5756
};
5857

package/cpp/specs/HybridNitroSQLiteQueryResult.hpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,28 @@ namespace margelo::nitro::rnnitrosqlite {
1111
class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
1212
public:
1313
HybridNitroSQLiteQueryResult() : HybridObject(TAG) {}
14-
HybridNitroSQLiteQueryResult(SQLiteQueryResults results,
15-
std::optional<double> insertId,
16-
double rowsAffected,
14+
HybridNitroSQLiteQueryResult(SQLiteQueryResults results, std::optional<double> insertId, double rowsAffected,
1715
std::optional<SQLiteQueryTableMetadata> metadata)
18-
: HybridObject(TAG),
19-
_insertId(insertId),
20-
_rowsAffected(rowsAffected),
21-
_results(std::move(results)),
22-
_metadata(metadata) {
16+
: HybridObject(TAG), _insertId(insertId), _rowsAffected(rowsAffected), _results(std::move(results)), _metadata(metadata) {
2317
if (_results.empty()) {
2418
// Empty rows: empty vector, length 0, item callback always returns null
2519
auto emptyItem = [](double /* idx */) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
26-
return Promise<std::optional<SQLiteQueryResultRow>>::async(
27-
[]() -> std::optional<SQLiteQueryResultRow> { return std::nullopt; });
20+
return Promise<std::optional<SQLiteQueryResultRow>>::async([]() -> std::optional<SQLiteQueryResultRow> { return std::nullopt; });
2821
};
2922
_rows = NitroSQLiteQueryResultRows(SQLiteQueryResults{}, 0.0, std::move(emptyItem));
3023
return;
3124
}
3225

3326
auto rows = _results;
34-
auto itemFunction =
35-
[rows](double idx) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
36-
return Promise<std::optional<SQLiteQueryResultRow>>::async(
37-
[rows, idx]() -> std::optional<SQLiteQueryResultRow> {
38-
const auto index = static_cast<size_t>(idx);
39-
if (index >= rows.size()) {
40-
return std::nullopt;
41-
}
42-
return rows[index];
43-
});
44-
};
27+
auto itemFunction = [rows](double idx) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
28+
return Promise<std::optional<SQLiteQueryResultRow>>::async([rows, idx]() -> std::optional<SQLiteQueryResultRow> {
29+
const auto index = static_cast<size_t>(idx);
30+
if (index >= rows.size()) {
31+
return std::nullopt;
32+
}
33+
return rows[index];
34+
});
35+
};
4536

4637
const auto length = static_cast<double>(rows.size());
4738
_rows = NitroSQLiteQueryResultRows(std::move(rows), length, std::move(itemFunction));
@@ -52,7 +43,7 @@ class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
5243
double _rowsAffected;
5344
SQLiteQueryResults _results;
5445
std::optional<NitroSQLiteQueryResultRows> _rows;
55-
std::optional<SQLiteQueryTableMetadata>_metadata;
46+
std::optional<SQLiteQueryTableMetadata> _metadata;
5647

5748
public:
5849
// Properties

0 commit comments

Comments
 (0)