Skip to content

Commit e5b3211

Browse files
committed
Formatted and fixed includes.
Updated main functions to use libcli.
1 parent f6821ba commit e5b3211

File tree

63 files changed

+186
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+186
-234
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
BasedOnStyle: Google
2+
BasedOnStyle: Google

.clang-tidy

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2-
Checks: '*, -fuchsia-trailing-return, -fuchsia-default-arguments-declarations, -readability-identifier-length, -llvmlibc-restrict-system-libc-headers, -llvmlibc-implementation-in-namespace, -llvmlibc-callee-namespace, -fuchsia-default-arguments-calls, -altera-unroll-loops, -fuchsia-overloaded-operator, -altera-id-dependent-backward-branch, -altera-struct-pack-align'
2+
Checks: "*, -fuchsia-trailing-return, -fuchsia-default-arguments-declarations, -readability-identifier-length, -llvmlibc-restrict-system-libc-headers, -llvmlibc-implementation-in-namespace, -llvmlibc-callee-namespace, -fuchsia-default-arguments-calls, -altera-unroll-loops, -fuchsia-overloaded-operator, -altera-id-dependent-backward-branch, -altera-struct-pack-align"
33
CheckOptions:
4-
- { key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: true }
4+
- {
5+
key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic,
6+
value: true,
7+
}

.clangd

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
2+
23
Diagnostics:
3-
UnusedIncludes: Strict
4+
UnusedIncludes: Strict

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ build
33
lib
44
.cache
55
.TODO
6-
.vscode
6+
.vscode

build.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ docker compose -f ./src/app/docker_test/docker-compose.yml build
1818
# Upload Docker test app images to Docker Hub.
1919
docker compose -f ./src/app/docker_test/docker-compose.yml push
2020

21-
22-
23-
2421
# run kubernetes deployment
2522
kompose convert
26-
# use something like all yaml files
23+
# use something like all yaml files
2724
kubectl apply -f pds-tcp-service.yaml,pds-pod.yaml,stec-tcp-service.yaml,stec-pod.yaml
2825

2926
# run ngrok which opens port to kubernetes
3027

3128
# stop deployment
32-
kubectl delete -f pds-tcp-service.yaml,pds-pod.yaml,stec-tcp-service.yaml,stec-pod.yaml
29+
kubectl delete -f pds-tcp-service.yaml,pds-pod.yaml,stec-tcp-service.yaml,stec-pod.yaml

include/app/app_network_restsdk_injector.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace stonks::app::injectors {
1212
[[nodiscard]] inline auto MakeNetworkRestsdkInjector() {
1313
return di::MakeInjector(
1414
di::BindInterfaceToImplementation<network::IRestRequestReceiver,
15-
restsdk::RestRequestReceiver>(),
15+
restsdk::RestRequestReceiver>(),
1616
di::BindInterfaceToImplementation<network::IRestRequestSender,
17-
restsdk::RestRequestSender>());
17+
restsdk::RestRequestSender>());
1818
}
1919
} // namespace stonks::app::injectors
2020

include/app/app_nosqldb_aws_injector.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace stonks::app::injectors {
1010
[[nodiscard]] inline auto MakeNosqldbAwsInjector() {
1111
return di::MakeInjector(
1212
di::BindInterfaceToImplementation<nosqldb::ITablesInterface,
13-
aws::dynamodb::SyncDbProxy>(),
13+
aws::dynamodb::SyncDbProxy>(),
1414
di::BindInterfaceToImplementation<nosqldb::IItemsInterface,
15-
aws::dynamodb::SyncDbProxy>(),
15+
aws::dynamodb::SyncDbProxy>(),
1616
di::BindInterfaceToImplementation<nosqldb::IDb,
17-
aws::dynamodb::SyncDbProxy>());
17+
aws::dynamodb::SyncDbProxy>());
1818
}
1919
} // namespace stonks::app::injectors
2020

include/app/app_sqldb_sqlite_injector.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace stonks::app::injectors {
2323
return di::MakeInjector(
2424
di::BindInterfaceToImplementation<sqldb::IDb, sqlite::Db>(),
2525
di::BindInterfaceToImplementation<sqldb::IQueryBuilder,
26-
sqlite::QueryBuilder>(),
26+
sqlite::QueryBuilder>(),
2727
di::BindTypeToFactoryFunction<
2828
sqlite::SqliteDbHandle, SqliteDbHandleFactory,
2929
sqlite::DbHandlesFactory, sqlite::FilePath>(),
3030
di::BindTypeToOtherType<sqlite::SqliteDbHandleVariant,
31-
sqlite::SqliteDbFileHandle>());
31+
sqlite::SqliteDbFileHandle>());
3232
}
3333
} // namespace stonks::app::injectors
3434

include/app/docker_test/persistent_db_server/app_dt_pds_app_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define STONKS_APP_DOCKER_TEST_PERSISTENT_DB_SERVER_APP_DT_PDS_APP_SERVER_H_
33

44
#include "app_dt_pds_app.h"
5-
#include "di_factory.h"
65
#include "cpp_not_null.h"
6+
#include "di_factory.h"
77
#include "network_i_rest_request_receiver.h"
88
#include "network_types.h"
99

include/app/docker_test/server_to_external_client/app_dt_stec_app_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define STONKS_APP_DOCKER_TEST_SERVER_TO_EXTERNAL_CLIENT_APP_DT_STEC_APP_SERVER_H_
33

44
#include "app_dt_stec_app.h"
5-
#include "di_factory.h"
65
#include "cpp_not_null.h"
6+
#include "di_factory.h"
77
#include "network_i_rest_request_receiver.h"
88
#include "network_types.h"
99

include/app/public_nosql_db/app_pnd_items_interface_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef STONKS_APP_PUBLIC_NOSQL_DB_APP_PND_ITEMS_INTERFACE_SERVER_H_
22
#define STONKS_APP_PUBLIC_NOSQL_DB_APP_PND_ITEMS_INTERFACE_SERVER_H_
33

4-
#include "di_factory.h"
54
#include "cpp_not_null.h"
5+
#include "di_factory.h"
66
#include "network_i_rest_request_receiver.h"
77
#include "network_types.h"
88
#include "nosqldb_i_items_interface.h"

include/cli/cli_app.h

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class App {
2020
App(int argc, const char *const *argv);
2121

2222
/**
23-
* @brief Runs the application until it's interrupted
24-
* @tparam Main Function to execute inside application. Has access to
25-
* application options and must produce an instance.
23+
* @brief Runs the application until it's interrupted.
24+
* @tparam Main Function to execute inside application.
25+
* Has access to application options and must produce an instance.
2626
*/
2727
template <std::invocable<const Options &> Main>
2828
void Run(const Main &main) {
@@ -33,6 +33,18 @@ class App {
3333
const auto instance = main(options);
3434
}
3535

36+
/**
37+
* @brief Runs the application until it's interrupted.
38+
* @tparam Main Function to execute inside application.
39+
* Must produce an instance.
40+
*/
41+
template <std::invocable Main>
42+
void Run(const Main &main) {
43+
const auto run_scope =
44+
cpp::CallExposedPrivateConstructorOf<RunScope, App>{}(app_);
45+
const auto instance = main();
46+
}
47+
3648
private:
3749
cpp::NnSp<CLI::App> app_;
3850
};

include/di/di_bind_interface_to_implementation.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#include <boost/di.hpp>
55

6+
#include "cpp_not_null.h"
67
#include "di_factory.h"
78
#include "di_make_injector.h"
8-
#include "cpp_not_null.h"
99

1010
namespace stonks::di {
1111
namespace detail {
@@ -16,10 +16,11 @@ struct AssumedNn : public cpp::Nn<T> {
1616

1717
template <typename Interface>
1818
[[nodiscard]] auto EnableNn() {
19-
return MakeInjector(::boost::di::bind<cpp::NnUp<Interface>>()
20-
.template to<detail::AssumedNn<cpp::Up<Interface>>>(),
21-
::boost::di::bind<cpp::NnSp<Interface>>()
22-
.template to<detail::AssumedNn<cpp::Sp<Interface>>>());
19+
return MakeInjector(
20+
::boost::di::bind<cpp::NnUp<Interface>>()
21+
.template to<detail::AssumedNn<cpp::Up<Interface>>>(),
22+
::boost::di::bind<cpp::NnSp<Interface>>()
23+
.template to<detail::AssumedNn<cpp::Sp<Interface>>>());
2324
}
2425

2526
template <typename Interface, std::derived_from<Interface> Implementation>

include/di/di_bind_type_to_factory_function.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace stonks::di {
88
namespace detail {
99
template <typename Type, typename FactoryFunction, typename... Args>
10-
requires std::is_invocable_r_v<Type, FactoryFunction, Args...>
10+
requires std::is_invocable_r_v<Type, FactoryFunction, Args...>
1111
struct FactoryFunctionInjector : public Type {
1212
explicit FactoryFunctionInjector(Args... args)
1313
: Type{FactoryFunction{}(std::move(args)...)} {}
@@ -23,7 +23,7 @@ struct FactoryFunctionInjector : public Type {
2323
* @remark Can be used for types which don't have public constructors.
2424
*/
2525
template <typename Type, typename FactoryFunction, typename... Args>
26-
requires std::is_invocable_r_v<Type, FactoryFunction, Args...>
26+
requires std::is_invocable_r_v<Type, FactoryFunction, Args...>
2727
[[nodiscard]] auto BindTypeToFactoryFunction() {
2828
return boost::di::bind<Type>()
2929
.template to<

include/network/auto_parsable/network_auto_parsable_request_handler.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#ifndef STONKS_NETWORK_AUTO_PARSABLE_NETWORK_AUTO_PARSABLE_REQUEST_HANDLER_H_
22
#define STONKS_NETWORK_AUTO_PARSABLE_NETWORK_AUTO_PARSABLE_REQUEST_HANDLER_H_
33

4-
#include <function2/function2.hpp>
54
#include <utility>
6-
#include <variant>
75

8-
#include "network_aprh_concepts.h"
6+
#include "network_aprh_concepts.h" // IWYU pragma: keep
97
#include "network_aprh_handler_variant.h"
108
#include "network_auto_parsable_request.h"
11-
#include "network_concepts.h"
129
#include "network_i_rest_request_handler.h"
1310
#include "network_types.h"
1411

include/network/network_concepts.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010
namespace stonks::network {
1111
template <typename T>
1212
concept Parsable = requires(const IJson &json) {
13-
{ ParseFromJson<T>(json) } -> std::same_as<T>;
14-
};
13+
{ ParseFromJson<T>(json) } -> std::same_as<T>;
14+
};
1515

1616
template <typename T>
1717
concept Convertible = requires(const T &t) {
18-
true;
19-
// TODO(vh): Find requirements for the concept. The one below doesn't work,
20-
// because available declarations are searched only among the ones visible
21-
// here, meaning that user-defined conversions would not be visible here.
22-
// { ConvertToJson(t) } -> std::same_as<cpp::Pv<IJson>>;
23-
};
18+
true;
19+
// TODO(vh): Find requirements for the concept. The one
20+
// below doesn't work, because available declarations
21+
// are searched only among the ones visible here,
22+
// meaning that user-defined conversions would not be
23+
// visible here. { ConvertToJson(t) } ->
24+
// std::same_as<cpp::Pv<IJson>>;
25+
};
2426
} // namespace stonks::network
2527

2628
#endif // STONKS_NETWORK_NETWORK_CONCEPTS_H_

include/network/network_json_common_conversions.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template <>
3333
[[nodiscard]] auto ConvertToJson(cpp::TimePoint value) -> cpp::Pv<IJson>;
3434

3535
template <cpp::IsTypedStruct T>
36-
requires Parsable<typename T::ValueType>
36+
requires Parsable<typename T::ValueType>
3737
[[nodiscard]] auto ParseFromJson(const IJson &json) -> T {
3838
return {ParseFromJson<typename T::ValueType>(json)};
3939
}
@@ -45,7 +45,7 @@ template <Convertible T>
4545
}
4646

4747
template <cpp::Optional T>
48-
requires Parsable<typename T::value_type>
48+
requires Parsable<typename T::value_type>
4949
[[nodiscard]] auto ParseFromJson(const IJson &json) -> T {
5050
if (json.IsNull()) {
5151
return std::nullopt;
@@ -64,7 +64,7 @@ template <Convertible T>
6464
}
6565

6666
template <cpp::Vector T>
67-
requires Parsable<typename T::value_type>
67+
requires Parsable<typename T::value_type>
6868
[[nodiscard]] auto ParseFromJson(const IJson &json) -> T {
6969
auto vector = T{};
7070

include/network/network_rest_server_builder.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <map>
55
#include <utility>
66

7-
#include "di_factory.h"
87
#include "cpp_not_null.h"
98
#include "cpp_optional.h"
9+
#include "di_factory.h"
1010
#include "network_auto_parsable_request_handler.h"
1111
#include "network_i_rest_request_handler.h"
1212
#include "network_i_rest_request_receiver.h"
@@ -19,8 +19,8 @@ namespace stonks::network {
1919
*/
2020
class RestServerBuilder {
2121
public:
22-
explicit RestServerBuilder(cpp::NnSp<di::IFactory<IRestRequestReceiver>>
23-
request_receiver_factory);
22+
explicit RestServerBuilder(
23+
cpp::NnSp<di::IFactory<IRestRequestReceiver>> request_receiver_factory);
2424

2525
/**
2626
* @brief Sets base URI on which requests are to be handled.
@@ -31,7 +31,7 @@ class RestServerBuilder {
3131
* @brief Registers handler for particular endpoint.
3232
*/
3333
template <typename T>
34-
requires std::constructible_from<AutoParsableRequestHandler, T>
34+
requires std::constructible_from<AutoParsableRequestHandler, T>
3535
auto Handling(TypedEndpoint endpoint, T handler) -> RestServerBuilder & {
3636
return Handling(
3737
std::move(endpoint),

include/network/typed_endpoint/network_typed_endpoint_handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define STONKS_NETWORK_TYPED_ENDPOINT_NETWORK_TYPED_ENDPOINT_HANDLER_H_
33

44
#include "cpp_not_null.h"
5-
#include "network_te_endpoint_types_validator_template.h"
65
#include "network_i_rest_request_handler.h"
6+
#include "network_te_endpoint_types_validator_template.h"
77
#include "network_typed_endpoint.h"
88
#include "network_types.h"
99

include/restsdk/restsdk_json.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Json : public network::IJson {
106106

107107
template <cpp::DecaysTo<Json> This>
108108
[[nodiscard]] static auto GetNativeHandleImpl(This& t)
109-
-> cpp::CopyConst<This, IJson::NativeHandle> &;
109+
-> cpp::CopyConst<This, IJson::NativeHandle>&;
110110

111111
network::IJson::NativeHandle native_handle_;
112112
};

include/restsdk/restsdk_json_native_handle.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef STONKS_RESTSDK_RESTSDK_JSON_NATIVE_HANDLE_H_
22
#define STONKS_RESTSDK_RESTSDK_JSON_NATIVE_HANDLE_H_
33

4-
#include "cpp_concepts.h"
54
#include "cpp_copy_const.h"
65
#include "cpp_not_null.h"
76
#include "network_i_json.h"

include/restsdk/restsdk_rest_request_sender.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef STONKS_RESTSDK_RESTSDK_REST_REQUEST_SENDER_H_
22
#define STONKS_RESTSDK_RESTSDK_REST_REQUEST_SENDER_H_
33

4+
#include "cpp_not_null.h"
45
#include "log_i_logger.h"
56
#include "network_i_rest_request_sender.h"
67
#include "network_types.h"
7-
#include "cpp_not_null.h"
88

99
namespace stonks::restsdk {
1010
/**

include/sqldb/query_builder_facade/sqldb_qbf_common.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef STONKS_SQLDB_QUERY_BUILDER_FACADE_SQLDB_QBF_COMMON_H_
22
#define STONKS_SQLDB_QUERY_BUILDER_FACADE_SQLDB_QBF_COMMON_H_
33

4-
#include <variant>
54
#include <vector>
65

76
#include "cpp_views.h"

include/sqldb/query_builder_facade/sqldb_qbf_insert_query_builder.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include "cpp_not_null.h"
88
#include "cpp_views.h"
99
#include "sqldb_i_query_builder.h"
10-
#include "sqldb_qbf_common.h"
10+
#include "sqldb_qbf_columns_variant.h"
11+
#include "sqldb_qbf_table_variant.h"
1112
#include "sqldb_types.h"
1213

1314
namespace stonks::sqldb {

include/sqldb/query_builder_facade/sqldb_qbf_limit_variant.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#ifndef STONKS_SQLDB_QUERY_BUILDER_FACADE_SQLDB_QBF_LIMIT_VARIANT_H_
22
#define STONKS_SQLDB_QUERY_BUILDER_FACADE_SQLDB_QBF_LIMIT_VARIANT_H_
33

4+
#include <string>
45
#include <variant>
5-
#include <vector>
6-
7-
#include "cpp_copy_const.h"
8-
#include "sqldb_types.h"
96

107
namespace stonks::sqldb::qbf {
118
/**

include/sqldb/query_builder_facade/sqldb_qbf_select_query_builder.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
#include <string>
55
#include <string_view>
6-
#include <variant>
76
#include <vector>
87

98
#include "cpp_expose_private_constructors.h"
109
#include "cpp_not_null.h"
1110
#include "cpp_optional.h"
1211
#include "cpp_views.h"
1312
#include "sqldb_i_query_builder.h"
14-
#include "sqldb_qbf_common.h"
13+
#include "sqldb_qbf_columns_variant.h"
1514
#include "sqldb_qbf_limit_variant.h"
1615
#include "sqldb_types.h"
1716

include/sqldb/query_builder_facade/sqldb_qbf_update_query_builder.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#include "cpp_optional.h"
1111
#include "cpp_views.h"
1212
#include "sqldb_i_query_builder.h"
13-
#include "sqldb_qbf_common.h"
13+
#include "sqldb_qbf_columns_variant.h"
14+
#include "sqldb_qbf_table_variant.h"
1415
#include "sqldb_types.h"
1516

1617
namespace stonks::sqldb {

0 commit comments

Comments
 (0)