NCCLOUD
0.1
|
Implements various convenience functions (e.g., error reporting) More...
#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include <iostream>
#include <sstream>
Go to the source code of this file.
Defines | |
#define | show_error(call) |
Print error details with perror() and exit. | |
#define | show_file_error(call, filename, fp) |
Print error details with perror(), close specified file (if any) and exit. | |
Functions | |
void | print (std::ostream &s) |
cout for use in multi-threaded environments | |
void | print_error (std::ostream &s) |
cerr for use in multi-threaded environments | |
template<typename T > | |
void | reset_array (T **array, unsigned int size=0) |
deallocate an array and reallocate if needed | |
void | write_file (std::string dst, char *data, size_t size) |
Implements various convenience functions (e.g., error reporting)
#define show_error | ( | call | ) |
do { \ fprintf(stderr, "%c[1;31;40m", 0x1B); \ fprintf(stderr, "%s(%d) in %s:: ", __FILE__, __LINE__, __func__); \ perror(call); \ fprintf(stderr, "%c[0m", 0x1B); \ exit(-1); } while (0)
Print error details with perror() and exit.
#define show_file_error | ( | call, | |
filename, | |||
fp | |||
) |
do { \ fprintf(stderr, "%c[1;31;40m", 0x1B); \ fprintf(stderr, "%s(%d) in %s:: ", __FILE__, __LINE__, __func__); \ perror(call); \ fprintf(stderr, "\twhen working with file: %s\n", filename); \ fprintf(stderr, "%c[0m", 0x1B); \ if (fp) { fclose(fp); } \ exit(-1); } while (0)
Print error details with perror(), close specified file (if any) and exit.
void print | ( | std::ostream & | s | ) | [inline] |
cout for use in multi-threaded environments
void print_error | ( | std::ostream & | s | ) | [inline] |
cerr for use in multi-threaded environments
void reset_array | ( | T ** | array, |
unsigned int | size = 0 |
||
) |
deallocate an array and reallocate if needed
void write_file | ( | std::string | dst, |
char * | data, | ||
size_t | size | ||
) | [inline] |