<commit_before>//-------------------------------------------------------------------------------------
// ExportSettings.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//  
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/?LinkId=226208
//-------------------------------------------------------------------------------------

#include "stdafx.h"
#include "ExportSettings.h"

namespace ATG
{
    ExportSettingsManager   g_SettingsManager;
    ExportCoreSettings      g_ExportCoreSettings;

    ExportSettingsEntry::ExportSettingsEntry()
        : m_pFirstChild( nullptr ),
          m_pSibling( nullptr ),
          m_pLinkedCurrentValue( nullptr ),
          m_pEnumValues( nullptr ),
          m_dwEnumValueCount( 0 )
    {
    }

    ExportSettingsEntry::~ExportSettingsEntry()
    {
        if( m_pFirstChild )
        {
            delete m_pFirstChild;
            m_pFirstChild = nullptr;
        }
        if( m_pSibling )
        {
            delete m_pSibling;
            m_pSibling = nullptr;
        }
    }

    void ExportSettingsEntry::SetDefaultValue( bool bSetChildren, bool bSetSiblings )
    {
        if( m_pLinkedCurrentValue )
        {
            if( m_DefaultValue.m_Type == ExportVariant::VT_STRING )
                strcpy_s( (CHAR*)m_pLinkedCurrentValue, SETTINGS_STRING_LENGTH, m_DefaultValue.m_strValue );
            else if( m_DefaultValue.m_Type == ExportVariant::VT_BOOL )
                *reinterpret_cast<bool*>( m_pLinkedCurrentValue ) = m_DefaultValue.m_iValue ? true : false;
            else
                *reinterpret_cast<INT*>( m_pLinkedCurrentValue ) = m_DefaultValue.m_iValue;
        }
        else
        {
            m_CurrentValue = m_DefaultValue;
        }

        if( bSetSiblings && m_pSibling )
        {
            m_pSibling->SetDefaultValue( bSetChildren, true );
        }
        if( bSetChildren && m_pFirstChild )
        {
            m_pFirstChild->SetDefaultValue( true, true );
        }
    }

    void ExportSettingsEntry::ReverseChildOrder()
    {
        ExportSettingsEntry* pHead = nullptr;
        ExportSettingsEntry* pCurrent = m_pFirstChild;

        while( pCurrent )
        {<commit_msg>Fixed another bug with bool vs. BOOL<commit_after>//-------------------------------------------------------------------------------------
// ExportSettings.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//  
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/?LinkId=226208
//-------------------------------------------------------------------------------------

#include "stdafx.h"
#include "ExportSettings.h"

namespace ATG
{
    ExportSettingsManager   g_SettingsManager;
    ExportCoreSettings      g_ExportCoreSettings;

    ExportSettingsEntry::ExportSettingsEntry()
        : m_pFirstChild( nullptr ),
          m_pSibling( nullptr ),
          m_pLinkedCurrentValue( nullptr ),
          m_pEnumValues( nullptr ),
          m_dwEnumValueCount( 0 )
    {
    }

    ExportSettingsEntry::~ExportSettingsEntry()
    {
        if( m_pFirstChild )
        {
            delete m_pFirstChild;
            m_pFirstChild = nullptr;
        }
        if( m_pSibling )
        {
            delete m_pSibling;
            m_pSibling = nullptr;
        }
    }

    void ExportSettingsEntry::SetDefaultValue( bool bSetChildren, bool bSetSiblings )
    {
        if( m_pLinkedCurrentValue )
        {
            if( m_DefaultValue.m_Type == ExportVariant::VT_STRING )
                strcpy_s( (CHAR*)m_pLinkedCurrentValue, SETTINGS_STRING_LENGTH, m_DefaultValue.m_strValue );
            else if( m_DefaultValue.m_Type == ExportVariant::VT_BOOL )
                *reinterpret_cast<bool*>( m_pLinkedCurrentValue ) = m_DefaultValue.m_bValue ? true : false;
            else
                *reinterpret_cast<INT*>( m_pLinkedCurrentValue ) = m_DefaultValue.m_iValue;
        }
        else
        {
            m_CurrentValue = m_DefaultValue;
        }

        if( bSetSiblings && m_pSibling )
        {
            m_pSibling->SetDefaultValue( bSetChildren, true );
        }
        if( bSetChildren && m_pFirstChild )
        {
            m_pFirstChild->SetDefaultValue( true, true );
        }
    }

    void ExportSettingsEntry::ReverseChildOrder()
    {
        ExportSettingsEntry* pHead = nullptr;
        ExportSettingsEntry* pCurrent = m_pFirstChild;

        while( pCurrent )
        {
{'fraction_non_alphanumeric': 0.15082434357826174, 'fraction_numerical': 0.0028495827396702628, 'mean_word_length': 1.7920454545454545, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5694505', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1333, 'n_words': 274}