NNFS
Neural network library from scratch
Loading...
Searching...
No Matches
clue.hpp File Reference
#include <iomanip>
#include <sstream>
#include <cassert>
#include <iostream>
#include <ctime>
Include dependency graph for clue.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  clue
 

Macros

#define clue_MAJOR   1
 
#define clue_MINOR   0
 
#define clue_PATCH   0
 
#define clue_VERSION   clue_STRINGIFY(clue_MAJOR) "." clue_STRINGIFY(clue_MINOR) "." clue_STRINGIFY(clue_PATCH)
 
#define clue_STRINGIFY(x)   clue_STRINGIFY_(x)
 
#define clue_STRINGIFY_(x)   #x
 
#define clue_OMIT_UNUSED_LOG_EXPRESSION   0
 
#define clue_LOG_TO_CONSOLE
 
#define LOG_SEV_NONE   clue_LOG_SEV_NONE
 
#define LOG_SEV_EMERGENCY   clue_LOG_SEV_EMERGENCY
 
#define LOG_SEV_ALERT   clue_LOG_SEV_ALERT
 
#define LOG_SEV_CRITICAL   clue_LOG_SEV_CRITICAL
 
#define LOG_SEV_ERROR   clue_LOG_SEV_ERROR
 
#define LOG_SEV_WARNING   clue_LOG_SEV_WARNING
 
#define LOG_SEV_NOTICE   clue_LOG_SEV_NOTICE
 
#define LOG_SEV_INFO   clue_LOG_SEV_INFO
 
#define LOG_SEV_DEBUG   clue_LOG_SEV_DEBUG
 
#define LOG_SEV_MAX   clue_LOG_SEV_MAX
 
#define LOG_EMERGENCY   clue_LOG_EMERGENCY
 
#define LOG_ALERT   clue_LOG_ALERT
 
#define LOG_CRITICAL   clue_LOG_CRITICAL
 
#define LOG_ERROR   clue_LOG_ERROR
 
#define LOG_WARNING   clue_LOG_WARNING
 
#define LOG_NOTICE   clue_LOG_NOTICE
 
#define LOG_INFO   clue_LOG_INFO
 
#define LOG_DEBUG   clue_LOG_DEBUG
 
#define LOG_LOGGED_SEVERITIES   clue_LOG_LOGGED_SEVERITIES
 
#define LOG_EXPRESSION   clue_LOG_EXPRESSION
 
#define clue_LOG_SEV_NONE   -1
 
#define clue_LOG_SEV_EMERGENCY   0
 
#define clue_LOG_SEV_ALERT   1
 
#define clue_LOG_SEV_CRITICAL   2
 
#define clue_LOG_SEV_ERROR   3
 
#define clue_LOG_SEV_WARNING   4
 
#define clue_LOG_SEV_NOTICE   5
 
#define clue_LOG_SEV_INFO   6
 
#define clue_LOG_SEV_DEBUG   7
 
#define clue_LOG_SEV_MAX   7
 
#define clue_LOG_LEVEL   clue_LOG_SEV_DEBUG
 
#define clue_LOG_LEVEL_BUILD   clue_LOG_SEV_DEBUG
 
#define clue_LOG_SEV_NONE_TEXT   "[clue]"
 
#define clue_LOG_SEV_EMERGENCY_TEXT   "Emergency"
 
#define clue_LOG_SEV_ALERT_TEXT   "Alert"
 
#define clue_LOG_SEV_CRITICAL_TEXT   "Critical"
 
#define clue_LOG_SEV_ERROR_TEXT   "Error"
 
#define clue_LOG_SEV_WARNING_TEXT   "Warning"
 
#define clue_LOG_SEV_NOTICE_TEXT   "Notice"
 
#define clue_LOG_SEV_INFO_TEXT   "Info"
 
#define clue_LOG_SEV_DEBUG_TEXT   "Debug"
 
#define clue_LOG_MODULE_NAME   ""
 
#define clue_LOG_PREFIX_WIDTH   sizeof(clue_LOG_SEV_EMERGENCY_TEXT)
 
#define clue_is_active(severity)    clue::is_true(severity <= clue_LOG_LEVEL)
 
#define clue_is_active_build(severity)    clue::is_true(clue_IS_ACTIVE_BUILD(severity))
 
#define clue_IS_ACTIVE_BUILD(severity)    (severity <= clue_LOG_LEVEL_BUILD)
 
#define clue_LOG_LOGGED_SEVERITIES()    clue_LOG_EXPRESSION(clue_LOG_SEV_NONE, clue::to_severities_text(clue_LOG_LEVEL_BUILD))
 
#define clue_LOG_NO_EXPRESSION()
 
#define clue_IS_ACTIVE(severity)    (clue_IS_ACTIVE_BUILD(severity) || !clue_OMIT_UNUSED_LOG_EXPRESSION)
 
#define clue_LOG_EMERGENCY(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_EMERGENCY, expr)
 
#define clue_LOG_ALERT(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_ALERT, expr)
 
#define clue_LOG_CRITICAL(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_CRITICAL, expr)
 
#define clue_LOG_ERROR(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_ERROR, expr)
 
#define clue_LOG_WARNING(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_WARNING, expr)
 
#define clue_LOG_NOTICE(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_NOTICE, expr)
 
#define clue_LOG_INFO(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_INFO, expr)
 
#define clue_LOG_DEBUG(expr)   clue_LOG_EXPRESSION(clue_LOG_SEV_DEBUG, expr)
 
#define clue_LOG_EXPRESSION(severity, expr)
 

Functions

bool clue::is_true (bool const on)
 
std::string clue::text_or (std::string const &text, std::string const &or_text)
 
std::string clue::text_with_or (std::string const &prefix, std::string const &text, std::string const &postfix, std::string const &or_text)
 
std::string clue::to_module_text (std::string const &module)
 
std::string clue::to_severity_text (int const severity)
 
std::string clue::to_severities_text (int const level, std::string const &postfix=".", std::string const &result="")
 
std::string clue::now_text ()
 

Macro Definition Documentation

◆ clue_is_active

#define clue_is_active (   severity)     clue::is_true(severity <= clue_LOG_LEVEL)

◆ clue_IS_ACTIVE

#define clue_IS_ACTIVE (   severity)     (clue_IS_ACTIVE_BUILD(severity) || !clue_OMIT_UNUSED_LOG_EXPRESSION)

◆ clue_is_active_build

#define clue_is_active_build (   severity)     clue::is_true(clue_IS_ACTIVE_BUILD(severity))

◆ clue_IS_ACTIVE_BUILD

#define clue_IS_ACTIVE_BUILD (   severity)     (severity <= clue_LOG_LEVEL_BUILD)

◆ clue_LOG_ALERT

#define clue_LOG_ALERT (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_ALERT, expr)

◆ clue_LOG_CRITICAL

#define clue_LOG_CRITICAL (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_CRITICAL, expr)

◆ clue_LOG_DEBUG

#define clue_LOG_DEBUG (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_DEBUG, expr)

◆ clue_LOG_EMERGENCY

#define clue_LOG_EMERGENCY (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_EMERGENCY, expr)

◆ clue_LOG_ERROR

#define clue_LOG_ERROR (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_ERROR, expr)

◆ clue_LOG_EXPRESSION

#define clue_LOG_EXPRESSION (   severity,
  expr 
)
Value:
do \
{ \
if (clue_is_active_build(severity)) \
{ \
if (clue_is_active(severity)) \
{ \
std::clog << clue::now_text() << std::setw(clue_LOG_PREFIX_WIDTH) << clue::to_severity_text(severity) << clue::to_module_text(clue_LOG_MODULE_NAME) << ": " << expr << "\n"; \
} \
} \
} while (clue::is_true(false))
#define clue_LOG_PREFIX_WIDTH
Definition clue.hpp:208
#define clue_is_active_build(severity)
Definition clue.hpp:214
#define clue_LOG_MODULE_NAME
Definition clue.hpp:204
#define clue_is_active(severity)
Definition clue.hpp:211
bool is_true(bool const on)
Definition clue.hpp:372
std::string now_text()
Definition clue.hpp:446
std::string to_severity_text(int const severity)
Definition clue.hpp:389
std::string to_module_text(std::string const &module)
Definition clue.hpp:384

◆ clue_LOG_INFO

#define clue_LOG_INFO (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_INFO, expr)

◆ clue_LOG_LEVEL

#define clue_LOG_LEVEL   clue_LOG_SEV_DEBUG

◆ clue_LOG_LEVEL_BUILD

#define clue_LOG_LEVEL_BUILD   clue_LOG_SEV_DEBUG

◆ clue_LOG_LOGGED_SEVERITIES

#define clue_LOG_LOGGED_SEVERITIES ( )     clue_LOG_EXPRESSION(clue_LOG_SEV_NONE, clue::to_severities_text(clue_LOG_LEVEL_BUILD))

◆ clue_LOG_MODULE_NAME

#define clue_LOG_MODULE_NAME   ""

◆ clue_LOG_NO_EXPRESSION

#define clue_LOG_NO_EXPRESSION ( )
Value:
do \
{ \
} while (clue::is_true(false))

◆ clue_LOG_NOTICE

#define clue_LOG_NOTICE (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_NOTICE, expr)

◆ clue_LOG_PREFIX_WIDTH

#define clue_LOG_PREFIX_WIDTH   sizeof(clue_LOG_SEV_EMERGENCY_TEXT)

◆ clue_LOG_SEV_ALERT

#define clue_LOG_SEV_ALERT   1

◆ clue_LOG_SEV_ALERT_TEXT

#define clue_LOG_SEV_ALERT_TEXT   "Alert"

◆ clue_LOG_SEV_CRITICAL

#define clue_LOG_SEV_CRITICAL   2

◆ clue_LOG_SEV_CRITICAL_TEXT

#define clue_LOG_SEV_CRITICAL_TEXT   "Critical"

◆ clue_LOG_SEV_DEBUG

#define clue_LOG_SEV_DEBUG   7

◆ clue_LOG_SEV_DEBUG_TEXT

#define clue_LOG_SEV_DEBUG_TEXT   "Debug"

◆ clue_LOG_SEV_EMERGENCY

#define clue_LOG_SEV_EMERGENCY   0

◆ clue_LOG_SEV_EMERGENCY_TEXT

#define clue_LOG_SEV_EMERGENCY_TEXT   "Emergency"

◆ clue_LOG_SEV_ERROR

#define clue_LOG_SEV_ERROR   3

◆ clue_LOG_SEV_ERROR_TEXT

#define clue_LOG_SEV_ERROR_TEXT   "Error"

◆ clue_LOG_SEV_INFO

#define clue_LOG_SEV_INFO   6

◆ clue_LOG_SEV_INFO_TEXT

#define clue_LOG_SEV_INFO_TEXT   "Info"

◆ clue_LOG_SEV_MAX

#define clue_LOG_SEV_MAX   7

◆ clue_LOG_SEV_NONE

#define clue_LOG_SEV_NONE   -1

◆ clue_LOG_SEV_NONE_TEXT

#define clue_LOG_SEV_NONE_TEXT   "[clue]"

◆ clue_LOG_SEV_NOTICE

#define clue_LOG_SEV_NOTICE   5

◆ clue_LOG_SEV_NOTICE_TEXT

#define clue_LOG_SEV_NOTICE_TEXT   "Notice"

◆ clue_LOG_SEV_WARNING

#define clue_LOG_SEV_WARNING   4

◆ clue_LOG_SEV_WARNING_TEXT

#define clue_LOG_SEV_WARNING_TEXT   "Warning"

◆ clue_LOG_TO_CONSOLE

#define clue_LOG_TO_CONSOLE

◆ clue_LOG_WARNING

#define clue_LOG_WARNING (   expr)    clue_LOG_EXPRESSION(clue_LOG_SEV_WARNING, expr)

◆ clue_MAJOR

#define clue_MAJOR   1

◆ clue_MINOR

#define clue_MINOR   0

◆ clue_OMIT_UNUSED_LOG_EXPRESSION

#define clue_OMIT_UNUSED_LOG_EXPRESSION   0

◆ clue_PATCH

#define clue_PATCH   0

◆ clue_STRINGIFY

#define clue_STRINGIFY (   x)    clue_STRINGIFY_(x)

◆ clue_STRINGIFY_

#define clue_STRINGIFY_ (   x)    #x

◆ clue_VERSION

◆ LOG_ALERT

#define LOG_ALERT   clue_LOG_ALERT

◆ LOG_CRITICAL

#define LOG_CRITICAL   clue_LOG_CRITICAL

◆ LOG_DEBUG

#define LOG_DEBUG   clue_LOG_DEBUG

◆ LOG_EMERGENCY

#define LOG_EMERGENCY   clue_LOG_EMERGENCY

◆ LOG_ERROR

#define LOG_ERROR   clue_LOG_ERROR

◆ LOG_EXPRESSION

#define LOG_EXPRESSION   clue_LOG_EXPRESSION

◆ LOG_INFO

#define LOG_INFO   clue_LOG_INFO

◆ LOG_LOGGED_SEVERITIES

#define LOG_LOGGED_SEVERITIES   clue_LOG_LOGGED_SEVERITIES

◆ LOG_NOTICE

#define LOG_NOTICE   clue_LOG_NOTICE

◆ LOG_SEV_ALERT

#define LOG_SEV_ALERT   clue_LOG_SEV_ALERT

◆ LOG_SEV_CRITICAL

#define LOG_SEV_CRITICAL   clue_LOG_SEV_CRITICAL

◆ LOG_SEV_DEBUG

#define LOG_SEV_DEBUG   clue_LOG_SEV_DEBUG

◆ LOG_SEV_EMERGENCY

#define LOG_SEV_EMERGENCY   clue_LOG_SEV_EMERGENCY

◆ LOG_SEV_ERROR

#define LOG_SEV_ERROR   clue_LOG_SEV_ERROR

◆ LOG_SEV_INFO

#define LOG_SEV_INFO   clue_LOG_SEV_INFO

◆ LOG_SEV_MAX

#define LOG_SEV_MAX   clue_LOG_SEV_MAX

◆ LOG_SEV_NONE

#define LOG_SEV_NONE   clue_LOG_SEV_NONE

◆ LOG_SEV_NOTICE

#define LOG_SEV_NOTICE   clue_LOG_SEV_NOTICE

◆ LOG_SEV_WARNING

#define LOG_SEV_WARNING   clue_LOG_SEV_WARNING

◆ LOG_WARNING

#define LOG_WARNING   clue_LOG_WARNING