Jpp  18.2.1-ARCA-DF-PATCH
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...
 
struct  Head::tags
 

Functions

static void trimstring (std::string &s)
 Trim a string in place. More...
 
std::vector< std::stringsplitstring (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 23 of file Head.hh.

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

45 {
46  using namespace std;
47 
49 
50  stringstream ss(str);
51  string token;
52  while (getline(ss, token, delim))
53  {
54  trimstring(token);
55  if (token != "") r.push_back(token);
56  }
57 
58  return r;
59 }
data_type r[M+1]
Definition: JPolint.hh:868
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:23
std::ostream& operator<< ( std::ostream &  out,
const Head h 
)
inline

Print header.

Parameters
outoutput stream
hheader
Returns
output stream

Definition at line 442 of file Head.hh.

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