Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions
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...
 

Functions

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

Function Documentation

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

Trim a string in place.

Parameters
sinput string
Returns
list of tokens

Definition at line 25 of file Head.hh.

26 {
27  // from the left
28  s.erase( s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
29  return !std::isspace(ch);
30  }));
31 
32  // from the right
33  s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
34  return !std::isspace(ch);
35  }).base(), s.end());
36 }
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 46 of file Head.hh.

47 {
48  using namespace std;
49 
51 
52  stringstream ss(str);
53  string token;
54  while (getline(ss, token, delim))
55  {
56  trimstring(token);
57  if (token != "") r.push_back(token);
58  }
59 
60  return r;
61 }
data_type r[M+1]
Definition: JPolint.hh:758
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
static void trimstring(std::string &s)
Trim a string in place.
Definition: Head.hh:25
std::ostream& operator<< ( std::ostream &  out,
const Head h 
)
inline

Print header.

Parameters
outoutput stream
hheader
Returns
output stream

Definition at line 424 of file Head.hh.

425 {
426  h.print(out);
427  return out;
428 }
void print(std::ostream &out=std::cout) const
Print header.
Definition: Head.hh:295