ATLAS Offline Software
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
JetRec
LineFormatter.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
// Class to create a string of elements, n perline
5
// where n is settable.
6
7
#ifndef JETREC_LINEFORMATTER_H
8
#define JETREC_LINEFORMATTER_H
9
10
#include <sstream>
11
#include <ios>
12
#include <vector>
13
14
class
LineFormatter
{
15
public
:
16
LineFormatter
(std::size_t perline):
m_perline
(perline){
17
}
18
template
<
typename
T>
19
std::string
operator()
(
const
std::vector<T>& v){
20
std::size_t
count
{0};
21
std::size_t linecount{0};
22
std::ostringstream oss{
""
, std::ios::ate};
23
oss << linecount <<
'|'
<<
" "
;
24
for
(
const
auto
& e : v){
25
if
(
count
==
m_perline
){
26
count
= 0;
27
linecount +=
m_perline
;
28
oss <<
'\n'
<<linecount<<
'|'
<<
" "
;
29
}
30
oss << e <<
" "
;
31
++
count
;
32
}
33
// if(count != 0){oss << '\n';}
34
return
oss.str();
35
}
36
37
private
:
38
std::size_t
m_perline
;
39
};
40
41
#endif
LineFormatter::m_perline
std::size_t m_perline
Definition
LineFormatter.h:38
LineFormatter::LineFormatter
LineFormatter(std::size_t perline)
Definition
LineFormatter.h:16
LineFormatter::operator()
std::string operator()(const std::vector< T > &v)
Definition
LineFormatter.h:19
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:146
Generated on
for ATLAS Offline Software by
1.14.0