<commit_before>//
//  yas_db_column_value.h
//

#pragma once

#include <MacTypes.h>
#include <sqlite3.h>
#include <initializer_list>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

namespace yas {
namespace db {
    struct copy_tag_t {};
    struct no_copy_tag_t {};
    constexpr static copy_tag_t copy_tag{};
    constexpr static no_copy_tag_t no_copy_tag{};

    struct int64 {
        using type = sqlite3_int64;
    };

    struct float64 {
        using type = Float64;
    };

    struct string {
        using type = std::string;
    };

    struct blob {
        using type = blob;

        blob();

        template <typename T = copy_tag_t>
        blob(const void *const data, size_t const size, T const tag = copy_tag);

        blob(const blob &) = delete;
        blob(blob &&) = default;
        blob &operator=(const blob &) = delete;
        blob &operator=(blob &&) = default;

        const void *data() const;
        size_t size() const;

       private:
        std::vector<UInt8> _vector;
        const void *_data;
        size_t _size;
    };

    struct null {
        using type = std::nullptr_t;
    };

    class column_value {
       public:
        explicit column_value(UInt8 const &);
        explicit column_value(SInt8 const &);
        explicit column_value(UInt16 const &);
        explicit column_value(SInt16 const &);
        explicit column_value(UInt32 const &);
        explicit column_value(SInt32 const &);
        explicit column_value(UInt64 const &);
        explicit column_value(SInt64 const &);
        explicit column_value(Float32 const &);
        explicit column_value(Float64 const &);
        explicit column_value(std::string const &);
        explicit column_value(std::string &&);
        explicit column_value(blob::type &&);
        column_value(null::type);

        template <typename T = db::copy_tag_t>
        column_value(const void *const data, size_t const size, T const tag = db::copy_tag);

        ~column_value();

        column_value(const column_value &) = delete;
        column_value(column_value &&) noexcept;
        column_value &operator=(const column_value &) = delete;
        column_value &operator=(column_value &&) noexcept;

        std::type_info const &type() const;

        template <typename T>
        const typename T::type &value() const;

       private:
        class impl_base;
        std::unique_ptr<impl_base> _impl;

        template <typename T>
        class impl;
    };

    using column_vector = std::vector<column_value>;
    using column_map = std::unordered_map<std::string, column_value>;

    static_assert(std::is_nothrow_move_constructible<column_value>::value == true,
                  "column_value is nothrow move constructible");
}

std::string to_string(const db::column_value &);
}
<commit_msg>remove unused include<commit_after>//
//  yas_db_column_value.h
//

#pragma once

#include <MacTypes.h>
#include <sqlite3.h>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

namespace yas {
namespace db {
    struct copy_tag_t {};
    struct no_copy_tag_t {};
    constexpr static copy_tag_t copy_tag{};
    constexpr static no_copy_tag_t no_copy_tag{};

    struct int64 {
        using type = sqlite3_int64;
    };

    struct float64 {
        using type = Float64;
    };

    struct string {
        using type = std::string;
    };

    struct blob {
        using type = blob;

        blob();

        template <typename T = copy_tag_t>
        blob(const void *const data, size_t const size, T const tag = copy_tag);

        blob(const blob &) = delete;
        blob(blob &&) = default;
        blob &operator=(const blob &) = delete;
        blob &operator=(blob &&) = default;

        const void *data() const;
        size_t size() const;

       private:
        std::vector<UInt8> _vector;
        const void *_data;
        size_t _size;
    };

    struct null {
        using type = std::nullptr_t;
    };

    class column_value {
       public:
        explicit column_value(UInt8 const &);
        explicit column_value(SInt8 const &);
        explicit column_value(UInt16 const &);
        explicit column_value(SInt16 const &);
        explicit column_value(UInt32 const &);
        explicit column_value(SInt32 const &);
        explicit column_value(UInt64 const &);
        explicit column_value(SInt64 const &);
        explicit column_value(Float32 const &);
        explicit column_value(Float64 const &);
        explicit column_value(std::string const &);
        explicit column_value(std::string &&);
        explicit column_value(blob::type &&);
        column_value(null::type);

        template <typename T = db::copy_tag_t>
        column_value(const void *const data, size_t const size, T const tag = db::copy_tag);

        ~column_value();

        column_value(const column_value &) = delete;
        column_value(column_value &&) noexcept;
        column_value &operator=(const column_value &) = delete;
        column_value &operator=(column_value &&) noexcept;

        std::type_info const &type() const;

        template <typename T>
        const typename T::type &value() const;

       private:
        class impl_base;
        std::unique_ptr<impl_base> _impl;

        template <typename T>
        class impl;
    };

    using column_vector = std::vector<column_value>;
    using column_map = std::unordered_map<std::string, column_value>;

    static_assert(std::is_nothrow_move_constructible<column_value>::value == true,
                  "column_value is nothrow move constructible");
}

std::string to_string(const db::column_value &);
}

{'fraction_non_alphanumeric': 0.10721830985915493, 'fraction_numerical': 0.010211267605633803, 'mean_word_length': 2.644002565747274, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '3066398', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1697, 'n_words': 420}