ATLAS Offline Software
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
19
20
21#ifndef READCARDS_UTILS_H
22#define READCARDS_UTILS_H
23
24#include <string>
25#include <vector>
26#include <iostream>
27
28
29// get tokens off the front (chop) and back (chomp)
30std::string chop(std::string& , const std::string& );
31std::string chomp(std::string& , const std::string& );
32
33// chop token off of end of string, leave string unchaged, return the token
34std::string choptoken(std::string& , const std::string& );
35
36// chop token off of end of string, leave string unchaged, return the token
37std::string chomptoken(std::string& , const std::string& );
38
39
40// removes whitespace
41void removespace(std::string& s, const std::string& s2=" \t");
42
43// replaces whitespace
44void replace(std::string& s, const std::string& s2=" \t", const std::string& s3="-");
45void replace(std::string& s, char c1, char c2) noexcept;
46
47// chops s1 to the first not of s2
48std::string chopfirst(std::string& s1, const std::string& s2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:/");
49
50// chops s1 from the the last not of s2
51std::string choplast(std::string& s1, const std::string& s2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
52
53// chops from both ends all of s2
54std::string chopends(std::string& s1, const std::string& s2=" \t");
55
56// functions for manipulating filenames
57std::string basename( std::string name );
58std::string dirname( std::string name );
59
60// removes colons
61void depunctuate(std::string& );
62
63// helper methods, calculate delta phi form two phi angles
64double deltaPhi(double , double );
65
66// checks to see if a particular file can be opened
67bool canopen(const std::string& );
68
69
70// converts number into integer string ...
71std::string number(const int& i, const std::string& s="%d");
72std::string number(const double& d, const std::string& s="%lf");
73
74
75
76#endif /* READCARDS_UTILS_H */
77
78
79
80
81
82
83
84
85
86
87
std::string chopfirst(std::string &s1, const std::string &s2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:/")
Definition hcg.cxx:260
std::string chopends(std::string &s1, const std::string &s2=" \t")
Definition hcg.cxx:290
std::string chomp(std::string &, const std::string &)
Definition hcg.cxx:214
std::string dirname(std::string name)
Definition utils.cxx:200
double deltaPhi(double, double)
Definition utils.cxx:169
void removespace(std::string &s, const std::string &s2=" \t")
Definition hcg.cxx:300
void replace(std::string &s, const std::string &s2=" \t", const std::string &s3="-")
Definition utils.cxx:142
bool canopen(const std::string &)
Definition utils.cxx:178
std::string chop(std::string &, const std::string &)
Definition hcg.cxx:161
std::string choptoken(std::string &, const std::string &)
Definition hcg.cxx:233
std::string basename(std::string name)
Definition utils.cxx:207
std::string chomptoken(std::string &, const std::string &)
Definition hcg.cxx:247
std::string number(const int &i, const std::string &s="%d")
Definition utils.cxx:192
void depunctuate(std::string &)
Definition utils.cxx:157
std::string choplast(std::string &s1, const std::string &s2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")
Definition hcg.cxx:276