Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
Head.hh File Reference
#include "km3net-dataformat/offline/Vec.hh"
#include "km3net-dataformat/offline/Exception.hh"
#include "TObject.h"
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

Go to the source code of this file.

Classes

struct  Head
 The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred to as "tags") and values. More...
 
struct  Head::tags
 

Functions

static void trimstring (std::string &s)
 Trim a string in place.
 
std::vector< std::string > splitstring (const std::string &str, char delim=' ')
 Split string at delimiter.
 
std::ostream & operator<< (std::ostream &out, const Head &h)
 Print header.
 

Function Documentation

◆ trimstring()

static void trimstring ( std::string & s)
inlinestatic

Trim a string in place.

Parameters
sinput string

Definition at line 22 of file Head.hh.

23{
24 // from the left
25 s.erase( s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
26 return !std::isspace(ch);
27 }));
28
29 // from the right
30 s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
31 return !std::isspace(ch);
32 }).base(), s.end());
33}

◆ splitstring()

std::vector< std::string > splitstring ( const std::string & str,
char delim = ' ' )
inline

Split string at delimiter.

Trailing and leading whitespace is removed from each token. Empty tokens are not put in the output list.

Parameters
strinput string
delimtoken delimiter
Returns
list of tokens

Definition at line 43 of file Head.hh.

44{
45 using namespace std;
46
48
49 stringstream ss(str);
50 string token;
51 while (getline(ss, token, delim))
52 {
53 trimstring(token);
54 if (token != "") r.push_back(token);
55 }
56
57 return r;
58}
static void trimstring(std::string &s)
Trim a string in place.
Definition Head.hh:22
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478

◆ operator<<()

std::ostream & operator<< ( std::ostream & out,
const Head & h )
inline

Print header.

Parameters
outoutput stream
hheader
Returns
output stream

Definition at line 441 of file Head.hh.

442{
443 h.print(out);
444 return out;
445}
void print(std::ostream &out=std::cout) const
Print header.
Definition Head.hh:298