ATLAS Offline Software
Loading...
Searching...
No Matches
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
15public:
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
37private:
38 std::size_t m_perline;
39};
40
41#endif
std::size_t m_perline
LineFormatter(std::size_t perline)
std::string operator()(const std::vector< T > &v)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146