<commit_before>#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>

#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/bind.hpp>

#include "errors.h"
#include "external_readonly_parameter.h"
#include "external_readwrite_parameter.h"
#include "object_dictionary.h"
#include "managed_readwrite_parameter.h"
#include "managed_readonly_parameter.h"
#include "scheme_protocol.h"
#include "scheme_monitor_protocol.h"
#include "server.h"
#include "tree_element.h"

Server decofServer;

struct my_managed_readwrite_parameter : public managed_readwrite_parameter<std::string>
{
    my_managed_readwrite_parameter(std::string name, node *parent = nullptr, std::string value = std::string())
     : managed_readwrite_parameter<std::string>(name, parent, value)
    {}

    virtual void verify(const std::string& value) override {
        if (value != "true" && value != "false")
            throw invalid_value_error();

        std::cout << "my_managed_readwrite_parameter was changed to " << value << std::endl;
    }
};

struct my_managed_readonly_parameter : public managed_readonly_parameter<std::string>
{
    my_managed_readonly_parameter(std::string name, node *parent = nullptr, std::string value = std::string())
     : managed_readonly_parameter<std::string>(name, parent, value)
    {}

    virtual bool notify(const std::string& value) {
        std::cout << "my_managed_readonly_parameter was changed to " << value << std::endl;
        return true;
    }
};

struct time_parameter : public external_readonly_parameter<std::string>
{
    time_parameter(std::string name, node *parent = nullptr)
     : external_readonly_parameter<std::string>(name, parent)
    {}

private:
    std::string get_external_value() override {
        std::time_t t = std::time(nullptr);
        return std::asctime(std::localtime(&t));
    }
};

struct ip_address_parameter : public external_readwrite_parameter<std::string>
{
    ip_address_parameter(std::string name, node *parent = nullptr)
     : external_readwrite_parameter<std::string>(name, parent)
    {}

private:
    bool set_external_value(const value_type &value) override {
        std::fstream file(filename_, std::ios_base::out | std::ios_base::trunc);
        if (file.rdstate() & std::ios_base::failbit)<commit_msg>Fixed newline in time string issue.<commit_after>#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>

#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/bind.hpp>

#include "errors.h"
#include "external_readonly_parameter.h"
#include "external_readwrite_parameter.h"
#include "object_dictionary.h"
#include "managed_readwrite_parameter.h"
#include "managed_readonly_parameter.h"
#include "scheme_protocol.h"
#include "scheme_monitor_protocol.h"
#include "server.h"
#include "tree_element.h"

Server decofServer;

struct my_managed_readwrite_parameter : public managed_readwrite_parameter<std::string>
{
    my_managed_readwrite_parameter(std::string name, node *parent = nullptr, std::string value = std::string())
     : managed_readwrite_parameter<std::string>(name, parent, value)
    {}

    virtual void verify(const std::string& value) override {
        if (value != "true" && value != "false")
            throw invalid_value_error();

        std::cout << "my_managed_readwrite_parameter was changed to " << value << std::endl;
    }
};

struct my_managed_readonly_parameter : public managed_readonly_parameter<std::string>
{
    my_managed_readonly_parameter(std::string name, node *parent = nullptr, std::string value = std::string())
     : managed_readonly_parameter<std::string>(name, parent, value)
    {}

    virtual bool notify(const std::string& value) {
        std::cout << "my_managed_readonly_parameter was changed to " << value << std::endl;
        return true;
    }
};

struct time_parameter : public external_readonly_parameter<std::string>
{
    time_parameter(std::string name, node *parent = nullptr)
     : external_readonly_parameter<std::string>(name, parent)
    {}

private:
    std::string get_external_value() override {
        const size_t max_length = 40;
        char str[max_length];
        std::time_t now = std::time(nullptr);
        std::strftime(str, sizeof(str), "%c", std::localtime(&now));
        return std::string(str);
    }
};

struct ip_address_parameter : public external_readwrite_parameter<std::string>
{
    ip_address_parameter(std::string name, node *parent = nullptr)
     : external_readwrite_parameter<std::string>(name, parent)
    {}

private:
    bool set_external_value(const value_type &value) override {
        std::fstream file(filename_, std::ios_base::out | std::ios_base::trunc);
        if (file.rdstate() & std::ios_base::failbit)
{'fraction_non_alphanumeric': 0.12899853648337864, 'fraction_numerical': 0.000418147606104955, 'mean_word_length': 5.040404040404041, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 33, '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': '6040768', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1448, 'n_words': 302}