<commit_before>#pragma once
#include "string_header.h"
#include <string>
#include <limits>

namespace NJS::Class
{
	// Constructors
	String::String()
	{ 

	}
	String::String(std::string val)
	{
		value = val;
	}
	String::String(const char* val)
	{
		value = val;
	}
	// Methods
	void String::Delete() noexcept
	{
		if (--counter < 1)
		{
			delete this;
		}
	}
	// Native cast
	String::operator bool() const noexcept { return value.size() > 0; }
	String::operator double() const noexcept
	{
		std::string::size_type end;
		double res;
		try
		{
			res = std::stod(value, &end);
		}catch(std::invalid_argument e){}
		return end == value.size() ? res : std::numeric_limits<double>::quiet_NaN();
	}
	String::operator int() const noexcept
	{
		std::string::size_type end;
		int res;
		try
		{
			res = std::stoi(value, &end, 10);
		}catch(std::invalid_argument e){}
		
		return end == value.size() ? res : std::numeric_limits<int>::quiet_NaN();
	}
	String::operator long long() const noexcept
	{
		std::string::size_type end;
		long long res;
		int res;
		try
		{
			res = std::stoll(value, &end, 10);
		}catch(std::invalid_argument e){}

		return end == value.size() ? res : std::numeric_limits<long long>::quiet_NaN();
	}
	String::operator std::string() const noexcept { return value; }
	// Main operators
	NJS::VAR const String::operator[](NJS::VAR key) const
	{
		if (key.type == NJS::Enum::Type::Number)
		{
			auto i = (int)key;
			if (i >= 0 && i <= value.size())
			{
				return value.at(i);
			}
			else return undefined;
		}<commit_msg>Improve var to string auto conversion<commit_after>#pragma once
#include "string_header.h"
#include <string>
#include <limits>

namespace NJS::Class
{
	// Constructors
	String::String()
	{ 

	}
	String::String(std::string val)
	{
		value = val;
	}
	String::String(const char* val)
	{
		value = val;
	}
	// Methods
	void String::Delete() noexcept
	{
		if (--counter < 1)
		{
			delete this;
		}
	}
	// Native cast
	String::operator bool() const noexcept { return value.size() > 0; }
	String::operator double() const noexcept
	{
		std::string::size_type end;
		double res;
		try
		{
			res = std::stod(value, &end);
		}catch(std::invalid_argument e){}
		return end == value.size() ? res : std::numeric_limits<double>::quiet_NaN();
	}
	String::operator int() const noexcept
	{
		std::string::size_type end;
		int res;
		try
		{
			res = std::stoi(value, &end, 10);
		}catch(std::invalid_argument e){}
		
		return end == value.size() ? res : std::numeric_limits<int>::quiet_NaN();
	}
	String::operator long long() const noexcept
	{
		std::string::size_type end;
		long long res;
		try
		{
			res = std::stoll(value, &end, 10);
		}catch(std::invalid_argument e){}

		return end == value.size() ? res : std::numeric_limits<long long>::quiet_NaN();
	}
	String::operator std::string() const noexcept { return value; }
	// Main operators
	NJS::VAR const String::operator[](NJS::VAR key) const
	{
		if (key.type == NJS::Enum::Type::Number)
		{
			auto i = (int)key;
			if (i >= 0 && i <= value.size())
			{
				return value.at(i);
			}
			else return undefined;
		}
{'fraction_non_alphanumeric': 0.170810461737165, 'fraction_numerical': 0.004520503713270907, 'mean_word_length': 3.766153846153846, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2471677', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1120, 'n_words': 267}