//
//  CPAssert.h
//  Meteor
//
//  Created by Cesar Parent on 17/07/2015.
//  Copyright (c) 2015 Cesar Parent. All rights reserved.
//

#ifndef Meteor_CPAssert_h
#define Meteor_CPAssert_h

#include <cstdio>
#include <cstdarg>
#include <cstdlib>

void inline
CPAssert(int expression, const char* format, ...) {
    if(!expression) {
        va_list arglist;
        va_start(arglist, format);
        vfprintf(stderr, format, arglist);
        //fprintf(stderr, "\n");
        va_end(arglist);
        exit(EXIT_FAILURE);
    }
}

#define CPNullCheck(ref) if(!ref) { throw std::runtime_error("Null Reference Exception"); }

#endif
