rename from soi.h to soi, including macros
This commit is contained in:
parent
44aa8d060a
commit
d8a3ccc553
|
@ -10,13 +10,13 @@ You can debug any expressions using the macro dbg().
|
||||||
|
|
||||||
You can set the following environment variables to customize the behaviour.
|
You can set the following environment variables to customize the behaviour.
|
||||||
|
|
||||||
`SOI_H_COLOR`: By default, colored output is shown in case a terminal is connected.
|
`SOI_COLOR`: By default, colored output is shown in case a terminal is connected.
|
||||||
You can force colors with `SOI_H_COLOR=1` and shut them off with `SOI_H_COLOR=0`.
|
You can force colors with `SOI_COLOR=1` and shut them off with `SOI_COLOR=0`.
|
||||||
|
|
||||||
`SOI_H_EOFCHECK`: By default, it is *not* checked, whether you have read all the
|
`SOI_EOFCHECK`: By default, it is *not* checked, whether you have read all the
|
||||||
input. In case you pipe the input from a file or want to issue a proper EOF
|
input. In case you pipe the input from a file or want to issue a proper EOF
|
||||||
character (Control D under linux or Control Z under Windows), you can enable
|
character (Control D under linux or Control Z under Windows), you can enable
|
||||||
this check using `SOI_H_COLOR=1`.
|
this check using `SOI_EOFCHECK=1`.
|
||||||
|
|
||||||
## Template
|
## Template
|
||||||
Using this header is as simple as:
|
Using this header is as simple as:
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
//
|
//
|
||||||
// The global operator<< overload hs been removed
|
// The global operator<< overload hs been removed
|
||||||
|
|
||||||
#ifndef SOI_H_PRETTY_PRINT
|
#ifndef SOI_PRETTY_PRINT
|
||||||
#define SOI_H_PRETTY_PRINT
|
#define SOI_PRETTY_PRINT
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
@ -88,7 +88,7 @@ namespace pretty_print
|
||||||
struct delimiters
|
struct delimiters
|
||||||
{
|
{
|
||||||
using type = delimiters_values<TChar>;
|
using type = delimiters_values<TChar>;
|
||||||
static const type values;
|
static const type values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -441,4 +441,4 @@ namespace std
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif // SOI_H_PRETTY_PRINT
|
#endif // SOI_PRETTY_PRINT
|
|
@ -7,8 +7,8 @@
|
||||||
// initialize with dbg_init() to enable colorized output
|
// initialize with dbg_init() to enable colorized output
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SOI_H_DBG
|
#ifndef SOI_DBG
|
||||||
#define SOI_H_DBG
|
#define SOI_DBG
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -165,7 +165,7 @@ sanitized_type_name() {
|
||||||
t[11] == 'g';
|
t[11] == 'g';
|
||||||
return static_string_no_std(is_debug, is_std, t);
|
return static_string_no_std(is_debug, is_std, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// colorized output
|
// colorized output
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ bool tty_supports_colors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int has_environment_color_overwrite() {
|
int has_environment_color_overwrite() {
|
||||||
if (const char* color_enabled = std::getenv("SOI_H_COLOR")) {
|
if (const char* color_enabled = std::getenv("SOI_COLOR")) {
|
||||||
if (!std::strcmp(color_enabled, "1"))
|
if (!std::strcmp(color_enabled, "1"))
|
||||||
return 1;
|
return 1;
|
||||||
if (!std::strcmp(color_enabled, "0"))
|
if (!std::strcmp(color_enabled, "0"))
|
||||||
|
@ -261,7 +261,7 @@ auto dbg_print(const char (&msg)[N],
|
||||||
char const* file,
|
char const* file,
|
||||||
int line,
|
int line,
|
||||||
char const* function_name,
|
char const* function_name,
|
||||||
char const* expression) -> decltype(msg) {
|
char const* expression) -> decltype(msg) {
|
||||||
std::cerr << ANSI_DEBUG
|
std::cerr << ANSI_DEBUG
|
||||||
<< "[" << file << ":" << line
|
<< "[" << file << ":" << line
|
||||||
<< " (" << function_name << ")] " << ANSI_RESET
|
<< " (" << function_name << ")] " << ANSI_RESET
|
||||||
|
@ -279,7 +279,7 @@ T&& identity(T&& t) {
|
||||||
|
|
||||||
} // end namespace dbg_macro
|
} // end namespace dbg_macro
|
||||||
|
|
||||||
#ifdef SOI_H_RELEASE
|
#ifdef SOI_RELEASE
|
||||||
#define dbg(...) dbg_macro::identity(__VA_ARGS__)
|
#define dbg(...) dbg_macro::identity(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define dbg(...) \
|
#define dbg(...) \
|
||||||
|
@ -291,4 +291,4 @@ T&& identity(T&& t) {
|
||||||
#__VA_ARGS__)
|
#__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // SOI_H_DBG
|
#endif // SOI_DBG
|
|
@ -6,8 +6,8 @@
|
||||||
// pretty printing with c++
|
// pretty printing with c++
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SOI_H_PRETTY
|
#ifndef SOI_PRETTY
|
||||||
#define SOI_H_PRETTY
|
#define SOI_PRETTY
|
||||||
|
|
||||||
#include "prettyprint.hpp"
|
#include "prettyprint.hpp"
|
||||||
|
|
||||||
|
@ -73,4 +73,4 @@ pretty_print(std::basic_ostream<TChar, TCharTraits> & stream, const T& x) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SOI_H_PRETTY
|
#endif // SOI_PRETTY
|
|
@ -28,7 +28,7 @@
|
||||||
#include <valarray>
|
#include <valarray>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "soi-dbg.hpp"
|
#include "bits/soi-dbg.hpp"
|
||||||
|
|
||||||
namespace soi_h {
|
namespace soi_h {
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void noninteractive_check_eof() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool should_check_for_eof() {
|
bool should_check_for_eof() {
|
||||||
if (const char* eofcheck_enabled = std::getenv("SOI_H_EOFCHECK")) {
|
if (const char* eofcheck_enabled = std::getenv("SOI_EOFCHECK")) {
|
||||||
if (!std::strcmp(eofcheck_enabled, "1"))
|
if (!std::strcmp(eofcheck_enabled, "1"))
|
||||||
return true;
|
return true;
|
||||||
if (!std::strcmp(eofcheck_enabled, "0"))
|
if (!std::strcmp(eofcheck_enabled, "0"))
|
||||||
|
@ -96,7 +96,7 @@ soi_h_initializer soi_h_initializer_{false};
|
||||||
|
|
||||||
} // end namespace soi_h
|
} // end namespace soi_h
|
||||||
|
|
||||||
#include "soi-deprecate.hpp"
|
#include "bits/soi-deprecate.hpp"
|
||||||
|
|
||||||
#define int int64_t
|
#define int int64_t
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
Loading…
Reference in New Issue