BOSS 8.0.0
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 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 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 49 of file Event/ers/include/ers/Core.h.

Member Function Documentation

◆ parse_boolean() [1/3]

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 93 of file Core.cxx.

93 {
94 if ( !s ) return -1;
95 if ( !*s ) return -1;
96 if ( strcasecmp( s, BOOLEAN_NAMES[1] ) == 0 ) return 1;
97 if ( strcasecmp( s, BOOLEAN_NAMES[0] ) == 0 ) return 0;
98 return -1;
99} // parse_boolean
XmlRpcServer s

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

◆ parse_boolean() [2/3]

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

string to boolean

◆ parse_boolean() [3/3]

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

string to boolean

◆ parse_prefix_string() [1/3]

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 118 of file Core.cxx.

118 {
119 if ( ptr == 0 || *ptr == 0 || **ptr == '\0' ) return ers::Core::empty_string;
120 int l = 0;
121 while ( isdigit( **ptr ) )
122 { // we parse the integer
123 l *= 10;
124 l += ( **ptr ) - '0';
125 ( *ptr )++;
126 } //
127 std::string s( *ptr, l ); // we create the string
128 ( *ptr ) += l;
129 return s;
130} // parse_gcc_string
static const std::string empty_string

Referenced by umangle_gcc_class_name().

◆ parse_prefix_string() [2/3]

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

prefix string data to string

◆ parse_prefix_string() [3/3]

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

prefix string data to string

◆ parse_responsibility() [1/6]

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 69 of file Core.cxx.

69 {
70 for ( int i = 0; i < resp_max; i++ )
71 {
72 if ( strcmp( s, RESPONSIBILITY_NAMES[i] ) == 0 ) return (ers::responsibility_t)i;
73 } // for
74 return resp_unknown;
75} // parse_responsability
enum ers::_responsibility_t responsibility_t

Referenced by parse_responsibility(), and ers::Issue::responsibility().

◆ parse_responsibility() [2/6]

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

string to responsibility

◆ parse_responsibility() [3/6]

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

string to responsibility

◆ parse_responsibility() [4/6]

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 82 of file Core.cxx.

82 {
83 return parse_responsibility( s.c_str() );
84} // parse_responsability
static responsibility_t parse_responsibility(const char *s)
string to responsibility
Definition Core.cxx:69

◆ parse_responsibility() [5/6]

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

string to responsibility

◆ parse_responsibility() [6/6]

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

string to responsibility

◆ parse_severity() [1/6]

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 36 of file Core.cxx.

36 {
37 for ( int i = 0; i < severity_max; i++ )
38 {
39 if ( strcmp( s, ers::Core::SEVERITY_NAMES[i] ) == 0 ) return (ers::severity_t)i;
40 } // for
41 return severity_none;
42} // parse_severity
enum ers::_severity_t severity_t

Referenced by parse_severity(), and ers::Issue::severity().

◆ parse_severity() [2/6]

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

string to severity_t

◆ parse_severity() [3/6]

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

string to severity_t

◆ parse_severity() [4/6]

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 49 of file Core.cxx.

49 {
50 return parse_severity( s.c_str() );
51} // parse_severity
static severity_t parse_severity(const char *s)
string to severity_t
Definition Core.cxx:36

◆ parse_severity() [5/6]

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

string to severity_t

◆ parse_severity() [6/6]

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

string to severity_t

◆ to_string() [1/9]

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 106 of file Core.cxx.

106 {
107 int index = b ? 1 : 0;
108 return BOOLEAN_NAMES[index];
109} // to_string

◆ to_string() [2/9]

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

boolean to string

◆ to_string() [3/9]

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

boolean to string

◆ to_string() [4/9]

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 58 of file Core.cxx.

58 {
59 const unsigned int index = (unsigned int)r;
60 assert( index <= resp_max );
61 return RESPONSIBILITY_NAMES[index];
62} // to_string

◆ to_string() [5/9]

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

responsibility to string

◆ to_string() [6/9]

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

responsibility to string

◆ to_string() [7/9]

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 25 of file Core.cxx.

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

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

◆ to_string() [8/9]

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

severity_t to string

◆ to_string() [9/9]

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

severity_t to string

◆ tokenize() [1/3]

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

Definition at line 157 of file Core.cxx.

158 {
159 std::vector<std::string> result_vector;
160 std::string::size_type start_p, end_p;
161 start_p = text.find_first_not_of( separators );
162 while ( start_p != std::string::npos )
163 {
164 end_p = text.find_first_of( separators, start_p );
165 if ( end_p == std::string::npos ) { end_p = text.length(); }
166 const std::string sub_str = text.substr( start_p, end_p - start_p );
167 result_vector.push_back( sub_str );
168 start_p = text.find_first_not_of( separators, end_p );
169 } // while
170 return result_vector;
171} // tokenize

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

◆ tokenize() [2/3]

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

◆ tokenize() [3/3]

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

◆ umangle_gcc_class_name() [1/3]

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 139 of file Core.cxx.

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

◆ umangle_gcc_class_name() [2/3]

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

unmangles gcc RTTI names

◆ umangle_gcc_class_name() [3/3]

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

unmangles gcc RTTI names

Member Data Documentation

◆ empty_string

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

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