<commit_before>//
//
//
#ifndef POPEN_HPP
#define POPEN_HPP

#include <sys/types.h>

#include <cstdio>
#include <csignal>
#include <regex>
#include <string>

#include "asio.hpp"

#include "bash-queue.hpp"

namespace led_d
{

  class popen_t// : public std::enable_shared_from_this<popen_t>
  {
  public:
    // Achtung: it throws
    popen_t (const std::string &command,
             asio::io_context &context, bash_queue_t &queue);
    popen_t () = delete;
    popen_t (const popen_t&) = delete;
    ~popen_t ();

    // 'fileno (FILE*)' call
    // descriptor_t& descriptor () {return m_descriptor;}

    // Try to read smth
    // Note: ignore if 'info' is empty
    // bool read (std::string &info);

    // man -S 2 kill
    bool kill (int signal);

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix,
                       const std::string &pattern);

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix);

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix,
                       const std::regex &regex);

  private:
    using descriptor_t = asio::posix::stream_descriptor;



    void filter (std::string &info);

    void handle_read (const asio::error_code &error, std::size_t len);

    FILE *m_file_ptr;
    descriptor_t m_descriptor;
    bash_queue_t &m_queue;

    pid_t m_pid;

    static constexpr auto asio_buf_size = 128;
    std::array<char, asio_buf_size> m_asio_buf;

    static const std::regex m_regex;
  };

} // led_d

// list of all tracks
// mpc -f "%file%" playlist

#endif<commit_msg>pi: Polish<commit_after>//
//
//
#ifndef POPEN_HPP
#define POPEN_HPP

#include <sys/types.h>

#include <cstdio>
#include <csignal>
#include <regex>
#include <string>

#include "asio.hpp"

#include "bash-queue.hpp"

namespace led_d
{

  class popen_t// : public std::enable_shared_from_this<popen_t>
  {
  public:
    // Achtung: it throws
    popen_t (const std::string &command,
             asio::io_context &context, bash_queue_t &queue);
    popen_t () = delete;
    popen_t (const popen_t&) = delete;
    ~popen_t ();

    // man -S 2 kill
    bool kill (int signal);

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix,
                       const std::string &pattern);

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix,
                       const std::regex &regex);

  private:
    using descriptor_t = asio::posix::stream_descriptor;

    static bool split (const std::string &src,
                       std::string &prefix, std::string &suffix);

    void filter (std::string &info);

    void handle_read (const asio::error_code &error, std::size_t len);

    FILE *m_file_ptr;
    descriptor_t m_descriptor;
    bash_queue_t &m_queue;

    pid_t m_pid;

    static constexpr auto asio_buf_size = 128;
    std::array<char, asio_buf_size> m_asio_buf;

    static const std::regex m_regex;
  };

} // led_d

// list of all tracks
// mpc -f "%file%" playlist

#endif
{'fraction_non_alphanumeric': 0.12543009071004066, 'fraction_numerical': 0.0025023459493274947, 'mean_word_length': 2.597300337457818, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '1951610', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1042, 'n_words': 287}