Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPrint.hh
Go to the documentation of this file.
1#ifndef __JEEP__JPRINT__
2#define __JEEP__JPRINT__
3
4#include <string>
5#include <ostream>
6#include <sstream>
7#include <iomanip>
8#include <functional>
9
10
11/**
12 * \file
13 * I/O formatting auxiliaries.
14 * \author mdejong
15 */
16namespace JEEP {}
17namespace JPP { using namespace JEEP; }
18
19
20namespace JEEP {
21
22
23 /**
24 * Get output C-string.
25 *
26 * Note that this method is needed to guarentee livetime of underlying std::string.
27 *
28 * \param input input
29 * \return C-string
30 */
31 inline const char* getCString(const std::string& input)
32 {
33 static std::string buffer;
34
35 buffer = input;
36
37 return buffer.c_str();
38 }
39}
40
41
42/**
43 * Make string.
44 *
45 * \param A std::ostream compatible construct
46 * \return std::string
47 */
48#define MAKE_STRING(A) std::invoke( [&]() { std::ostringstream out; out << A; return out.str(); } )
49
50
51/**
52 * Make C-string.
53 *
54 * \param A std::ostream compatible construct
55 * \return C-string
56 */
57#define MAKE_CSTRING(A) JEEP::getCString(MAKE_STRING(A))
58
59#endif
General puprpose classes and methods.
const char * getCString(const std::string &input)
Get output C-string.
Definition JPrint.hh:31
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).