libcsdbg  1.28
C++ exception (and generic) stack trace debug library
csdbg::parser Class Reference

Stack trace parser and syntax highlighter for VT100 terminals. More...

#include <parser.hpp>

+ Inheritance diagram for csdbg::parser:
+ Collaboration diagram for csdbg::parser:

Public Member Functions

 parser ()
 Object default constructor. More...
 
 parser (const parser &)
 Object copy constructor. More...
 
virtual ~parser ()
 Object destructor. More...
 
virtual parserclone () const
 Object virtual copy constructor. More...
 
virtual parseroperator= (const parser &)
 Assignment operator. More...
 
virtual dictionaryadd_dictionary (const i8 *, const i8 *, bool)
 Add a dictionary to the parser. More...
 
virtual parseradd_dictionary (dictionary *)
 Add a dictionary to the parser. More...
 
virtual parserremove_dictionary (const i8 *)
 Remove a dictionary, indexed by name. More...
 
virtual parserremove_all_dictionaries ()
 Remove all dictionaries. More...
 
virtual dictionaryget_dictionary (const i8 *) const
 Get a dictionary, indexed by name. More...
 
virtual chain< string > * get_dictionary_names () const
 Get all the registered dictionary names. More...
 
virtual styleadd_style (const i8 *, color_t, color_t, attrset_t)
 Add a style to the parser/highlighter. More...
 
virtual parseradd_style (style *)
 Add a style to the parser/highlighter. More...
 
virtual parserremove_style (const i8 *)
 Remove a style, indexed by name. More...
 
virtual parserremove_all_styles ()
 Remove all styles. More...
 
virtual styleget_style (const i8 *) const
 Get a style, indexed by name. More...
 
virtual chain< string > * get_style_names () const
 Get all the registered style names. More...
 
virtual chain< string > * parse (const i8 *=NULL, bool=false) const
 Parse the current buffer using a custom syntax. More...
 
virtual stringhighlight (const i8 *=NULL, bool=false) const
 Highlight (escape) the current buffer using a custom syntax. More...
 
virtual bool lookup (const string &, const i8 *, bool=false) const
 Lookup an expression in one of the parser dictionaries. More...
 
virtual const i8lookup (const string &, bool=false) const
 Lookup an expression in all registered dictionaries. More...
 
- Public Member Functions inherited from csdbg::string
 string (u32=0)
 Object constructor. More...
 
 string (const i8 *,...)
 Object constructor. More...
 
 string (const string &)
 Object copy constructor. More...
 
virtual ~string ()
 Object destructor. More...
 
virtual const i8cstr () const
 Get the C-string equivalent. More...
 
virtual u32 length () const
 Get the character count. More...
 
virtual u32 bufsize () const
 Get the buffer size. More...
 
virtual i8at (u32)
 Get/set the character at an offset. More...
 
virtual stringset (const i8 *,...)
 Fill with a printf-style format C-string expanded with the values of a variable argument list. More...
 
virtual stringset (const string &)
 Copy a string. More...
 
virtual stringoperator= (const string &)
 Assignment operator. More...
 
virtual stringoperator+= (const string &)
 Compound addition-assignment operator (append) More...
 
virtual i8operator[] (u32)
 Subscript operator. More...
 
virtual u32 available () const
 Get the available buffer size, the number of characters that can be appended without reallocation. More...
 
virtual stringshred (u8=0)
 Fill the whole buffer with a constant byte. More...
 
virtual stringclear ()
 Clear contents. More...
 
virtual stringappend (const string &)
 Append a string. More...
 
virtual stringappend (const i8 *,...)
 Append a printf-style format C-string expanded with the values of a variable argument list. More...
 
virtual stringappend (i8)
 Append a character. More...
 
virtual i32 cmp (const string &, bool=false) const
 Compare to another string. More...
 
virtual bool match (const string &, bool=false) const
 Match against a POSIX extended regular expression. More...
 
virtual stringtrim (i32=0)
 Remove leading and/or trailing whitespace characters. More...
 
virtual stringinsert (u32, const string &)
 Insert a string at a specified position. More...
 
virtual stringinsert (u32, const i8 *,...)
 Insert a printf-style format C-string expanded with the values of a variable argument list, at a specified position. More...
 
virtual chain< string > * split (const string &, bool=true, bool=false) const
 Tokenize using a POSIX extended regular expression. More...
 
- Public Member Functions inherited from csdbg::object
virtual ~object ()=0
 To be implemented. More...
 
virtual const i8class_name () const
 Query the class name of an object descending from csdbg::object. More...
 

Static Public Member Functions

static parserget_default ()
 Get the default (stack trace) parser. More...
 
static styleget_fallback_style ()
 Get the shared fallback style. More...
 

Static Protected Member Functions

static void on_lib_load () __attribute((constructor))
 Library constructor. More...
 
static void on_lib_unload () __attribute((destructor))
 Library destructor. More...
 

Protected Attributes

chain< dictionary > * m_dictionaries
 Dictionary collection. More...
 
chain< style > * m_styles
 VT100 style collection. More...
 
- Protected Attributes inherited from csdbg::string
i8m_data
 String data. More...
 
u32 m_length
 Character count. More...
 
u32 m_size
 Buffer size. More...
 

Static Protected Attributes

static parserm_default = NULL
 Default parser. More...
 
static stylem_fallback = NULL
 Shared fallback style. More...
 

Friends

std::ostream & operator<< (std::ostream &, const parser &)
 Stream insertion operator for csdbg::parser objects. More...
 

Additional Inherited Members

- Protected Member Functions inherited from csdbg::string
virtual stringmemalign (u32, bool=false)
 Allocate aligned memory, mandate a minimum buffer size. More...
 
virtual stringformat (const i8 *, va_list)
 Fill with a printf-style format C-string expanded with the values of a variable argument list. More...
 

Detailed Description

Stack trace parser and syntax highlighter for VT100 terminals.

A parser object can be used to parse stack traces produced by libcsdbg or any text of arbitrary syntax. It is easy to define the parser syntax using POSIX extended regular expressions. Parsed text can then be highlighted for VT100 terminals (XTerm, RXVT, GNOME terminal e.t.c), using configurable styles for each type of token. Token types can be identified using a set of C++ language dictionaries. By subclassing class csdbg::parser, users can create parsers and higlighters for any kind of content, syntax and output media

See Also
csdbg::g_trace_syntax
5.7 Using the stack trace parser (syntax highlighter)

Definition at line 29 of file parser.hpp.


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