#ifndef GLOBAL_H #define GLOBAL_H /// Indica la ausencia de valor en un puntero const int null = 0; /// Permite definir constructores de conversion implicitos #ifndef implicit #define implicit #endif /// Deletes the memory pointed by ptr and makes ptr null #ifndef free_ptr #define free_ptr(ptr) { free(ptr); ptr = null; } #endif /// Deletes the object pointed by ptr and makes ptr null #ifndef delete_ptr #define delete_ptr(ptr) { delete ptr; ptr = null; } #endif /// Deletes the array pointed by arr and makes arr null #ifndef delete_arr #define delete_arr(arr) { delete [] arr; arr = null; } #endif /// Declara el constructor de copy y el operador de asignacion para una clase cuyo nombre es /// dado por parametro. Normalmente se utilizara esta macro en la seccion private de una clase /// con el fin de evitar la copia de objetso de dicha clase #define DECLARE_COPY_METHODS(ClassName) \ ClassName(const ClassName& other); \ const ClassName& operator=(const ClassName& other); /// Prints an error message in stderr. Always returns errorcode. This is useful for saving /// blocks of lines. For example, instead of writing this error management code /// @code /// bool do_something(const char* filename) /// { /// FILE* file = fopen(filename, "r"); /// if ( ! file ) /// { /// fprintf( stderr, "error: could not open %s\n", filename ); /// return false; /// } /// // ... /// } /// @endcode /// you can get the same effect with this: /// @code /// bool do_something(const char* filename) /// { /// FILE* file = fopen(filename, "r"); /// if ( ! file ) return eprintf( false, "error: could not open %s\n", filename ); /// // ... /// } /// @endcode int eprintf(int errorcode, const char* format, ...); #endif // GLOBAL_H