g4tools  5.4.0
schar
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_schar
5 #define tools_schar
6 
7 #include <string>
8 
9 namespace tools {
10 
11 inline bool belong(const std::string& a_string,char a_c){
12  std::string::const_iterator it;
13  for(it=a_string.begin();it!=a_string.end();++it) {
14  if((*it)==a_c) return true;
15  }
16  return false;
17 }
18 
19 inline size_t numchar(const std::string& a_string,char a_c){
20  size_t num = 0;
21  std::string::const_iterator it;
22  for(it=a_string.begin();it!=a_string.end();++it) {
23  if((*it)==a_c) num++;
24  }
25  return num;
26 }
27 
28 inline bool is_spaces(const std::string& a_string){
29  std::string::const_iterator it;
30  for(it=a_string.begin();it!=a_string.end();++it) {
31  if((*it)!=' ') return false;
32  }
33  return true;
34 }
35 
36 //inline std::string::size_type find_not(const std::string& a_s,char a_c) {
37 // std::string::size_type _size = a_s.size();
38 // const char* p = a_s.c_str();
39 // for(std::string::size_type pos=0;pos<_size;pos++,p++) {
40 // if((*p)!=a_c) return pos;
41 // }
42 // return std::string::npos;
43 //}
44 
45 }
46 
47 #endif
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::is_spaces
bool is_spaces(const std::string &a_string)
Definition: schar:28
tools::belong
bool belong(const std::string &a_string, char a_c)
Definition: schar:11
tools::numchar
size_t numchar(const std::string &a_string, char a_c)
Definition: schar:19