Skip to content

Commit 42f0024

Browse files
committed
Fix clang-tidy
1 parent 76518f7 commit 42f0024

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

src/chart/options/config.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ void Config::setChannelParam(const std::string &path,
211211
if (parts.size() == 3 && value == "null")
212212
channel.reset();
213213
else {
214-
if (auto command = parts.size() == 4
215-
? "name"
216-
: std::string_view{parts.at(4)};
214+
if (const std::string_view command =
215+
parts.size() == 4 ? std::string_view{"name"}
216+
: parts.at(4);
217217
command == "name") {
218218
if (std::stoi(parts.at(3)) == 0) channel.reset();
219-
if (value == "") { channel.measureId.emplace(); }
219+
if (value.empty()) { channel.measureId.emplace(); }
220220
else
221221
channel.addSeries({value, table});
222222
}

src/dataframe/impl/data_source.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ enum class error_type {
2929
internal_error
3030
};
3131

32+
struct series_meta_t
33+
{
34+
std::string_view name;
35+
series_type type;
36+
};
37+
3238
[[maybe_unused]] [[noreturn]] void error(error_type err,
3339
std::string_view arg = {});
3440

src/dataframe/impl/dataframe.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,7 @@ std::string dataframe::get_record_id_by_dims(std::size_t my_record,
722722
return get_data_source().get_id(my_record, dimensions);
723723
}
724724

725-
dataframe::series_meta_t dataframe::get_series_meta(
726-
const std::string &id) const
725+
series_meta_t dataframe::get_series_meta(const std::string &id) const
727726
{
728727
switch (auto &&ser = get_data_source().get_series(id)) {
729728
using enum series_type;

src/dataframe/impl/dataframe.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ class dataframe
117117
[[nodiscard]] std::span<const std::string> get_categories(
118118
const std::string_view &dimension) const &;
119119

120-
struct series_meta_t
121-
{
122-
std::string_view name;
123-
series_type type;
124-
};
125-
126120
[[nodiscard]] series_meta_t get_series_meta(
127121
const std::string &id) const;
128122

src/dataframe/old/datatable.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "base/text/funcstring.h"
99
#include "chart/options/options.h"
1010
#include "dataframe/impl/aggregators.h"
11+
#include "dataframe/impl/data_source.h"
1112
#include "dataframe/interface.h"
1213

1314
namespace Vizzu::Data
@@ -53,15 +54,18 @@ const MultiIndex &DataCube::iterator_t::operator*() const
5354
return index;
5455
}
5556

56-
SeriesIndex::SeriesIndex(std::string const &str,
57-
const DataTable &table)
57+
SeriesIndex::SeriesIndex(dataframe::series_meta_t const &meta) :
58+
name{meta.name}
5859
{
59-
auto &&[s, type] = table.getDf().get_series_meta(str);
60-
name = s;
61-
if (type == DataTable::Type::measure)
62-
aggregator = dataframe::aggregator_type::sum;
60+
if (meta.type == dataframe::series_type::measure)
61+
aggregator.emplace(dataframe::aggregator_type::sum);
6362
}
6463

64+
SeriesIndex::SeriesIndex(std::string const &str,
65+
const DataTable &table) :
66+
SeriesIndex(table.getDf().get_series_meta(str))
67+
{}
68+
6569
void SeriesIndex::setAggr(const std::string &aggr)
6670
{
6771
aggregator = Refl::get_enum<dataframe::aggregator_type>(aggr);

src/dataframe/old/types.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
#include "../interface.h"
99

10+
namespace Vizzu::dataframe
11+
{
12+
struct series_meta_t;
13+
}
14+
1015
namespace Vizzu::Data
1116
{
1217

@@ -30,6 +35,8 @@ class SeriesIndex
3035
std::string_view name{};
3136
std::optional<dataframe::aggregator_type> aggregator;
3237

38+
explicit SeriesIndex(dataframe::series_meta_t const &meta);
39+
3340
public:
3441
SeriesIndex() : aggregator(dataframe::aggregator_type::count) {}
3542
SeriesIndex(std::string const &str, const DataTable &table);

0 commit comments

Comments
 (0)