diff options
Diffstat (limited to 'src/figalyser.hpp')
-rw-r--r-- | src/figalyser.hpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/figalyser.hpp b/src/figalyser.hpp new file mode 100644 index 0000000..bcbb3b6 --- /dev/null +++ b/src/figalyser.hpp @@ -0,0 +1,91 @@ +#pragma once +#include <vector> +#include <cstdio> + +struct FIG +{ + int type; + int ext; + int len; +}; + +class FIGalyser +{ + public: + FIGalyser() + { + clear(); + } + + void set_fib(int fib) + { + m_fib = fib; + } + + void push_back(int type, int ext, int len) + { + struct FIG fig = { + .type = type, + .ext = ext, + .len = len }; + + m_figs[m_fib].push_back(fig); + } + + void analyse() + { + printf("FIC "); + + for (size_t fib = 0; fib < m_figs.size(); fib++) { + int consumed = 7; + int fic_size = 0; + printf("[%1zu ", fib); + + for (size_t i = 0; i < m_figs[fib].size(); i++) { + FIG &f = m_figs[fib][i]; + printf("%01d/%02d (%2d) ", f.type, f.ext, f.len); + + consumed += 10; + + fic_size += f.len; + } + + printf(" "); + + int align = 60 - consumed; + if (align > 0) { + while (align--) { + printf(" "); + } + } + + printf("|"); + + for (int i = 0; i < 15; i++) { + if (2*i < fic_size) { + printf("#"); + } + else { + printf("-"); + } + } + + printf("| ] "); + + } + + printf("\n"); + } + + void clear() + { + m_figs.clear(); + m_figs.resize(3); + } + + private: + int m_fib; + std::vector<std::vector<FIG> > m_figs; +}; + + |