#include <Core.h>
Static Public Member Functions | |
int | parse_boolean (const char *s) throw () |
string to boolean | |
int | parse_boolean (const char *s) throw () |
string to boolean | |
std::string | parse_prefix_string (const char **ptr) throw () |
prefix string data to string | |
std::string | parse_prefix_string (const char **ptr) throw () |
prefix string data to string | |
responsibility_t | parse_responsibility (const std::string &s) throw () |
string to responsibility | |
responsibility_t | parse_responsibility (const char *s) throw () |
string to responsibility | |
responsibility_t | parse_responsibility (const std::string &s) throw () |
string to responsibility | |
responsibility_t | parse_responsibility (const char *s) throw () |
string to responsibility | |
severity_t | parse_severity (const std::string &s) throw () |
string to severity_t | |
severity_t | parse_severity (const char *s) throw () |
string to severity_t | |
severity_t | parse_severity (const std::string &s) throw () |
string to severity_t | |
severity_t | parse_severity (const char *s) throw () |
string to severity_t | |
const char * | to_string (bool b) throw () |
boolean to string | |
const char * | to_string (responsibility_t s) throw () |
responsibility to string | |
const char * | to_string (severity_t s) throw () |
severity_t to string | |
const char * | to_string (bool b) throw () |
boolean to string | |
const char * | to_string (responsibility_t s) throw () |
responsibility to string | |
const char * | to_string (severity_t s) throw () |
severity_t to string | |
std::vector< std::string > | tokenize (const std::string &text, const std::string &separators) |
std::vector< std::string > | tokenize (const std::string &text, const std::string &separators) |
std::string | umangle_gcc_class_name (const char *name) throw () |
unmangles gcc RTTI names | |
std::string | umangle_gcc_class_name (const char *name) throw () |
unmangles gcc RTTI names | |
Static Public Attributes | |
const std::string | empty_string = "" |
Static Private Attributes | |
const char *const | BOOLEAN_NAMES [] |
const char *const | BOOLEAN_NAMES [] = { "false", "true" } |
const char *const | RESPONSIBILITY_NAMES [] |
const char *const | RESPONSIBILITY_NAMES [] = { "precondition", "internal", "subSystem" } |
const char *const | SEVERITY_NAMES [] |
const char *const | SEVERITY_NAMES [] = { "none", "debug_0", "debug_1", "debug_2", "debug_3", "information", "notification", "warning", "error", "fatal", "maximum (illegal)" } |
This class contains some general constants.
|
string to boolean
|
|
string to boolean Parse a string and extract a boolean
00086 { 00087 if (! s) return -1 ; 00088 if (! *s) return -1 ; 00089 if (strcasecmp(s,BOOLEAN_NAMES[1])==0) return 1 ; 00090 if (strcasecmp(s,BOOLEAN_NAMES[0])==0) return 0 ; 00091 return -1 ; 00092 } // parse_boolean
|
|
prefix string data to string
|
|
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).
00112 { 00113 if (ptr==0 || *ptr==0 || **ptr=='\0') return ers::Core::empty_string ; 00114 int l = 0 ; 00115 while(isdigit(**ptr)) { // we parse the integer 00116 l*=10 ; 00117 l+=(**ptr)-'0' ; 00118 (*ptr)++ ; 00119 } // 00120 std::string s(*ptr,l); // we create the string 00121 (*ptr)+=l ; 00122 return s ; 00123 } // parse_gcc_string
|
|
string to responsibility
|
|
string to responsibility
|
|
string to responsibility Parses a string and extracts a responsibility
00075 { 00076 return parse_responsibility(s.c_str()) ; 00077 } // parse_responsability
|
|
string to responsibility Parses a string and extracts a responsibility
00063 { 00064 for(int i=0;i<resp_max;i++) { 00065 if (strcmp(s,RESPONSIBILITY_NAMES[i])==0) return (ers::responsibility_t) i ; 00066 } // for 00067 return resp_unknown ; 00068 } // parse_responsability
|
|
string to severity_t
|
|
string to severity_t
|
|
string to severity_t Parses a string and extracts a severity_t
00043 { 00044 return parse_severity(s.c_str()); 00045 } // parse_severity
|
|
string to severity_t Parses a string and extracts a severity_t
00031 { 00032 for(int i=0;i<severity_max;i++) { 00033 if (strcmp(s,ers::Core::SEVERITY_NAMES[i])==0) return (ers::severity_t) i ; 00034 }// for 00035 return severity_none ; 00036 } // parse_severity
|
|
boolean to string
|
|
responsibility to string
|
|
severity_t to string
|
|
boolean to string Convert a boolean to a string
00099 { 00100 int index = b ? 1 : 0 ; 00101 return BOOLEAN_NAMES[index] ; 00102 } // to_string
|
|
responsibility to string Transforms a responsibility value into a string
00052 { 00053 const unsigned int index = (unsigned int) r ; 00054 assert(index<=resp_max); 00055 return RESPONSIBILITY_NAMES[index] ; 00056 } // to_string
|
|
severity_t to string
00020 { 00021 const unsigned int index = (unsigned int) s ; 00022 assert(index<=severity_max); 00023 return ers::Core::SEVERITY_NAMES[index] ; 00024 } // getSeverityText
|
|
|
|
00149 { 00150 std::vector<std::string> result_vector ; 00151 std::string::size_type start_p, end_p ; 00152 start_p = text.find_first_not_of(separators) ; 00153 while(start_p != std::string::npos) { 00154 end_p = text.find_first_of(separators,start_p) ; 00155 if (end_p == std::string::npos) { 00156 end_p = text.length(); 00157 } 00158 const std::string sub_str = text.substr(start_p,end_p-start_p); 00159 result_vector.push_back(sub_str) ; 00160 start_p = text.find_first_not_of(separators,end_p) ; 00161 } // while 00162 return result_vector ; 00163 } // tokenize
|
|
unmangles gcc RTTI names
|
|
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.
00133 { 00134 if (name==0 || strlen(name)==0) return ers::Core::empty_string ; 00135 const char *ptr = name ; 00136 std::ostringstream stream ; 00137 while (*ptr=='P') { // pointers are denoted with P 00138 stream << "*" ; 00139 ptr++ ; 00140 } // if 00141 while (*ptr=='N') { // namespace are denoted by N+string 00142 ptr++ ; 00143 stream << parse_prefix_string(&ptr) << "::" ; 00144 } // 00145 stream << parse_prefix_string(&ptr); 00146 return stream.str(); 00147 } // umangle_gcc_class_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|