From 4efa8bd9d477a30f4ed19c8e2f4063be4e2c1814 Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Tue, 3 Oct 2023 17:01:11 +0200 Subject: [PATCH] add exceptions --- .gitignore | 4 ++- lpstd.hpp | 3 ++ src/exceptions/exceptions.hpp | 7 +++++ src/exceptions/generic_exception.hpp | 32 ++++++++++++++++++++++ src/exceptions/notImplementedException.hpp | 22 +++++++++++++++ src/faker/faker.hpp | 6 ++++ src/faker/file.hpp | 27 ++++++++++++++++++ 7 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/exceptions/exceptions.hpp create mode 100644 src/exceptions/generic_exception.hpp create mode 100644 src/exceptions/notImplementedException.hpp create mode 100644 src/faker/faker.hpp create mode 100644 src/faker/file.hpp diff --git a/.gitignore b/.gitignore index ff1fef1..d04d428 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ main.cpp -*.exe \ No newline at end of file +*.exe +*.out +.vscode \ No newline at end of file diff --git a/lpstd.hpp b/lpstd.hpp index c2eb004..8ee6cfc 100644 --- a/lpstd.hpp +++ b/lpstd.hpp @@ -2,7 +2,10 @@ #ifndef __LPSTD_HPP__ #define __LPSTD_HPP__ + #include "src/patterns/singleton.hpp" #include "src/testing/testing.hpp" +// #include "src/faker/faker.hpp" +#include "src/exceptions/exceptions.hpp" #endif // __LPSTD_HPP__ diff --git a/src/exceptions/exceptions.hpp b/src/exceptions/exceptions.hpp new file mode 100644 index 0000000..7112c0d --- /dev/null +++ b/src/exceptions/exceptions.hpp @@ -0,0 +1,7 @@ +#ifndef EXCEPTIONS_HPP +#define EXCEPTIONS_HPP + +#include "generic_exception.hpp" +#include "notImplementedException.hpp" + +#endif // EXCEPTIONS_HPP \ No newline at end of file diff --git a/src/exceptions/generic_exception.hpp b/src/exceptions/generic_exception.hpp new file mode 100644 index 0000000..719e3f6 --- /dev/null +++ b/src/exceptions/generic_exception.hpp @@ -0,0 +1,32 @@ +#ifndef GENERIC_EXCEPTION_HPP +#define GENERIC_EXCEPTION_HPP + +#include +#include + +namespace lpstd +{ + + namespace exceptions + { + + class generic_exception : public std::exception + { + private: + std::string message; + + public: + generic_exception(std::string message) + { + this->message = message; + } + const char *what() const throw() + { + return this->message.c_str(); + } + }; + } + +} // namespace lpstd:: + +#endif // GENERIC_EXCEPTION_HPP \ No newline at end of file diff --git a/src/exceptions/notImplementedException.hpp b/src/exceptions/notImplementedException.hpp new file mode 100644 index 0000000..fa956e2 --- /dev/null +++ b/src/exceptions/notImplementedException.hpp @@ -0,0 +1,22 @@ +#ifndef NotImplementedException_HPP +#define NotImplementedException_HPP + +#include "generic_exception.hpp" + +namespace lpstd +{ + namespace exceptions + { + class NotImplementedException : public generic_exception + { + public: + NotImplementedException() : generic_exception("Not implemented exception") + { + } + }; + + } // namespace exceptions + +} // namespace lpstd + +#endif // NotImplementedException_HPP \ No newline at end of file diff --git a/src/faker/faker.hpp b/src/faker/faker.hpp new file mode 100644 index 0000000..e1892f4 --- /dev/null +++ b/src/faker/faker.hpp @@ -0,0 +1,6 @@ +#ifndef FAKER_HPP +#define FAKER_HPP + +#include "./file.hpp" + +#endif // FAKER_HPP \ No newline at end of file diff --git a/src/faker/file.hpp b/src/faker/file.hpp new file mode 100644 index 0000000..4c9fdaa --- /dev/null +++ b/src/faker/file.hpp @@ -0,0 +1,27 @@ +#ifndef FAKER_FILE_HPP +#define FAKER_FILE_HPP + +#include +namespace lpstd +{ + namespace faker + { + class file + { + public: + std::string virtualPath; + file() + { + this->virtualPath = "C:\\Users\\Public\\Documents\\lpstd\\faker\\file.txt"; + } + std::ofstream get_ofStream() + { + std::ofstream file; + file.open(this->virtualPath); + return file; + } + }; + } // namespace faker +} // namespace lpstd + +#endif // FAKER_FILE_HPP