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 parser * clone () const
 Object virtual copy constructor. More...
 
virtual parser & operator= (const parser &)
 Assignment operator. More...
 
virtual dictionary * add_dictionary (const i8 *, const i8 *, bool)
 Add a dictionary to the parser. More...
 
virtual parser & add_dictionary (dictionary *)
 Add a dictionary to the parser. More...
 
virtual parser & remove_dictionary (const i8 *)
 Remove a dictionary, indexed by name. More...
 
virtual parser & remove_all_dictionaries ()
 Remove all dictionaries. More...
 
virtual dictionary * get_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 style * add_style (const i8 *, color_t, color_t, attrset_t)
 Add a style to the parser/highlighter. More...
 
virtual parser & add_style (style *)
 Add a style to the parser/highlighter. More...
 
virtual parser & remove_style (const i8 *)
 Remove a style, indexed by name. More...
 
virtual parser & remove_all_styles ()
 Remove all styles. More...
 
virtual style * get_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 string * highlight (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 i8 * lookup (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 i8 * cstr () 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 i8 & at (u32)
 Get/set the character at an offset. More...
 
virtual string & set (const i8 *,...)
 Fill with a printf-style format C-string expanded with the values of a variable argument list. More...
 
virtual string & set (const string &)
 Copy a string. More...
 
virtual string & operator= (const string &)
 Assignment operator. More...
 
virtual string & operator+= (const string &)
 Compound addition-assignment operator (append) More...
 
virtual i8 & operator[] (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 string & shred (u8=0)
 Fill the whole buffer with a constant byte. More...
 
virtual string & clear ()
 Clear contents. More...
 
virtual string & append (const string &)
 Append a string. More...
 
virtual string & append (const i8 *,...)
 Append a printf-style format C-string expanded with the values of a variable argument list. More...
 
virtual string & append (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 string & trim (i32=0)
 Remove leading and/or trailing whitespace characters. More...
 
virtual string & insert (u32, const string &)
 Insert a string at a specified position. More...
 
virtual string & insert (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 i8 * class_name () const
 Query the class name of an object descending from csdbg::object. More...
 

Static Public Member Functions

static parser * get_default ()
 Get the default (stack trace) parser. More...
 
static style * get_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
i8 * m_data
 String data. More...
 
u32 m_length
 Character count. More...
 
u32 m_size
 Buffer size. More...
 

Static Protected Attributes

static parser * m_default = NULL
 Default parser. More...
 
static style * m_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 string & memalign (u32, bool=false)
 Allocate aligned memory, mandate a minimum buffer size. More...
 
virtual string & format (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: