BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
ers::Core Class Reference

Miscalenous constants. More...

#include <Core.h>

Static Public Member Functions

static severity_t parse_severity (const char *s) throw ()
 string to severity_t
 
static severity_t parse_severity (const std::string &s) throw ()
 string to severity_t
 
static const char * to_string (severity_t s) throw ()
 severity_t to string
 
static responsibility_t parse_responsibility (const char *s) throw ()
 string to responsibility
 
static responsibility_t parse_responsibility (const std::string &s) throw ()
 string to responsibility
 
static const char * to_string (responsibility_t s) throw ()
 responsibility to string
 
static int parse_boolean (const char *s) throw ()
 string to boolean
 
static const char * to_string (bool b) throw ()
 boolean to string
 
static std::string parse_prefix_string (const char **ptr) throw ()
 prefix string data to string
 
static std::string umangle_gcc_class_name (const char *name) throw ()
 unmangles gcc RTTI names
 
static std::vector< std::string > tokenize (const std::string &text, const std::string &separators)
 

Static Public Attributes

static const std::string empty_string = ""
 

Detailed Description

Miscalenous constants.

This class contains some general constants.

Definition at line 32 of file Core.h.

Member Function Documentation

◆ parse_boolean()

int ers::Core::parse_boolean ( const char *  s)
throw (
)
static

string to boolean

Parse a string and extract a boolean

Parameters
sthe string to parse
Returns
1 if true
0 if false
-1 if undefined

Definition at line 88 of file Core.cxx.

88 {
89 if (! s) return -1 ;
90 if (! *s) return -1 ;
91 if (strcasecmp(s,BOOLEAN_NAMES[1])==0) return 1 ;
92 if (strcasecmp(s,BOOLEAN_NAMES[0])==0) return 0 ;
93 return -1 ;
94} // parse_boolean
XmlRpcServer s
Definition: HelloServer.cpp:11

Referenced by ers::Issue::transience().

◆ parse_prefix_string()

std::string ers::Core::parse_prefix_string ( const char **  ptr)
throw (
)
static

prefix string data to string

This method parses a string in the format used by gcc class names The string begins with the length of the string expressed in ascii encoded integer, followed by the character data (no 0 character at the end).

Parameters
ptrpointer to the character data pointer, this pointer is incremented by the parsing.
Returns
a string containing the string data

Definition at line 114 of file Core.cxx.

114 {
115 if (ptr==0 || *ptr==0 || **ptr=='\0') return ers::Core::empty_string ;
116 int l = 0 ;
117 while(isdigit(**ptr)) { // we parse the integer
118 l*=10 ;
119 l+=(**ptr)-'0' ;
120 (*ptr)++ ;
121 } //
122 std::string s(*ptr,l); // we create the string
123 (*ptr)+=l ;
124 return s ;
125} // parse_gcc_string
static const std::string empty_string
Definition: Core.h:38

◆ parse_responsibility() [1/2]

ers::responsibility_t ers::Core::parse_responsibility ( const char *  s)
throw (
)
static

string to responsibility

Parses a string and extracts a responsibility

Parameters
sthe string to parse
Returns
a responsibility value

Definition at line 65 of file Core.cxx.

65 {
66 for(int i=0;i<resp_max;i++) {
67 if (strcmp(s,RESPONSIBILITY_NAMES[i])==0) return (ers::responsibility_t) i ;
68 } // for
69 return resp_unknown ;
70} // parse_responsability
enum ers::_responsibility_t responsibility_t
@ resp_unknown
Definition: Core.h:25
@ resp_max
Definition: Core.h:25

Referenced by ers::Issue::responsibility().

◆ parse_responsibility() [2/2]

ers::responsibility_t ers::Core::parse_responsibility ( const std::string &  s)
throw (
)
static

string to responsibility

Parses a string and extracts a responsibility

Parameters
sthe string to parse
Returns
a responsibility value

Definition at line 77 of file Core.cxx.

77 {
78 return parse_responsibility(s.c_str()) ;
79} // parse_responsability
static responsibility_t parse_responsibility(const char *s)
string to responsibility
Definition: Core.cxx:65

◆ parse_severity() [1/2]

ers::severity_t ers::Core::parse_severity ( const char *  s)
throw (
)
static

string to severity_t

Parses a string and extracts a severity_t

Parameters
sthe string to parse
Returns
a severity_t value

Definition at line 33 of file Core.cxx.

33 {
34 for(int i=0;i<severity_max;i++) {
35 if (strcmp(s,ers::Core::SEVERITY_NAMES[i])==0) return (ers::severity_t) i ;
36 }// for
37 return severity_none ;
38} // parse_severity
@ severity_max
Definition: Core.h:24
@ severity_none
Definition: Core.h:24
enum ers::_severity_t severity_t

Referenced by ers::Issue::severity().

◆ parse_severity() [2/2]

ers::severity_t ers::Core::parse_severity ( const std::string &  s)
throw (
)
static

string to severity_t

Parses a string and extracts a severity_t

Parameters
sthe string to parse
Returns
a severity_t value

Definition at line 45 of file Core.cxx.

45 {
46 return parse_severity(s.c_str());
47} // parse_severity
static severity_t parse_severity(const char *s)
string to severity_t
Definition: Core.cxx:33

◆ to_string() [1/3]

const char * ers::Core::to_string ( bool  b)
throw (
)
static

boolean to string

Convert a boolean to a string

Parameters
bthe boolean
Returns
either the string "true" or "false"

Definition at line 101 of file Core.cxx.

101 {
102 int index = b ? 1 : 0 ;
103 return BOOLEAN_NAMES[index] ;
104} // to_string

◆ to_string() [2/3]

const char * ers::Core::to_string ( ers::responsibility_t  r)
throw (
)
static

responsibility to string

Transforms a responsibility value into a string

Parameters
rthe responsibility
Returns
string with text for responsibility

Definition at line 54 of file Core.cxx.

54 {
55 const unsigned int index = (unsigned int) r ;
56 assert(index<=resp_max);
57 return RESPONSIBILITY_NAMES[index] ;
58} // to_string

◆ to_string() [3/3]

const char * ers::Core::to_string ( ers::severity_t  s)
throw (
)
static

severity_t to string

Transforms a severity_t type into the corresponding string.

Parameters
sseverity
Returns
pointer to string with associated text

Definition at line 22 of file Core.cxx.

22 {
23 const unsigned int index = (unsigned int) s ;
24 assert(index<=severity_max);
25 return ers::Core::SEVERITY_NAMES[index] ;
26} // getSeverityText

Referenced by ers::StreamFactory::debug(), ers::StreamFactory::key_for_severity(), ers::Issue::responsibility(), ers::Issue::severity(), and ers::Issue::transience().

◆ tokenize()

std::vector< std::string > ers::Core::tokenize ( const std::string &  text,
const std::string &  separators 
)
static

Definition at line 151 of file Core.cxx.

151 {
152 std::vector<std::string> result_vector ;
153 std::string::size_type start_p, end_p ;
154 start_p = text.find_first_not_of(separators) ;
155 while(start_p != std::string::npos) {
156 end_p = text.find_first_of(separators,start_p) ;
157 if (end_p == std::string::npos) {
158 end_p = text.length();
159 }
160 const std::string sub_str = text.substr(start_p,end_p-start_p);
161 result_vector.push_back(sub_str) ;
162 start_p = text.find_first_not_of(separators,end_p) ;
163 } // while
164 return result_vector ;
165} // tokenize

Referenced by ers::FilterStream::factory(), and ers::Issue::qualifiers().

◆ umangle_gcc_class_name()

std::string ers::Core::umangle_gcc_class_name ( const char *  name)
throw (
)
static

unmangles gcc RTTI names

This method tries to unmangle GCC class names given by the RTTI system This works for GCC 3.2 and 3.4. It should not be used for anything else than human display or fallback mechanism.

Parameters
namethe mangled name of the object
Returns
an unmangled name

Definition at line 135 of file Core.cxx.

135 {
136 if (name==0 || strlen(name)==0) return ers::Core::empty_string ;
137 const char *ptr = name ;
138 std::ostringstream stream ;
139 while (*ptr=='P') { // pointers are denoted with P
140 stream << "*" ;
141 ptr++ ;
142 } // if
143 while (*ptr=='N') { // namespace are denoted by N+string
144 ptr++ ;
145 stream << parse_prefix_string(&ptr) << "::" ;
146 } //
147 stream << parse_prefix_string(&ptr);
148 return stream.str();
149} // umangle_gcc_class_name
static std::string parse_prefix_string(const char **ptr)
prefix string data to string
Definition: Core.cxx:114

Referenced by ers::Issue::get_class_name().

Member Data Documentation

◆ empty_string

const std::string ers::Core::empty_string = ""
static

Definition at line 38 of file Core.h.

Referenced by ers::Issue::get_value(), parse_prefix_string(), and umangle_gcc_class_name().


The documentation for this class was generated from the following files: