summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ingestor.cpp17
-rw-r--r--src/ingestor.hpp10
2 files changed, 16 insertions, 11 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index c1206a2..e316e84 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -101,37 +101,40 @@ namespace WebStat {
}
template<typename... T>
- void
+ size_t
Ingestor::storeEntities(const std::tuple<T...> & values) const
{
- std::apply(
+ return std::apply(
[this](auto &&... value) {
- (this->storeEntity(value), ...);
+ return (this->storeEntity(value) + ...);
},
values);
}
template<typename T>
- void
+ size_t
Ingestor::storeEntity(const T &) const
{
+ return 0;
}
- void
+ size_t
Ingestor::storeEntity(const Entity entity) const
{
auto insert = dbconn->modify(SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS);
insert->bindParamI(0, entity.first);
insert->bindParamS(1, entity.second);
insert->execute();
+ return 1;
}
- void
+ size_t
Ingestor::storeEntity(const std::optional<Entity> entity) const
{
if (entity) {
- storeEntity(*entity);
+ return storeEntity(*entity);
}
+ return 0;
}
template<typename... T>
diff --git a/src/ingestor.hpp b/src/ingestor.hpp
index 07a9a7d..53ba81f 100644
--- a/src/ingestor.hpp
+++ b/src/ingestor.hpp
@@ -24,9 +24,11 @@ namespace WebStat {
void ingestLog(std::FILE *);
void ingestLogLine(std::string_view);
- template<typename T> void storeEntity(const T &) const;
- void storeEntity(Entity) const;
- void storeEntity(std::optional<Entity>) const;
+ template<typename T> [[nodiscard]] size_t storeEntity(const T &) const;
+ // NOLINTNEXTLINE(modernize-use-nodiscard); testing exposition only
+ size_t storeEntity(Entity) const;
+ // NOLINTNEXTLINE(modernize-use-nodiscard); testing exposition only
+ size_t storeEntity(std::optional<Entity>) const;
template<typename... T> void storeLogLine(const std::tuple<T...> &) const;
protected:
@@ -35,7 +37,7 @@ namespace WebStat {
size_t linesDiscarded = 0;
private:
- template<typename... T> void storeEntities(const std::tuple<T...> &) const;
+ template<typename... T> size_t storeEntities(const std::tuple<T...> &) const;
uint32_t hostnameId;
DB::ConnectionPtr dbconn;