<commit_before>#pragma once
#include "cstr.h"
#include "cargseq.h"


class ArgParser
{public:
    struct ArgInfo
    {
        char type;
        std::size_t pos;
    };

    ArgParser(cstr msg)
        :msg_(msg)
    {
        seq_t all_seq = arg_seq(msg, '*');
        seq_t str_seq = arg_seq(msg, 's');
        seq_t int_seq = arg_seq(msg, 'd');
        seq_t float_seq = arg_seq(msg, 'f');
        seq_t escape_seq = arg_seq(msg, '%');

        arg_infos_.resize(count_bit1(all_seq));
        for(std::size_t i = 0; i < arg_infos_.size(); i++)
        {
            arg_infos_[i].type = arg_type_at_bit(i, str_seq, 's', int_seq, 'd', float_seq, 'f', escape_seq, '%');
            assert(arg_infos_[i].type != '?' && "detected unknown symbol");
            arg_infos_[i].pos = pos_of_nth_arg(msg, i);
        }
    }

    std::size_t count_args(char arg_s='*') const
    {
        if(arg_s == '*') return arg_infos_.size();
        return std::count_if(arg_infos_.begin(), arg_infos_.end(), 
                [arg_s](ArgInfo ai){ return ai.type == arg_s; });
    };

    ArgInfo operator[](std::size_t i) const
    {
        return arg_infos_.at(i);
    }

    std::vector<ArgInfo>::iterator begin() { return arg_infos_.begin(); }
    std::vector<ArgInfo>::iterator end() { return arg_infos_.end(); }

    std::vector<ArgInfo>::const_iterator begin() const { return arg_infos_.begin(); }
    std::vector<ArgInfo>::const_iterator end() const { return arg_infos_.end(); }

private:
    cstr msg_;<commit_msg>adjust code layout<commit_after>#pragma once
#include "cstr.h"
#include "cargseq.h"


class ArgParser
{public:
    struct ArgInfo
    {
        char type;
        std::size_t pos;
    };

    ArgParser(cstr msg)
        :msg_(msg)
    {
        seq_t all_seq = arg_seq(msg, '*');
        seq_t str_seq = arg_seq(msg, 's');
        seq_t int_seq = arg_seq(msg, 'd');
        seq_t float_seq = arg_seq(msg, 'f');
        seq_t escape_seq = arg_seq(msg, '%');

        arg_infos_.resize(count_bit1(all_seq));
        for(std::size_t i = 0; i < arg_infos_.size(); i++)
        {
            arg_infos_[i].type = arg_type_at_bit(i, str_seq, 's', int_seq, 'd', float_seq, 'f', escape_seq, '%');
            assert(arg_infos_[i].type != '?' && "detected unknown symbol");
            arg_infos_[i].pos = pos_of_nth_arg(msg, i);
        }
    }

    std::size_t count_args(char arg_s='*') const
    {
        if(arg_s == '*') { return arg_infos_.size(); }

        return std::count_if(
            arg_infos_.begin(), 
            arg_infos_.end(), 
            [arg_s](ArgInfo ai){ return ai.type == arg_s; });
    };

    ArgInfo operator[](std::size_t i) const
    {
        return arg_infos_.at(i);
    }

    std::vector<ArgInfo>::iterator begin() { return arg_infos_.begin(); }
    std::vector<ArgInfo>::iterator end() { return arg_infos_.end(); }

    std::vector<ArgInfo>::const_iterator begin() const { return arg_infos_.begin(); }
    std::vector<ArgInfo>::const_iterator end() const { return arg_infos_.end(); }

private:
    cstr msg_;
{'fraction_non_alphanumeric': 0.16338582677165353, 'fraction_numerical': 0.0013123359580052493, 'mean_word_length': 2.6558752997601918, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '714599', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1088, 'n_words': 204}