Skip to content
Snippets Groups Projects
ResultFileStatement.h 1.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • #ifndef _CLI_RESULT_FILE_STATEMENT_H_
    #define _CLI_RESULT_FILE_STATEMENT_H_
    
    
    #include <ast/Statement.h>
    
    namespace cli {
    
    
    class ResultFileStatement final : public Statement {
    	std::unique_ptr < cli::Arg > m_file;
    
    	ResultFileStatement ( std::unique_ptr < cli::Arg > file ) : m_file ( std::move ( file ) ) {
    
    	}
    
    	virtual std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & environment ) const override {
    
    		std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getXmlFileWriterAbstraction ( prev->getReturnType ( ), m_file->eval ( environment ) );
    
    		if ( ! res->attachInput ( prev, 0 ) )
    			throw exception::CommonException ( "Can't connect param at 0 of result file statement with result of type " + prev->getReturnType ( ) + "." );
    		if ( ! res->eval ( ) )
    			throw exception::CommonException ( "Eval of result file statement failed." );
    
    		return res;
    	}
    
    };
    
    } /* namespace cli */
    
    
    #endif /* _CLI_RESULT_FILE_STATEMENT_H_ */