<commit_before>#ifndef CONFIG_CONFIG_HPP
#define CONFIG_CONFIG_HPP
#include <string>
#include <vector>

class ConfigFile {
public:
    struct Var {
        char const *sec;
        char const *key;
        char const *val;
    };

    ConfigFile();
    ~ConfigFile();

    void read(char const *path);
    void write(char const *path);

    void dump();

    // Generic put / get, keys & values will be copied
    // Putting a NULL value deletes the key
    void putKey(char const *sec, char const *key, char const *val);
    char const *getKey(char const *sec, char const *key);

    // Convenience functions
    bool hasKey(char const *sec, char const *key)
    { return getKey(sec, key); }
    void deleteKey(char const *sec, char const *key)
    { putKey(sec, key, 0); }

    // Typed put, overwriting existing value
    void putLong(char const *sec, char const *key, long val);
    void putString(char const *sec, char const *key,
                   std::string const &val);
    void putStringArray(char const *sec, char const *key,
                        std::vector<std::string> const &val);
    void putBool(char const *sec, char const *key, bool val);
    void putDouble(char const *sec, char const *key, double val);

    // Typed get
    bool getLong(char const *sec, char const *key, long &val);
    bool getString(char const *sec, char const *key, std::string &val);
    // Note that this will APPEND to the existing vector and it will
    // not remove existing elements.
    bool getStringArray(char const *sec, char const *key,
                        std::vector<std::string> &val);
    bool getBool(char const *sec, char const *key, bool &val);
    bool getDouble(char const *sec, char const *key, double val);

private:
    Var *getVar(char const *sec, char const *key);
    char *alloc(size_t len);
    char *putStr(char const *str);
    void sort();

    std::vector<Var> vars_;
    char *data_;
    size_t datasz_, dataalloc_;
    bool sorted_;
};

#endif<commit_msg>Disabled copying and assignment of config file objects.<commit_after>#ifndef CONFIG_CONFIG_HPP
#define CONFIG_CONFIG_HPP
#include <string>
#include <vector>

class ConfigFile {
public:
    struct Var {
        char const *sec;
        char const *key;
        char const *val;
    };

    ConfigFile();
    ~ConfigFile();

    void read(char const *path);
    void write(char const *path);

    void dump();

    // Generic put / get, keys & values will be copied
    // Putting a NULL value deletes the key
    void putKey(char const *sec, char const *key, char const *val);
    char const *getKey(char const *sec, char const *key);

    // Convenience functions
    bool hasKey(char const *sec, char const *key)
    { return getKey(sec, key); }
    void deleteKey(char const *sec, char const *key)
    { putKey(sec, key, 0); }

    // Typed put, overwriting existing value
    void putLong(char const *sec, char const *key, long val);
    void putString(char const *sec, char const *key,
                   std::string const &val);
    void putStringArray(char const *sec, char const *key,
                        std::vector<std::string> const &val);
    void putBool(char const *sec, char const *key, bool val);
    void putDouble(char const *sec, char const *key, double val);

    // Typed get
    bool getLong(char const *sec, char const *key, long &val);
    bool getString(char const *sec, char const *key, std::string &val);
    // Note that this will APPEND to the existing vector and it will
    // not remove existing elements.
    bool getStringArray(char const *sec, char const *key,
                        std::vector<std::string> &val);
    bool getBool(char const *sec, char const *key, bool &val);
    bool getDouble(char const *sec, char const *key, double val);

private:
    Var *getVar(char const *sec, char const *key);
    char *alloc(size_t len);
    char *putStr(char const *str);
    void sort();

    std::vector<Var> vars_;
    char *data_;
    size_t datasz_, dataalloc_;
    bool sorted_;

    ConfigFile(ConfigFile const &);
    ConfigFile &operator=(ConfigFile const &);
};

#endif
{'fraction_non_alphanumeric': 0.11081344374086702, 'fraction_numerical': 0.0004870920603994155, 'mean_word_length': 2.878186968838527, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '7026627', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1209, 'n_words': 473}