<commit_before>// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#pragma once

#include <map>
#include <string>
#include <sstream>
#include <functional>

namespace rs2
{
    class config_value
    {
    public:
        template<class T>
        operator T()
        {
            std::stringstream ss;
            ss.str(_val);
            T res;
            ss >> res;
            return res;
        }

        config_value(std::string val) : _val(std::move(val)) {}

    private:
        std::string _val;
    };

    class config_file
    {
    public:
        config_file();
        config_file(std::string filename);

        void set_default(const char* key, const char* calculate);

        template<class T>
        void set_default(const char* key, T val)<commit_msg>Added an overload to config_value's conversion operator, allowing correct conversion from config_value to std::string<commit_after>// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#pragma once

#include <map>
#include <string>
#include <sstream>
#include <functional>

namespace rs2
{
    class config_value
    {
    public:
        template<class T>
        operator T()
        {
            std::stringstream ss;
            ss.str(_val);
            T res;
            ss >> res;
            return res;
        }

		// When converting config_value to string, we can't use >> operator since it reads until first whitespace rather than the whole string;
		// Therefore we use a different overload for strings
		operator std::string()
		{
			return _val;
		}
		
        config_value(std::string val) : _val(std::move(val)) {}

    private:
        std::string _val;
    };

    class config_file
    {
    public:
        config_file();
        config_file(std::string filename);

        void set_default(const char* key, const char* calculate);

        template<class T>
        void set_default(const char* key, T val)
{'fraction_non_alphanumeric': 0.09770395701025891, 'fraction_numerical': 0.006839276990718124, 'mean_word_length': 2.2559618441971385, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '6299057', 'n_tokens_mistral': 607, 'n_tokens_neox': 569, 'n_words': 188}