From 2797b58646b29ed1342b57bb421fa987315ca3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 4 Jun 2016 16:45:14 +0200 Subject: [PATCH] Added missing ParserWarning file. --- include/plasp/utils/ParserWarning.h | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/plasp/utils/ParserWarning.h diff --git a/include/plasp/utils/ParserWarning.h b/include/plasp/utils/ParserWarning.h new file mode 100644 index 0000000..060ef9a --- /dev/null +++ b/include/plasp/utils/ParserWarning.h @@ -0,0 +1,59 @@ +#ifndef __PLASP__UTILS__PARSER_WARNING_H +#define __PLASP__UTILS__PARSER_WARNING_H + +#include +#include + +#include + +namespace plasp +{ +namespace utils +{ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// ParserWarning +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +class ParserWarning: public std::exception +{ + public: + explicit ParserWarning(const utils::Parser &parser) + : ParserWarning(parser, "Unspecified parser warning") + { + } + + explicit ParserWarning(const utils::Parser &parser, const char *message) + : ParserWarning(parser, static_cast(message)) + { + } + + explicit ParserWarning(const utils::Parser &parser, const std::string &message) + : m_message{std::to_string(parser.row()) + ":" + std::to_string(parser.column()) + "\t" + message} + { + } + + ~ParserWarning() throw() + { + } + + const char *what() const throw() + { + if (m_message.empty()) + return "Unspecified parser warning"; + + return m_message.c_str(); + } + + private: + std::string m_message; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +} +} + +#endif