yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
Formatting.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of YODA -- Yet more Objects for Data Analysis
4// Copyright (C) 2008-2024 The YODA collaboration (see AUTHORS for details)
5//
6#ifndef YODA_FORMATTING_H
7#define YODA_FORMATTING_H
8
9#include <iostream>
10#include <iomanip>
11#include <unistd.h>
12
13#define MSG_(msg) do { std::cout << msg; } while (0)
14
15#define MSG(msg) MSG_(msg << std::endl)
16
17#define PAD(n) std::setw(n) << std::left
18
19#define COLOR_(msg, code) \
20 (isatty(1) ? code : "") << msg << (isatty(1) ? "\033[0m" : "")
21
22
23#define RED(msg) COLOR_(msg, "\033[0;31m")
24#define MSG_RED_(x) MSG_(RED(x))
25#define MSG_RED(x) MSG(RED(x))
26
27#define GREEN(msg) COLOR_(msg, "\033[0;32m")
28#define MSG_GREEN_(x) MSG_(GREEN(x))
29#define MSG_GREEN(x) MSG(GREEN(x))
30
31#define YELLOW(msg) COLOR_(msg, "\033[0;33m")
32#define MSG_YELLOW_(x) MSG_(YELLOW(x))
33#define MSG_YELLOW(x) MSG(YELLOW(x))
34
35#define BLUE(msg) COLOR_(msg, "\033[0;34m")
36#define MSG_BLUE_(x) MSG_(BLUE(x))
37#define MSG_BLUE(x) MSG(BLUE(x))
38
39
40#endif