ROOT
v6-28
Reference Guide
Loading...
Searching...
No Matches
coutCapture.h
Go to the documentation of this file.
1
/*
2
* Project: xRooFit
3
* Author:
4
* Will Buttinger, RAL 2022
5
*
6
* Copyright (c) 2022, CERN
7
*
8
* Redistribution and use in source and binary forms,
9
* with or without modification, are permitted according to the terms
10
* listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11
*/
12
13
struct
cout_redirect
{
14
cout_redirect
(std::string &_out,
size_t
bufSize = 102 * 1024) :
out
(_out)
15
{
16
old
= std::cout.rdbuf(
buffer
.rdbuf());
17
old2
= std::cerr.rdbuf(
buffer
.rdbuf());
18
old3
= stdout;
19
buffer2
= (
char
*)
calloc
(
sizeof
(
char
), bufSize);
20
fp
= fmemopen(
buffer2
, bufSize,
"w"
);
21
stdout =
fp
;
22
}
23
~cout_redirect
()
24
{
25
std::cout.rdbuf(
old
);
26
std::cerr.rdbuf(
old2
);
27
std::fclose(
fp
);
28
stdout =
old3
;
29
out
=
buffer
.str();
30
out
+=
buffer2
;
31
free
(
buffer2
);
32
}
33
34
private
:
35
std::streambuf *
old
, *
old2
;
36
std::stringstream
buffer
;
37
char
*
buffer2
;
38
FILE *
fp
;
39
FILE *
old3
;
40
std::string &
out
;
41
};
free
#define free
Definition
civetweb.c:1539
calloc
#define calloc
Definition
civetweb.c:1537
cout_redirect
Definition
coutCapture.h:13
cout_redirect::old3
FILE * old3
Definition
coutCapture.h:39
cout_redirect::cout_redirect
cout_redirect(std::string &_out, size_t bufSize=102 *1024)
Definition
coutCapture.h:14
cout_redirect::old
std::streambuf * old
Definition
coutCapture.h:35
cout_redirect::buffer
std::stringstream buffer
Definition
coutCapture.h:36
cout_redirect::~cout_redirect
~cout_redirect()
Definition
coutCapture.h:23
cout_redirect::buffer2
char * buffer2
Definition
coutCapture.h:37
cout_redirect::fp
FILE * fp
Definition
coutCapture.h:38
cout_redirect::out
std::string & out
Definition
coutCapture.h:40
cout_redirect::old2
std::streambuf * old2
Definition
coutCapture.h:35
roofit
xroofit
src
coutCapture.h
ROOT v6-28 - Reference Guide Generated on Thu Oct 24 2024 01:49:51 (GVA Time) using Doxygen 1.9.8