<commit_before>/*
 * strcheck.hpp
 *  The class to check if strings are integer, decimal, or real number
 *
 *  written by janus_wel<<EMAIL>>
 *  This source code is in public domain, and has NO WARRANTY.
 * */

#ifndef STRCHECK_HPP
#define STRCHECK_HPP

#include <cstring>
#include <locale>
#include <string>

namespace util {
    namespace string {
        template<typename Char> struct numeric_traits;
        template<> struct numeric_traits<char> {
            typedef char    char_type;
            static const char_type positive = '+';
            static const char_type negative = '-';
        };
        template<> struct numeric_traits<wchar_t> {
            typedef wchar_t char_type;
            static const char_type positive = L'+';
            static const char_type negative = L'-';
        };

        template<   typename Char,
                    typename CharTraits = std::char_traits<Char>,
                    typename NumTraits = numeric_traits<Char> >
        class basic_check {
            public:
                typedef Char                            char_type;
                typedef std::basic_string<char_type>    string_type;
                typedef std::ctype<char_type>           ctype_type;
                typedef std::numpunct<char_type>        numpunct_type;

            private:
                std::locale loc;

            public:
                // constructor
                explicit basic_check(void) : loc(std::locale()) {}
                explicit basic_check(const std::locale& loc) : loc(loc) {}

            private:
                const ctype_type& ctype(void) const {
                    static const ctype_type& ctype =
                        std::use_facet<ctype_type>(loc);
                    return ctype;
                }

                char_type decimal_point(void) const {
                    static const char_type decimal_point =
                        std::use_facet<numpunct_type>(loc).decimal_point();
                    return decimal_point;
                }

            public:
                bool is_integer(const char_type* const str) const {
                    const char_type* const first =<commit_msg>Add some member functions<commit_after>/*
 * strcheck.hpp
 *  The class to check if strings are integer, decimal, or real number
 *
 *  written by janus_wel<<EMAIL>>
 *  This source code is in public domain, and has NO WARRANTY.
 * */

#ifndef STRCHECK_HPP
#define STRCHECK_HPP

#include <cstring>
#include <locale>
#include <string>

namespace util {
    namespace string {
        template<typename Char> struct numeric_traits;
        template<> struct numeric_traits<char> {
            typedef char    char_type;
            static const char_type positive = '+';
            static const char_type negative = '-';
        };
        template<> struct numeric_traits<wchar_t> {
            typedef wchar_t char_type;
            static const char_type positive = L'+';
            static const char_type negative = L'-';
        };

        template<   typename Char,
                    typename CharTraits = std::char_traits<Char>,
                    typename NumTraits = numeric_traits<Char> >
        class basic_check {
            public:
                typedef Char                            char_type;
                typedef std::basic_string<char_type>    string_type;
                typedef std::ctype<char_type>           ctype_type;
                typedef std::numpunct<char_type>        numpunct_type;

            private:
                std::locale loc;

            public:
                // constructor
                explicit basic_check(void) : loc(std::locale()) {}
                explicit basic_check(const std::locale& loc) : loc(loc) {}

            private:
                const ctype_type& ctype(void) const {
                    static const ctype_type& ctype =
                        std::use_facet<ctype_type>(loc);
                    return ctype;
                }

                char_type decimal_point(void) const {
                    static const char_type decimal_point =
                        std::use_facet<numpunct_type>(loc).decimal_point();
                    return decimal_point;
                }

            public:
                bool is_positive(const char_type* const str) const {
                    return !is_negative(str);
                }

                bool is_positive(const string_type& str) const {
                    return is_positive(str.c_str());
                }

                bool is_negative(const char_type* const str) const {
                    return str[0] == NumTraits::negative;
                }

                bool is_negative(const string_type& str) const {
                    return is_negative(str.c_str());
                }

                bool is_integer(const char_type* const str) const {
                    const char_type* const first =
{'fraction_non_alphanumeric': 0.07784067933683785, 'fraction_numerical': 0.0002021835826930853, 'mean_word_length': 1.5317297850562948, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '1414232', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1201, 'n_words': 326}