Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- class walidator
- {
- public:
- virtual bool waliduj() = 0;
- };
- class telefonkom : public walidator
- {
- private:
- std::string numer;
- public:
- bool waliduj()
- {
- const char* wzorcowy = "\\+?\\d{1,3}(-| )?\\d{3}(-| )?\\d{3}(-| )?\\d{3}";
- std::regex wzorzec(wzorcowy);
- return regex_match(numer, wzorzec);
- }
- telefonkom(std::string numer)
- {
- this->numer = numer;
- }
- };
- class kwota : public walidator
- {
- private:
- double ile;
- public:
- bool waliduj()
- {
- if (ile > 0)
- return 1;
- else return 0;
- }
- kwota(int ile)
- {
- this->ile = ile;
- }
- double &operator-(double &liczba)
- {
- ile = ile - liczba;
- return ile;
- }
- double &operator+(double &liczba)
- {
- ile = ile + liczba;
- return ile;
- }
- friend std::ostream & operator<<(std::ostream &wyjscie, const kwota &ile)
- {
- return wyjscie << ile;
- }
- };
- class email : public walidator
- {
- private:
- std::string nazwa;
- public:
- bool waliduj()
- {
- const char* wzorcowy = "(\\w+)(\\.|_)?(\\w+)@(\\w+)(\\.(\\w+))+";
- std::regex wzorzec(wzorcowy);
- return regex_match(nazwa, wzorzec);
- }
- email(std::string numer)
- {
- this->nazwa = numer;
- }
- email();
- friend std::ostream & operator<<(std::ostream &wyjscie, const std::string nazwa)
- {
- return wyjscie << nazwa;
- }
- };
- class telefonstac : public walidator
- {
- private:
- std::string numer;
- public:
- bool waliduj()
- {
- const char* wzorcowy = "\\d{2,3}(-| )?\\d{3}(-| )?\\d{3}(-| )?\\d{3}";
- std::regex wzorzec(wzorcowy);
- return regex_match(numer, wzorzec);
- }
- telefonstac(std::string numer)
- {
- this->numer = numer;
- }
- };
- class liczba_rzymska : public walidator
- {
- private:
- std::string liczba;
- public:
- bool waliduj()
- {
- const char* wzorcowa = "M{0,2}(C[MD]|D?C{0,3}|MCD|MD?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})";
- std::regex wzorzec(wzorcowa);
- return regex_match(liczba, wzorzec);
- }
- liczba_rzymska (std::string numer)
- {
- this->liczba = numer;
- }
- };
- class nr_faxu : public walidator
- {
- private:
- std::string numer;
- public:
- bool waliduj()
- {
- const char* fax = "\\+?\\(?\\d{1,3}\\)?(-| )\\(?\\d+\\)?(-| )(\\d{2,}(-| )\\d{2,}|\\d+)"; //najpierw kod kraju, potem kod strefy, na koniec numer (w dwóch formatach dozwolonych)
- std::regex wzorzec(fax);
- return regex_match(numer, wzorzec);
- }
- nr_faxu(std::string numer)
- {
- this->numer = numer;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement