/***************************************************************************
 * assert.h: implementation of Assert function
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2007- the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#ifndef ASSERT_H
#define ASSERT_H

#include <exception>
#include <string>

#include "contractException.h"

namespace ktabedit
{
	class ContractException;
	
	void assertion_failed(const std::string& msg, const std::string& expr, const std::string&  function, const std::string& file, long line) throw (std::exception);
	
	std::string backtrace();
}

#define ASSERT(expr) ((expr)? ((void)0): ::ktabedit::assertion_failed("ASSERT: ", #expr, __PRETTY_FUNCTION__, __FILE__, __LINE__))
#define PRECONDITION(expr) ((expr)? ((void)0): ::ktabedit::assertion_failed("PRECONDITION: ", #expr, __PRETTY_FUNCTION__, __FILE__, __LINE__))
#define POSTCONDITION(expr) ((expr)? ((void)0): ::ktabedit::assertion_failed("POSTCONDITION: ", #expr, __PRETTY_FUNCTION__, __FILE__, __LINE__))

#endif
