<commit_before>// 
// Clutter.cpp
// Clutter
//
// Created by <NAME> on 24-01-2016
// Copyright (c) <NAME>. All rights reserved.
//
// Version 1.0
//

#include "Clutter.h"
#include "Utils.h"

namespace Clutter {

    // 
    // Constructor
    //
    Clutter::Clutter( int argc, const char* argv[] )
    {
        // Initialize processing variables
        string              flag;
        string              tag;
        std::vector<string> values;

        // Loop over all tags in the command line
        for (int i = 1; i < argc; ++i) {
            // Convert the current entry to a tag
            string flag = string( argv[i] );

            // Ensure the tag is a flag-type
            if ( Utils::isValue( flag ) ) 
                throw "error: parsing error";

            // Ensure the flag does not alread exist
            if ( mCommandMap.count( flag ) > 0 )
                throw "error: duplicate flag";

            // Find the next flag (or the end of list)
            for (i++; i < argc; i++) { 
                // Load the next tag
                tag = string( argv[i] );
                // Test of tag type
                if ( Utils::isFlag( tag ) ) break;                      // flag found: block is complete
                else                        values.push_back( tag );    // value found: add to current block
            }

            // Store the tag & values as a block
            mCommandMap.emplace( flag, CommandBlock(values) );

            // Clear the processing memory
            values.clear();

            // Continue with next block
            // ...
        }

        // Set help flag
        if ( this->has_flag("-h") || this->has_flag("--help") ) {
            mHelpFlag = true;
        }
    }

    //
    // Support function
    // 
    bool Clutter::has_flag( string flag )
    {
        if ( mCommandMap.count( flag ) == 1 )
            return true;
        else
            return false;
    }


    // 
    // Parse termination function
    //
    void Clutter::end_parse()
    {
        // Check the help flag
        if ( mHelpFlag ) {
            printf( "Required arguments:\n" );
            for ( auto& block : mHelpTree_required )
                block.print();

            printf( "Optional arguments:\n" );
            for ( auto& block : mHelpTree_requested )
                block.print();

            exit(0);
        }

        // Check orphan options
        for ( auto& block : mCommandMap ) {
            if ( !block.processed ) {
                throw "error: orphan options";
            }
        }
    }
}
<commit_msg>Fix CommandMap iterator<commit_after>// 
// Clutter.cpp
// Clutter
//
// Created by <NAME> on 24-01-2016
// Copyright (c) <NAME>. All rights reserved.
//
// Version 1.0
//

#include "Clutter.h"
#include "Utils.h"

namespace Clutter {

    // 
    // Constructor
    //
    Clutter::Clutter( int argc, const char* argv[] )
    {
        // Initialize processing variables
        string              flag;
        string              tag;
        std::vector<string> values;

        // Loop over all tags in the command line
        for (int i = 1; i < argc; ++i) {
            // Convert the current entry to a tag
            string flag = string( argv[i] );

            // Ensure the tag is a flag-type
            if ( Utils::isValue( flag ) ) 
                throw "error: parsing error";

            // Ensure the flag does not alread exist
            if ( mCommandMap.count( flag ) > 0 )
                throw "error: duplicate flag";

            // Find the next flag (or the end of list)
            for (i++; i < argc; i++) { 
                // Load the next tag
                tag = string( argv[i] );
                // Test of tag type
                if ( Utils::isFlag( tag ) ) break;                      // flag found: block is complete
                else                        values.push_back( tag );    // value found: add to current block
            }

            // Store the tag & values as a block
            mCommandMap.emplace( flag, CommandBlock(values) );

            // Clear the processing memory
            values.clear();

            // Continue with next block
            // ...
        }

        // Set help flag
        if ( this->has_flag("-h") || this->has_flag("--help") ) {
            mHelpFlag = true;
        }
    }

    //
    // Support function
    // 
    bool Clutter::has_flag( string flag )
    {
        if ( mCommandMap.count( flag ) == 1 )
            return true;
        else
            return false;
    }


    // 
    // Parse termination function
    //
    void Clutter::end_parse()
    {
        // Check the help flag
        if ( mHelpFlag ) {
            printf( "Required arguments:\n" );
            for ( auto& block : mHelpTree_required )
                block.print();

            printf( "Optional arguments:\n" );
            for ( auto& block : mHelpTree_requested )
                block.print();

            exit(0);
        }

        // Check orphan options
        for ( auto& map : mCommandMap ) {
            if ( !map.second.processed ) {
                throw "error: orphan options";
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.1123444976076555, 'fraction_numerical': 0.005358851674641148, 'mean_word_length': 1.1976450798990748, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1405459', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1367, 'n_words': 438}