diff --git a/alib2common/src/exception/CommonException.cpp b/alib2common/src/exception/CommonException.cpp index e01db6fd2503bdf5c2f17599e070a2683afac131..702e08ab81b52c3a0ee5a8a174d0d8cab20647a7 100644 --- a/alib2common/src/exception/CommonException.cpp +++ b/alib2common/src/exception/CommonException.cpp @@ -37,10 +37,6 @@ CommonException::CommonException ( std::string cause, std::string backtrace, std this->m_whatMessage += this->m_cause; } -int CommonException::compare(const CommonException& other) const { - return this->m_whatMessage.compare(other.m_whatMessage); -} - const char * CommonException::what ( ) const noexcept { return m_whatMessage.c_str ( ); } diff --git a/alib2common/src/exception/CommonException.h b/alib2common/src/exception/CommonException.h index 277478f0ef1a2145792ba4673f9590c36e62edca..127450cf4df7c646d859cc724c0872c06ade3915 100644 --- a/alib2common/src/exception/CommonException.h +++ b/alib2common/src/exception/CommonException.h @@ -12,7 +12,6 @@ #include <ostream> #include <alib/string> -#include <alib/compare> namespace exception { @@ -22,7 +21,7 @@ namespace exception { * * Extends standard exception and additionally contains cause, backtrace (if conputed), and copy of command line string used to execute the program. */ -class CommonException : public std::exception, public ext::CompareOperators < CommonException > { +class CommonException : public std::exception { protected: /** * \brief @@ -61,15 +60,6 @@ public: */ explicit CommonException ( std::string cause, std::string backtrace, std::string command ); - /** - * The actual compare method - * - * \param other the other instance - * - * \returns the actual relation between two by type same expression instances - */ - int compare ( const CommonException & other ) const; - /** * \return reason why the exception occurred */ diff --git a/alib2xml/src/abstraction/XmlParserAbstraction.hpp b/alib2xml/src/abstraction/XmlParserAbstraction.hpp index 14748eb0134c4613b84181c54257411b8f40f2a3..b5e55de3037b0e1360280e535b7f6404e0fa55b6 100644 --- a/alib2xml/src/abstraction/XmlParserAbstraction.hpp +++ b/alib2xml/src/abstraction/XmlParserAbstraction.hpp @@ -26,13 +26,6 @@ public: } }; -template < > -inline bool XmlParserAbstraction < exception::CommonException >::run ( ) { - std::pair < std::shared_ptr < OperationAbstraction >, bool > & param = std::get < 0 > ( this->m_params ); - exception::CommonException ex = factory::XmlDataFactory::fromTokens ( abstraction::retrieveValue < ext::deque < sax::Token > && > ( param.first, param.second ) ); - throw ex; -} - } /* namespace abstraction */ #endif /* _XML_PARSER_ABSTRACTION_HPP_ */ diff --git a/alib2xml/src/exception/xml/CommonException.cpp b/alib2xml/src/exception/xml/CommonException.cpp deleted file mode 100644 index 3a1c4173ec9d40415441a99061dbdf87f30ab95a..0000000000000000000000000000000000000000 --- a/alib2xml/src/exception/xml/CommonException.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CommonException.cpp - * - * Created on: Apr 1, 2013 - * Author: Martin Zak - */ - -#include "CommonException.h" - -#include <object/Object.h> -#include <registration/XmlRegistration.hpp> - -namespace core { - -exception::CommonException xmlApi < exception::CommonException >::parse ( ext::deque < sax::Token >::iterator & input ) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, xmlTagName()); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "cause"); - std::string cause = ""; - if (input->getType() == sax::Token::TokenType::CHARACTER) { - cause = std::move(*input).moveData(); - ++input; - } - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "cause"); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "backtrace"); - std::string backtrace = ""; - if (input->getType() == sax::Token::TokenType::CHARACTER) { - backtrace = std::move(*input).moveData(); - ++input; - } - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "backtrace"); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "command"); - std::string command = ""; - if (input->getType() == sax::Token::TokenType::CHARACTER) { - command = std::move(*input).moveData(); - ++input; - } - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "command"); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, xmlTagName()); - return exception::CommonException(std::move(cause), std::move(backtrace), std::move(command)); -} - -bool xmlApi < exception::CommonException >::first ( const ext::deque < sax::Token >::const_iterator & input ) { - return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); -} - -std::string xmlApi < exception::CommonException >::xmlTagName ( ) { - return "CommonException"; -} - -void xmlApi < exception::CommonException >::compose ( ext::deque < sax::Token > & output, const exception::CommonException & data ) { - output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT ); - output.emplace_back ( "cause", sax::Token::TokenType::START_ELEMENT ); - output.emplace_back ( data.getCause ( ), sax::Token::TokenType::CHARACTER ); - output.emplace_back ( "cause", sax::Token::TokenType::END_ELEMENT ); - output.emplace_back ( "backtrace", sax::Token::TokenType::START_ELEMENT ); - output.emplace_back ( data.getBacktrace ( ), sax::Token::TokenType::CHARACTER ); - output.emplace_back ( "backtrace", sax::Token::TokenType::END_ELEMENT ); - output.emplace_back ( "command", sax::Token::TokenType::START_ELEMENT ); - output.emplace_back ( data.getCommand ( ), sax::Token::TokenType::CHARACTER ); - output.emplace_back ( "command", sax::Token::TokenType::END_ELEMENT ); - output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); -} - -} /* namespace core */ - -namespace { - -static auto xmlWrite = registration::XmlWriterRegister < exception::CommonException > ( ); -static auto xmlRead = registration::XmlReaderRegister < exception::CommonException > ( ); - -static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, exception::CommonException > ( ); - -} /* namespace */ diff --git a/alib2xml/src/exception/xml/CommonException.h b/alib2xml/src/exception/xml/CommonException.h deleted file mode 100644 index 48d03d5ac8b9066e7f98cfe36af3610620137b1f..0000000000000000000000000000000000000000 --- a/alib2xml/src/exception/xml/CommonException.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CommonException.h - * - * Created on: Apr 1, 2013 - * Author: Martin Zak - */ - -#ifndef _XML_COMMON_EXCEPTION_H_ -#define _XML_COMMON_EXCEPTION_H_ - -#include <exception/CommonException.h> -#include <alib/string> -#include <core/xmlApi.hpp> - -namespace core { - -template < > -struct xmlApi < exception::CommonException > { - static exception::CommonException parse ( ext::deque < sax::Token >::iterator & input ); - static bool first ( const ext::deque < sax::Token >::const_iterator & input ); - static std::string xmlTagName ( ); - static void compose ( ext::deque < sax::Token > & output, const exception::CommonException & data ); -}; - -} /* namespace core */ - -#endif /* XML_COMMON_EXCEPTION_H_ */ diff --git a/alib2xml/src/factory/XmlDataFactory.hpp b/alib2xml/src/factory/XmlDataFactory.hpp index 681523c0b9c7b6c46bcf52f748df5681d4f23807..c529e34a49591e7ad39aa57c65a3c46622a3493e 100644 --- a/alib2xml/src/factory/XmlDataFactory.hpp +++ b/alib2xml/src/factory/XmlDataFactory.hpp @@ -16,7 +16,6 @@ #include <sax/SaxParseInterface.h> #include <sax/SaxComposeInterface.h> #include <core/xmlApi.hpp> -#include <exception/xml/CommonException.h> #include <measure/xml/MeasurementResults.hpp> namespace factory { @@ -111,8 +110,6 @@ public: if ( context == tokens.end ( ) ) throw exception::CommonException ( "Empty tokens list" ); - if ( core::xmlApi < exception::CommonException >::first ( context ) ) throw core::xmlApi < exception::CommonException >::parse ( context ); - measurements::start ( "XML Parser", measurements::Type::INIT ); T res = core::xmlApi < T >::parse ( context ); measurements::end ( ); @@ -132,7 +129,7 @@ public: static bool first ( const ext::deque < sax::Token > & tokens ) { if( tokens.empty ( ) ) throw exception::CommonException ( "Empty tokens list" ); - return core::xmlApi < exception::CommonException >::first ( tokens.begin ( ) ) || core::xmlApi < T >::first ( tokens.begin ( ) ); + return core::xmlApi < T >::first ( tokens.begin ( ) ); } /** @@ -195,32 +192,12 @@ public: }; -template < > -inline bool XmlDataFactory::first < exception::CommonException > ( const ext::deque < sax::Token > & tokens ) { - return core::xmlApi < exception::CommonException >::first ( tokens.begin ( ) ); -} - -template < > -inline XmlDataFactory::fromTokens::operator exception::CommonException ( ) { - core::xmlApiInputContext context ( tokens.begin ( ) ); - - if ( context == tokens.end ( ) ) throw exception::CommonException ( "Empty tokens list" ); - - exception::CommonException res = core::xmlApi < exception::CommonException >::parse ( context ); - - if ( context != tokens.end ( ) ) throw exception::CommonException ( "Unexpeted tokens at the end of the xml" ); - - return res; -} - template < > inline XmlDataFactory::fromTokens::operator measurements::MeasurementResults ( ) { core::xmlApiInputContext context ( tokens.begin ( ) ); if ( context == tokens.end ( ) ) throw exception::CommonException ( "Empty tokens list" ); - if ( core::xmlApi < exception::CommonException >::first ( context ) ) throw core::xmlApi < exception::CommonException >::parse ( context ); - measurements::MeasurementResults res = core::xmlApi < measurements::MeasurementResults >::parse ( context ); if ( context != tokens.end ( ) ) throw exception::CommonException ( "Unexpeted tokens at the end of the xml" ); diff --git a/aql2/src/aql.cpp b/aql2/src/aql.cpp index 9ed0bc97380f04dc79f7ff498258b41ab6f18480..e6f388c1d26c89c953a520d5a5617d85e1d0c44f 100644 --- a/aql2/src/aql.cpp +++ b/aql2/src/aql.cpp @@ -36,8 +36,6 @@ std::istream& operator>> ( std::istream & in, std::pair < T, U > & value ) { #include "prompt/Prompt.h" -#include <factory/XmlDataFactory.hpp> - namespace TCLAP { template < class T, class U > @@ -109,9 +107,6 @@ int main ( int argc, char * argv[] ) { return p.getEnvironment ( ).getResult ( ); else return 4; - } catch ( const exception::CommonException & exception ) { - factory::XmlDataFactory::toStdout ( exception ); - return 1; } catch ( const TCLAP::ArgException & exception ) { common::Streams::out << exception.error ( ) << std::endl; return 2; diff --git a/aql2/src/prompt/Prompt.h b/aql2/src/prompt/Prompt.h index 909f89bd683707b33d1e6ba55301eafa68188e07..c61aea5f70a9e67be94e50084aa7fb6599416136 100644 --- a/aql2/src/prompt/Prompt.h +++ b/aql2/src/prompt/Prompt.h @@ -13,7 +13,6 @@ #include <lexer/Lexer.h> #include <parser/Parser.h> -#include <factory/XmlDataFactory.hpp> #include <global/GlobalData.h> #include "HistoryRegister.h" @@ -46,9 +45,6 @@ public: cli::Parser parser = cli::Parser ( cli::Lexer ( std::forward < T && > ( charSequence ) ) ); HistoryRegister historyRegister ( parser.getLexer ( ), allowHistory ); return parser.parse ( )->run ( m_environment ); - } catch ( const exception::CommonException & exception ) { - factory::XmlDataFactory::toStdout ( exception ); - return cli::Command::Result::EXCEPTION; } catch ( const std::exception & exception ) { common::Streams::err << "Exception caught: " << exception.what ( ) << std::endl; return cli::Command::Result::EXCEPTION;