Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ers::Core Class Reference

Miscalenous constants. More...

#include <Core.h>

List of all members.

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)" }


Detailed Description

Miscalenous constants.

This class contains some general constants.


Member Function Documentation

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

string to boolean

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

string to boolean

Parse a string and extract a boolean

Parameters:
s the string to parse
Returns:
1 if true

0 if false

-1 if undefined

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

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

prefix string data to 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:
ptr pointer to the character data pointer, this pointer is incremented by the parsing.
Returns:
a string containing the string data
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

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

string to responsibility

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

string to responsibility

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

string to responsibility

Parses a string and extracts a responsibility

Parameters:
s the string to parse
Returns:
a responsibility value
00075                                                                              {
00076     return parse_responsibility(s.c_str()) ; 
00077 } // parse_responsability

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

string to responsibility

Parses a string and extracts a responsibility

Parameters:
s the string to parse
Returns:
a responsibility value
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

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

string to severity_t

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

string to severity_t

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:
s the string to parse
Returns:
a severity_t value
00043                                                                 {
00044     return parse_severity(s.c_str());
00045 } // parse_severity

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:
s the string to parse
Returns:
a severity_t value
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

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

boolean to string

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

responsibility to string

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

severity_t to string

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

boolean to string

Convert a boolean to a string

Parameters:
b the boolean
Returns:
either the string "true" or "false"
00099                                               {
00100     int index = b ? 1 : 0 ;
00101     return BOOLEAN_NAMES[index] ;
00102 } // to_string

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

responsibility to string

Transforms a responsibility value into a string

Parameters:
r the responsibility
Returns:
string with text for responsibility
00052                                                              {
00053     const unsigned int index = (unsigned int) r ;
00054     assert(index<=resp_max);
00055     return RESPONSIBILITY_NAMES[index] ;
00056 } // to_string

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

severity_t to string

Parameters:
s severity
Returns:
pointer to string with associated text
00020                                                       {
00021     const unsigned int index = (unsigned int) s ;
00022     assert(index<=severity_max); 
00023     return ers::Core::SEVERITY_NAMES[index] ; 
00024 } // getSeverityText

std::vector<std::string> ers::Core::tokenize const std::string &  text,
const std::string &  separators
[static]
 

std::vector< std::string > ers::Core::tokenize const std::string &  text,
const std::string &  separators
[static]
 

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

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

unmangles gcc RTTI names

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:
name the mangled name of the object
Returns:
an unmangled name
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


Member Data Documentation

const char* const ers::Core::BOOLEAN_NAMES[] [static, private]
 

const char *const ers::Core::BOOLEAN_NAMES = { "false", "true" } [static, private]
 

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

const char* const ers::Core::RESPONSIBILITY_NAMES[] [static, private]
 

const char *const ers::Core::RESPONSIBILITY_NAMES = { "precondition", "internal", "subSystem" } [static, private]
 

const char* const ers::Core::SEVERITY_NAMES[] [static, private]
 

const char *const ers::Core::SEVERITY_NAMES = { "none", "debug_0", "debug_1", "debug_2", "debug_3", "information", "notification", "warning", "error", "fatal", "maximum (illegal)" } [static, private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:19:23 2011 for BOSS6.5.5 by  doxygen 1.3.9.1