#ifndef LOGGER_UTILITY_H #define LOGGER_UTILITY_H #include "types.h" namespace detail { constexpr std::size_t const_pow(std::size_t base, std::size_t pow) { if (pow == 0) return 1; else return base * const_pow(base, pow - 1); } template constexpr std::array get_zero_array() { std::array result; for (auto& c : result) c = '0'; return result; } template constexpr std::array get_init_array() { std::array result; if constexpr (fmt_node.has_zero_padding) { for (auto& c : result) c = '0'; } else { for (auto& c : result) c = ' '; } return result; } template consteval std::size_t count_ast_format_nodes() { std::size_t result = 0; for (const auto& node : ast) if (!node.is_char()) ++result; return result; } template consteval std::array()> get_fmt_data() { std::array()> result = {}; std::size_t position = 0; std::size_t i = 0; for (const auto& node : ast) { if (!node.is_char()) { const auto fmt_node = node.get_node(); result[i].has_zero_padding = fmt_node.has_zero_padding; result[i].length = fmt_node.length; result[i].precision = fmt_node.precision; result[i].type = fmt_node.type; result[i].position = position; ++i; position += fmt_node.length; } else { ++position; } } return result; } template consteval std::array drop_first(std::array array) { static_assert(t_n > 0, "Can't drop first element of array with no elements"); std::array result; std::copy(array.begin() + 1, array.end(), result.begin()); return result; } } // namespace detail #endif // LOGGER_UTILITY_H