<commit_before>#ifndef VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif


#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include <string>

namespace YAML
{
	inline Value::Value(): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		m_pNode->set_null();
	}
	
	inline Value::Value(ValueType::value type): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		m_pNode->set_type(type);
	}
	
	template<typename T>
	inline Value::Value(const T& rhs): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		Assign(rhs);
	}
	
	inline Value::Value(const Value& rhs): m_pMemory(rhs.m_pMemory), m_pNode(rhs.m_pNode)
	{
	}
	
	inline Value::Value(detail::node& node, detail::shared_memory_holder pMemory): m_pMemory(pMemory), m_pNode(&node)
	{
	}

	inline Value::~Value()
	{
	}

	inline ValueType::value Value::Type() const
	{
		return m_pNode->type();
	}
	
	// access
	template<typename T>
	inline const T Value::as() const
	{
		T t;
		if(convert<T>::decode(*this, t))
			return t;
		throw std::runtime_error("Unable to convert to type");
	}
	
	template<>
	inline const std::string Value::as() const
	{
		if(Type() != ValueType::Scalar)
			throw std::runtime_error("Unable to convert to string, not a scalar");
		return scalar();
	}

	inline const std::string& Value::scalar() const
	{
		return m_pNode->scalar();
	}

	// assignment
	inline bool Value::is(const Value& rhs) const
	{
		return m_pNode->is(*rhs.m_pNode);
	}

	template<typename T>
	inline Value& Value::operator=(const T& rhs)
	{
		Assign(rhs);
		return *this;
	}
	
	template<typename T>
	inline void Value::Assign(const T& rhs)
	{
		AssignData(convert<T>::encode(rhs));
	}

	template<>
	inline void Value::Assign(const std::string& rhs)
	{
		m_pNode->set_scalar(rhs);
	}

	inline void Value::Assign(const char *rhs)
	{
		m_pNode->set_scalar(rhs);
	}

	inline void Value::Assign(char *rhs)
	{
		m_pNode->set_scalar(rhs);
	}
	
	inline Value& Value::operator=(const Value& rhs)
	{
		if(is(rhs))
			return *this;
		AssignNode(rhs);
		return *this;
	}

	void Value::AssignData(const Value& rhs)
	{
		m_pNode->set_data(*rhs.m_pNode);
		m_pMemory->merge(*rhs.m_pMemory);
	}

	void Value::AssignNode(const Value& rhs)
	{
		m_pNode->set_ref(*rhs.m_pNode);
		m_pMemory->merge(*rhs.m_pMemory);
	}
<commit_msg>Switched value = otherValue to assign the actual nodes after setting the reference (so that tmp = foo['bar']; tmp = other; is the same as foo['bar'] = other;)<commit_after>#ifndef VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif


#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include <string>

namespace YAML
{
	inline Value::Value(): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		m_pNode->set_null();
	}
	
	inline Value::Value(ValueType::value type): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		m_pNode->set_type(type);
	}
	
	template<typename T>
	inline Value::Value(const T& rhs): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
	{
		Assign(rhs);
	}
	
	inline Value::Value(const Value& rhs): m_pMemory(rhs.m_pMemory), m_pNode(rhs.m_pNode)
	{
	}
	
	inline Value::Value(detail::node& node, detail::shared_memory_holder pMemory): m_pMemory(pMemory), m_pNode(&node)
	{
	}

	inline Value::~Value()
	{
	}

	inline ValueType::value Value::Type() const
	{
		return m_pNode->type();
	}
	
	// access
	template<typename T>
	inline const T Value::as() const
	{
		T t;
		if(convert<T>::decode(*this, t))
			return t;
		throw std::runtime_error("Unable to convert to type");
	}
	
	template<>
	inline const std::string Value::as() const
	{
		if(Type() != ValueType::Scalar)
			throw std::runtime_error("Unable to convert to string, not a scalar");
		return scalar();
	}

	inline const std::string& Value::scalar() const
	{
		return m_pNode->scalar();
	}

	// assignment
	inline bool Value::is(const Value& rhs) const
	{
		return m_pNode->is(*rhs.m_pNode);
	}

	template<typename T>
	inline Value& Value::operator=(const T& rhs)
	{
		Assign(rhs);
		return *this;
	}
	
	template<typename T>
	inline void Value::Assign(const T& rhs)
	{
		AssignData(convert<T>::encode(rhs));
	}

	template<>
	inline void Value::Assign(const std::string& rhs)
	{
		m_pNode->set_scalar(rhs);
	}

	inline void Value::Assign(const char *rhs)
	{
		m_pNode->set_scalar(rhs);
	}

	inline void Value::Assign(char *rhs)
	{
		m_pNode->set_scalar(rhs);
	}
	
	inline Value& Value::operator=(const Value& rhs)
	{
		if(is(rhs))
			return *this;
		AssignNode(rhs);
		return *this;
	}

	void Value::AssignData(const Value& rhs)
	{
		m_pNode->set_data(*rhs.m_pNode);
		m_pMemory->merge(*rhs.m_pMemory);
	}

	void Value::AssignNode(const Value& rhs)
	{
		m_pNode->set_ref(*rhs.m_pNode);
		m_pMemory->merge(*rhs.m_pMemory);
		m_pNode = rhs.m_pNode;
	}

{'fraction_non_alphanumeric': 0.1572744014732965, 'fraction_numerical': 0.019521178637200737, 'mean_word_length': 4.99448123620309, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 55, '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': '3490718', 'n_tokens_mistral': 2271, 'n_tokens_neox': 2124, 'n_words': 407}