<commit_before>#pragma once

#include "DpaMessage.h"
#include <string>
#include <sstream>
#include <memory>

static const std::string  PRF_NAME_RawTask("RawTask");

class DpaTask
{
public:
  DpaTask() = delete;

  DpaTask(const std::string& prfName)
    :m_prfName(prfName)
  {}

  DpaTask(const std::string& prfName, int address, int command)
    : m_prfName(prfName)
    , m_address(address)
    , m_command(command)
  {}

  virtual ~DpaTask()
  {}

  //from IQRF 
  virtual const DpaMessage& getRequest() = 0;
  virtual void parseConfirmation(const DpaMessage& confirmation) {}
  virtual void parseResponse(const DpaMessage& response) = 0;

  //from Messaging 
  virtual void parseCommand(const std::string& command) = 0;
  virtual const std::string& encodeCommand() const = 0;
  virtual void parseRequestMessage(std::istream& istr) {}
  virtual void encodeResponseMessage(std::ostream& ostr, const std::string& errStr) {}

  const std::string& getPrfName() const { return m_prfName; }
  int getAddress() const { return m_address; }
  void setAddress(int address) { m_address = address; }
  int getCommand() const { return m_command; }
  bool isValid() const { return m_valid; }

protected:
  std::string m_prfName;
  bool m_valid = false;
  int m_address = -1;
  int m_command = -1;
  DpaMessage m_request;
};

class DpaRawTask : public DpaTask
{
public:
  DpaRawTask(const DpaMessage& request);
  virtual ~DpaRawTask() {}

  //from IQRF 
  const DpaMessage& getRequest() override;
  void parseConfirmation(const DpaMessage& confirmation) override;
  void parseResponse(const DpaMessage& response) override;

  //from Messaging 
  void parseCommand(const std::string& command) override;
  const std::string& encodeCommand() const override;

private:
  DpaMessage m_confirmation;
  DpaMessage m_response;
};
<commit_msg>DpaTask encode to ostr<commit_after>#pragma once

#include "DpaMessage.h"
#include <string>
#include <sstream>
#include <memory>

static const std::string  PRF_NAME_RawTask("RawTask");

class DpaTask
{
public:
  DpaTask() = delete;

  DpaTask(const std::string& prfName)
    :m_prfName(prfName)
  {}

  DpaTask(const std::string& prfName, int address, int command)
    : m_prfName(prfName)
    , m_address(address)
    , m_command(command)
  {}

  virtual ~DpaTask()
  {}

  //from IQRF 
  virtual const DpaMessage& getRequest() = 0;
  virtual void parseConfirmation(const DpaMessage& confirmation) {}
  virtual void parseResponse(const DpaMessage& response) = 0;

  //from Messaging 
  virtual void parseCommand(const std::string& command) = 0;
  virtual const std::string& encodeCommand() const = 0;
  //virtual void parseRequestMessage(std::istream& istr) {}
  virtual void encodeResponseMessage(std::ostream& ostr, const std::string& errStr) {}

  const std::string& getPrfName() const { return m_prfName; }
  int getAddress() const { return m_address; }
  void setAddress(int address) { m_address = address; }
  int getCommand() const { return m_command; }
  bool isValid() const { return m_valid; }

protected:
  std::string m_prfName;
  bool m_valid = false;
  int m_address = -1;
  int m_command = -1;
  DpaMessage m_request;
};

class DpaRawTask : public DpaTask
{
public:
  DpaRawTask(const DpaMessage& request);
  virtual ~DpaRawTask() {}

  //from IQRF 
  const DpaMessage& getRequest() override;
  void parseConfirmation(const DpaMessage& confirmation) override;
  void parseResponse(const DpaMessage& response) override;

  //from Messaging 
  void parseCommand(const std::string& command) override;
  const std::string& encodeCommand() const override;

private:
  DpaMessage m_confirmation;
  DpaMessage m_response;
};

{'fraction_non_alphanumeric': 0.11156685808039377, 'fraction_numerical': 0.003281378178835111, 'mean_word_length': 4.751572327044025, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4785461', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1201, 'n_words': 325}