<commit_before>// qflags.h
//

#pragma once

#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include <set>
#include <map>

//! Macro used to eliminate compiler warnings generated when formal parameters
//! are declared but unreferenced; particularly for parameters which are used
//! in one configuration but not another (e.g. Debug vs Release). MSVC's C1/C2
//! compiler generates unreferenced variable warnings for variables which are
//! only referenced in an assert expression however Clang/C2 does not.
#define QFLAGS_UNREFERENCED_PARAMETER(x) ((void)x)

namespace qflags {

////////////////////////////////////////////////////////////////////////////////
/**
 * @class command_line
 *
 * @brief Utility class encapsulating a command line
 *
 * Normalizes command line arguments into a UTF-8 encoded array of argument
 * strings. It accepts a single wide-character string, an array of wide-
 * character strings, or an array of multi-byte character strings. It is
 * *highly* recommended for developers on Windows platforms to use the wide-
 * character versions in order to avoid non-reversible character conversions.
 */
class command_line
{
  public:
    /**
     * Initialize from a UTF-16 encoded wide-character command line string.
     *  e.g. the return value of GetCommandLineW() on Windows.
     *
     *  @param args
     *      a UTF-16 encoded wide-character string.
     */
    command_line(wchar_t const* args);

    /**
     * Initialize from an array of UTF-16 encoded wide-character command line
     * argument strings.
     *  e.g. the return value of CommandLineToArgvW() on Windows.
     *
     *  @param argc
     *      number of elements in `argv`
     *  @param argv
     *      an array of UTF-16 encoded wide-character argument strings
     */
    command_line(int argc, wchar_t const* const* argv);

    /**
     * Initialize from an array of UTF-16 encoded wide-character command line
     * argument strings. Automatically deduces argc from static array size.
     *
     *  @param argv
     *      an array of UTF-16 encoded wide-character argument strings
     */
    template<size_t _Size>
    command_line(wchar_t const* const (&argv)[_Size])
        : command_line(static_cast<int>(_Size), argv) {}

    /**
     * Initialize from a single command line argument string encoded using the
     * specified locale. Defaults to the 'user-preferred' local set by the
     * operating system.
     *
     *  @param args
     *      an argument string
     *  @param locale
     *      a locale name used to interpret the string `args`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    command_line(char const* args, char const* locale = "");

    /**
     * Initialize from an array of command line argument strings encoded
     * using the specified locale. Defaults to the 'user-preferred' locale set
     * by the operating system.
     *
     *  @param argc
     *      number of elements in `argv`
     *  @param argv
     *      an array of argument strings
     *  @param locale
     *      a locale name used to interpret the strings in `argv`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    command_line(int argc, char const* const* argv, char const* locale = "");

    /**
     * Initialize from an array of command line argument strings encoded
     * using the specified locale. Defaults to the 'user-preferred' locale set
     * by the operating system. Automatically deduces argc from static array size.
     *
     *  @param argv
     *      an array of argument strings
     *  @param locale
     *      a locale name used to interpret the strings in `argv`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    template<size_t _Size>
    command_line(char const* const (&argv)[_Size], char const* locale = "")
        : command_line(static_cast<int>(_Size), argv, locale) {}

    /**
     * Construct a copy from another command_line instance.
     */
    command_line(command_line const& other);

    /**
     * Copy from another command_line instance.
     */
    command_line& operator=(command_line const& other);

    //! @return
    //!     number of argument strings.
    int argc() const { return static_cast<int>(_argv.size() - 1); }

    //! @return
    //!     array of UTF-8 encoded argument strings.
    char const* const* argv() const { return _argv.data(); }

    //! @return
    //!     specified argument by index as a UTF-8 encoded string.
    char const* argv(int argn) const { return _argv[argn]; }

  private:
    std::vector<char> _args;    //!< Argument string buffer
    std::vector<char*> _argv;   //!< Argument string pointers<commit_msg>Fix locale problems on MinGW<commit_after>// qflags.h
//

#pragma once

#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include <set>
#include <map>

//! Macro used to eliminate compiler warnings generated when formal parameters
//! are declared but unreferenced; particularly for parameters which are used
//! in one configuration but not another (e.g. Debug vs Release). MSVC's C1/C2
//! compiler generates unreferenced variable warnings for variables which are
//! only referenced in an assert expression however Clang/C2 does not.
#define QFLAGS_UNREFERENCED_PARAMETER(x) ((void)x)

namespace qflags {

////////////////////////////////////////////////////////////////////////////////
/**
 * @class command_line
 *
 * @brief Utility class encapsulating a command line
 *
 * Normalizes command line arguments into a UTF-8 encoded array of argument
 * strings. It accepts a single wide-character string, an array of wide-
 * character strings, or an array of multi-byte character strings. It is
 * *highly* recommended for developers on Windows platforms to use the wide-
 * character versions in order to avoid non-reversible character conversions.
 */
class command_line
{
  public:

    /**
     * Functor for specifying the default locale on different platforms.
     */
    struct default_locale {
#if defined(__MINGW32__)
        // Only C and POSIX locales are supported on MinGW so suppress conversion.
        operator const char*() const { return nullptr; };
#else //!defined(__MINGW32__)
        operator const char*() const { return ""; };
#endif //!defined(__MINGW32__)
    };

    /**
     * Initialize from a UTF-16 encoded wide-character command line string.
     *  e.g. the return value of GetCommandLineW() on Windows.
     *
     *  @param args
     *      a UTF-16 encoded wide-character string.
     */
    command_line(wchar_t const* args);

    /**
     * Initialize from an array of UTF-16 encoded wide-character command line
     * argument strings.
     *  e.g. the return value of CommandLineToArgvW() on Windows.
     *
     *  @param argc
     *      number of elements in `argv`
     *  @param argv
     *      an array of UTF-16 encoded wide-character argument strings
     */
    command_line(int argc, wchar_t const* const* argv);

    /**
     * Initialize from an array of UTF-16 encoded wide-character command line
     * argument strings. Automatically deduces argc from static array size.
     *
     *  @param argv
     *      an array of UTF-16 encoded wide-character argument strings
     */
    template<size_t _Size>
    command_line(wchar_t const* const (&argv)[_Size])
        : command_line(static_cast<int>(_Size), argv) {}

    /**
     * Initialize from a single command line argument string encoded using the
     * specified locale. Defaults to the 'user-preferred' local set by the
     * operating system.
     *
     *  @param args
     *      an argument string
     *  @param locale
     *      a locale name used to interpret the string `args`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    command_line(char const* args, char const* locale = default_locale());

    /**
     * Initialize from an array of command line argument strings encoded
     * using the specified locale. Defaults to the 'user-preferred' locale set
     * by the operating system.
     *
     *  @param argc
     *      number of elements in `argv`
     *  @param argv
     *      an array of argument strings
     *  @param locale
     *      a locale name used to interpret the strings in `argv`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    command_line(int argc, char const* const* argv, char const* locale = default_locale());

    /**
     * Initialize from an array of command line argument strings encoded
     * using the specified locale. Defaults to the 'user-preferred' locale set
     * by the operating system. Automatically deduces argc from static array size.
     *
     *  @param argv
     *      an array of argument strings
     *  @param locale
     *      a locale name used to interpret the strings in `argv`
     *      a value of `nullptr` will suppress encoding conversion.
     */
    template<size_t _Size>
    command_line(char const* const (&argv)[_Size], char const* locale = default_locale())
        : command_line(static_cast<int>(_Size), argv, locale) {}

    /**
     * Construct a copy from another command_line instance.
     */
    command_line(command_line const& other);

    /**
     * Copy from another command_line instance.
     */
    command_line& operator=(command_line const& other);

    //! @return
    //!     number of argument strings.
    int argc() const { return static_cast<int>(_argv.size() - 1); }

    //! @return
    //!     array of UTF-8 encoded argument strings.
    char const* const* argv() const { return _argv.data(); }

    //! @return
    //!     specified argument by index as a UTF-8 encoded string.
    char const* argv(int argn) const { return _argv[argn]; }

  private:
    std::vector<char> _args;    //!< Argument string buffer
    std::vector<char*> _argv;   //!< Argument string pointers
{'fraction_non_alphanumeric': 0.10521052105210521, 'fraction_numerical': 0.0044004400440044, 'mean_word_length': 2.538570417551309, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 33, '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': '3064595', 'n_tokens_mistral': 2734, 'n_tokens_neox': 2654, 'n_words': 1066}