-
Notifications
You must be signed in to change notification settings - Fork 1
/
stream.hpp
25 lines (20 loc) · 983 Bytes
/
stream.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once
#include <iostream>
#include <iomanip>
#include <string>
namespace astrant {
inline std::string cut_left_if_too_large(std::string s, size_t size){
if(s.size() > size){
return s.substr(s.size() - size);
} else {
return s;
}
}
}
#define ASTRANT_STRING_CURRENT_PLACE_INFORMATION (astrant::cut_left_if_too_large(__FILE__, 20) + ":" + std::to_string(__LINE__) + "(" + __FUNCTION__ + ")")
#define ASTRANT_STREAM_CURRENT_PLACE_INFORMATION (astrant::cut_left_if_too_large(__FILE__, 20) + ":") << std::setw(4) << std::to_string(__LINE__) << "(" << std::setw(15) << __FUNCTION__ << ")"
#define ACOUT std::cout << ASTRANT_STREAM_CURRENT_PLACE_INFORMATION << "\n"
#define ASDOUT std::cout << ASTRANT_STREAM_CURRENT_PLACE_INFORMATION << ": "
#define ACERR std::cerr << ASTRANT_STREAM_CURRENT_PLACE_INFORMATION << "\n"
#define ASDERR std::cerr << ASTRANT_STREAM_CURRENT_PLACE_INFORMATION << ": "
#define AVAROUT(expr) ASDOUT << #expr << ": " << expr << "\n"