<commit_before>//Copyright 2015 <NAME>
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

// Contact :
// Email             : <EMAIL>
// GitHub repository : https://github.com/SolaireLibrary/SolaireCPP

#include "Solaire/Encode/GenericValue.hpp"

namespace Solaire {

    typedef ArrayList<GenericValue> ArrayType;
    typedef ListMap<CString, GenericValue> ObjectType;

	// GenericValue

    GenericValue::GenericValue() throw() :
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(NULL_T)
    {}

    GenericValue::GenericValue(const GenericValue& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
            mString = new(mAllocator->allocate(sizeof(CString))) CString(*aOther.mString);
            break;
        case ARRAY_T:
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType(*aOther.mArray);
            break;
        case OBJECT_T:
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType(*aOther.mObject);
            break;
        default:
            break;
        }
    }

    GenericValue::GenericValue(GenericValue&& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
        case ARRAY_T:
        case OBJECT_T:
            mString = aOther.mString;
            break;
        default:
            break;
        }

        aOther.mType = NULL_T;
    }

    GenericValue::GenericValue(const char aValue)throw() :
        mChar(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(CHAR_T)
    {}

    GenericValue::GenericValue(const bool aValue) throw() :
        mBool(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(BOOL_T)
    {}

    GenericValue::GenericValue(const uint8_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint16_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint32_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint64_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const int8_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int16_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int32_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int64_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const double aValue) throw() :
        mDouble(aValue),
        mAllocator(&DEFAULT_ALLOCATOR),
        mType(DOUBLE_T)
    {}

        // C++ operators

    GenericValue& GenericValue::operator=(const GenericValue& aOther) throw() {
        setNull();
        mType = aOther.mType;
        mAllocator = aOther.mAllocator;
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;<commit_msg>Fixed default allocator<commit_after>//Copyright 2015 <NAME>
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

// Contact :
// Email             : <EMAIL>
// GitHub repository : https://github.com/SolaireLibrary/SolaireCPP

#include "Solaire/Encode/GenericValue.hpp"

namespace Solaire {

    typedef ArrayList<GenericValue> ArrayType;
    typedef ListMap<CString, GenericValue> ObjectType;

	// GenericValue

    GenericValue::GenericValue() throw() :
        mAllocator(&getDefaultAllocator()),
        mType(NULL_T)
    {}

    GenericValue::GenericValue(const GenericValue& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
            mString = new(mAllocator->allocate(sizeof(CString))) CString(*aOther.mString);
            break;
        case ARRAY_T:
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType(*aOther.mArray);
            break;
        case OBJECT_T:
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType(*aOther.mObject);
            break;
        default:
            break;
        }
    }

    GenericValue::GenericValue(GenericValue&& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
        case ARRAY_T:
        case OBJECT_T:
            mString = aOther.mString;
            break;
        default:
            break;
        }

        aOther.mType = NULL_T;
    }

    GenericValue::GenericValue(const char aValue)throw() :
        mChar(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(CHAR_T)
    {}

    GenericValue::GenericValue(const bool aValue) throw() :
        mBool(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(BOOL_T)
    {}

    GenericValue::GenericValue(const uint8_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint16_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint32_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint64_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const int8_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int16_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int32_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int64_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const double aValue) throw() :
        mDouble(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(DOUBLE_T)
    {}

        // C++ operators

    GenericValue& GenericValue::operator=(const GenericValue& aOther) throw() {
        setNull();
        mType = aOther.mType;
        mAllocator = aOther.mAllocator;
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
{'fraction_non_alphanumeric': 0.10255872483221476, 'fraction_numerical': 0.004614093959731544, 'mean_word_length': 2.251619502216161, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5918340', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2850, 'n_words': 579}