<commit_before>#include <iostream>
#include <cmath>
#include <vector>
#include <stdexcept>
#include <regex>

#include "showcase.h"

static void showSimpleIteration()
{
    int myarray[5]={ 1,2,3,4,5};
    for (auto &x : myarray) x*=2;
    for (auto x: myarray) std::cout << x << " ";
    std::cout << std::endl;
}

/* validator delegation */
class MyHour {
    int hour;
    public:
    MyHour(int hour_in) {
        if ((0<=hour_in) and (hour_in<=23))
            hour=hour_in;
        else
            hour=0;
        std::cout << "hour=" << hour << std::endl;
    }
    MyHour(): MyHour(0) {};
    MyHour(double hour_in)
        :MyHour(static_cast<int>(ceil(hour_in))) {};
};

static void showValidatorDelegation()
{
  MyHour(10);  
  MyHour(100);
  MyHour();
  MyHour(22.45);
}

#if __GNU_C__ == 4 && __GNU_C_MINOR__ >= 7
#define GCC_SUPPORTS_INHERITED_CONSTRUCTORS
#endif

#ifdef GCC_SUPPORTS_INHERITED_CONSTRUCTORS
class IcBase {
    public:
        IcBase(int i) {
            std::cout << "IcBase::IcBase("<< i << std::endl;
        }
        IcBase(std::string s) {
            std::cout << "IcBase::IcBase("<< s << std::endl;
        }
};

class IcDerived: public IcBase {
    public:
        using IcBase::IcBase;
        IcDerived(double d) {
            std::cout << "IcDerived::IcDerived(" << d << std::endl;
        }
};

void showInheritedConstructor() {
    IcDerived(2011);
    IcDerived("C++11");
    IcDerived(0.33);
}
#else
void showInheritedConstructor() { std::cout << "inherited constructor not available" << std::endl; }
#endif

void showRawStringLiteral()
{
    std::cout << R"(Eins \ zwei \n
        drei)" << std::endl;
    std::cout << R"egal(Eins "()" zwei \ drei )egal" << std::endl;
}

void showBasicRegex()
{
    // http://www.cplusplus.com/reference/regex/basic_regex/
    // regex are ECMA script
    // see http://solarianprogrammer.com/2011/10/12/cpp-11-regex-tutorial/
    std::regex rx("marian");
    // uh, looks weird. No subset matchable?
    if (std::regex_match("marianx", rx))
        std::cout << "rule 1 matches" << std::endl;
    if (std::regex_match("<<EMAIL>>", rx))
        std::cout << "rule 2 matches" << std::endl;
    if (!std::regex_match("<<EMAIL>>", rx))
        std::cout << "rule 3 matches NOT" << std::endl;
}

void Showcase::run()
{
    showInheritedConstructor();
    showSimpleIteration();
    showValidatorDelegation();
    showRawStringLiteral();
    showBasicRegex();
}

void Showcase::throw_simple()
{
    // http://www.cplusplus.com/reference/stdexcept/runtime_error/
    throw std::runtime_error("showtime in showcase");
}


<commit_msg>regex-Versuche.<commit_after>#include <iostream>
#include <cmath>
#include <vector>
#include <stdexcept>
#include <regex>

#include "showcase.h"

using namespace std;

static void showSimpleIteration()
{
    int myarray[5]={ 1,2,3,4,5};
    for (auto &x : myarray) x*=2;
    for (auto x: myarray) cout << x << " ";
    cout << endl;
}

/* validator delegation */
class MyHour {
    int hour;
    public:
    MyHour(int hour_in) {
        if ((0<=hour_in) and (hour_in<=23))
            hour=hour_in;
        else
            hour=0;
        cout << "hour=" << hour << endl;
    }
    MyHour(): MyHour(0) {};
    MyHour(double hour_in)
        :MyHour(static_cast<int>(ceil(hour_in))) {};
};

static void showValidatorDelegation()
{
  MyHour(10);  
  MyHour(100);
  MyHour();
  MyHour(22.45);
}

#if __GNU_C__ == 4 && __GNU_C_MINOR__ >= 7
#define GCC_SUPPORTS_INHERITED_CONSTRUCTORS
#endif

#ifdef GCC_SUPPORTS_INHERITED_CONSTRUCTORS
class IcBase {
    public:
        IcBase(int i) {
            cout << "IcBase::IcBase("<< i << endl;
        }
        IcBase(string s) {
            cout << "IcBase::IcBase("<< s << endl;
        }
};

class IcDerived: public IcBase {
    public:
        using IcBase::IcBase;
        IcDerived(double d) {
            cout << "IcDerived::IcDerived(" << d << endl;
        }
};

void showInheritedConstructor() {
    IcDerived(2011);
    IcDerived("C++11");
    IcDerived(0.33);
}
#else
void showInheritedConstructor() { cout << "inherited constructor not available" << endl; }
#endif

void showRawStringLiteral()
{
    cout << R"(Eins \ zwei \n
        drei)" << endl;
    cout << R"egal(Eins "()" zwei \ drei )egal" << endl;
}

void showBasicRegex()
{
    // http://www.cplusplus.com/reference/regex/basic_regex/
    // regex are ECMA script
    // see http://solarianprogrammer.com/2011/10/12/cpp-11-regex-tutorial/
    regex rx("<marian");
    string candis[] = { "<<EMAIL>>", "<<EMAIL> <EMAIL>>", "<<EMAIL>>", "marian", "maria+n" };
    // ok, regex_search() is ==def false for now (gcc 4.7.2).
    for ( auto &testme : candis ) {
        cout << "testing " << testme << ": ";
        if (regex_search(testme, rx))
            cout << "is";
        else
            cout << "not";
        cout << " matching." << endl;
    }
}

void Showcase::run()
{
    showInheritedConstructor();
    showSimpleIteration();
    showValidatorDelegation();
    showRawStringLiteral();
    showBasicRegex();
}

void Showcase::throw_simple()
{
    // http://www.cplusplus.com/reference/stdexcept/runtime_error/
    throw runtime_error("showtime in showcase");
}



{'fraction_non_alphanumeric': 0.17096649980747017, 'fraction_numerical': 0.01732768579129765, 'mean_word_length': 2.8972243060765193, 'pattern_counts': {'":': 1, '<': 141, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3987284', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1880, 'n_words': 379}