<commit_before>//
// Created by <NAME> on 8/20/17.
//

#include "test.hpp"

#include <yadi/yadi.hpp>

#include <iterator>
#include <list>

namespace yadi {

struct power_plant {
    virtual ~power_plant() {}

    virtual int power() const = 0;
};

struct electric : public power_plant {
    static std::unique_ptr<power_plant> make_electric(std::string make, int watts) {
        std::unique_ptr<power_plant> ret(new electric(make, watts));
        return ret;
    }
    electric(std::string make, int watts) : make(std::move(make)), watts(std::move(watts)) {}

    int power() const { return this->watts; }

    std::string make;
    int watts;
};

struct gas : public power_plant {
    static std::unique_ptr<power_plant> make_gas(std::string make, int cylinder_count, int bore, int stroke) {
        std::unique_ptr<power_plant> ret(new gas(make, cylinder_count, bore, stroke));
        return ret;
    }

    gas(std::string make, int cylinder_count, int bore, int stroke)
        : make(make), cylinder_count(cylinder_count), bore(bore), stroke(stroke) {}

    int power() const { return this->bore * this->stroke * this->cylinder_count; }

    std::string make;
    int cylinder_count;
    int bore;
    int stroke;
};

struct car {
    static car make_car(std::string make, std::unique_ptr<power_plant>& motor) {
        return car{std::move(make), std::move(motor)};
    }
    car(std::string make, std::unique_ptr<power_plant> motor) : make(std::move(make)) { this->motor.swap(motor); }

    std::string make;
    std::unique_ptr<power_plant> motor;
};

template <>
struct factory_traits<car> {
    using ptr_type = car;
    static const bool direct_from_yaml = true;
};

YADI_INIT_BEGIN
// Make car from mapped args
::yadi::register_type<car>("", ::yadi::make_initializer<car>(&car::make_car, {"make", "power_plant"}));
// Make gas from mapped args
register_type<power_plant>("gas", ::yadi::make_initializer<power_plant>(&gas::make_gas,
                                                                        {"make", "cylinder_count", "bore", "stroke"}));<commit_msg>Spacing<commit_after>//
// Created by <NAME> on 8/20/17.
//

#include "test.hpp"

#include <yadi/yadi.hpp>

#include <iterator>
#include <list>

namespace yadi {

struct power_plant {
    virtual ~power_plant() {}

    virtual int power() const = 0;
};

struct electric : public power_plant {
    static std::unique_ptr<power_plant> make_electric(std::string make, int watts) {
        std::unique_ptr<power_plant> ret(new electric(make, watts));
        return ret;
    }
    electric(std::string make, int watts) : make(std::move(make)), watts(std::move(watts)) {}

    int power() const { return this->watts; }

    std::string make;
    int watts;
};

struct gas : public power_plant {
    static std::unique_ptr<power_plant> make_gas(std::string make, int cylinder_count, int bore, int stroke) {
        std::unique_ptr<power_plant> ret(new gas(make, cylinder_count, bore, stroke));
        return ret;
    }

    gas(std::string make, int cylinder_count, int bore, int stroke)
        : make(make), cylinder_count(cylinder_count), bore(bore), stroke(stroke) {}

    int power() const { return this->bore * this->stroke * this->cylinder_count; }

    std::string make;
    int cylinder_count;
    int bore;
    int stroke;
};

struct car {
    static car make_car(std::string make, std::unique_ptr<power_plant>& motor) {
        return car{std::move(make), std::move(motor)};
    }
    car(std::string make, std::unique_ptr<power_plant> motor) : make(std::move(make)) { this->motor.swap(motor); }

    std::string make;
    std::unique_ptr<power_plant> motor;
};

template <>
struct factory_traits<car> {
    using ptr_type = car;
    static const bool direct_from_yaml = true;
};

YADI_INIT_BEGIN
// Make car from mapped args
::yadi::register_type<car>("", ::yadi::make_initializer<car>(&car::make_car, {"make", "power_plant"}));

// Make gas from mapped args
register_type<power_plant>("gas", ::yadi::make_initializer<power_plant>(&gas::make_gas,
                                                                        {"make", "cylinder_count", "bore", "stroke"}));
{'fraction_non_alphanumeric': 0.14839797639123103, 'fraction_numerical': 0.002890869669959046, 'mean_word_length': 3.6133333333333333, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5178710', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1336, 'n_words': 315}