Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Public Types | Public Member Functions
Xfc::G::Scanner Class Reference

A general purpose lexical scanner. More...

#include <xfc/glib/scanner.hh>

Inheritance diagram for Xfc::G::Scanner:
Xfc::Object Xfc::Trackable

List of all members.

Public Types

Public Member Functions

Constructors

Detailed Description

A general purpose lexical scanner.


Constructor & Destructor Documentation

Xfc::G::Scanner::Scanner ( const GScannerConfig *  initial_settings)

Construct a new scanner.

Parameters:
initial_settingsA GScannerConfig structure specifiying the initial settings for the scanner.

If you pass null for the initial_settings, the default settings are used.

Xfc::G::Scanner::Scanner ( GScanner *  scanner) [explicit]

Construct a scanner from an existing GScanner.

Parameters:
scannerA pointer to a GScanner.

The Scanner object takes over the ownership of the GScanner and destroys it when the destructor is called.


Member Function Documentation

void Xfc::G::Scanner::error ( const char *  format,
  ... 
)

Outputs an error message, via the GScanner message handler.

Parameters:
formatThe message format. See the printf() documentation.
...The parameters to insert into the format string.
GTokenType Xfc::G::Scanner::get_next_token ( ) const

Gets the next token, removing it from the input stream.

The token data is placed in the token(), value(), line(), and position() fields.

void Xfc::G::Scanner::input_file ( int  input_fd)

Prepares to scan a file.

Parameters:
input_fdA file descriptor.
void Xfc::G::Scanner::input_text ( const char *  text,
unsigned int  length 
)

Prepares to scan a text buffer.

Parameters:
textThe text buffer to scan.
lengthThe length of the text buffer.
void Xfc::G::Scanner::input_text ( const String text)

Prepares to scan a text buffer.

Parameters:
textThe text buffer to scan.
void* Xfc::G::Scanner::lookup_symbol ( const char *  symbol)

Looks up a symbol in the current scope and returns its value.

Parameters:
symbolThe symbol to look up.
Returns:
The value of symbol in the current scope, or null if symbol is not bound in the current scope.
GTokenType Xfc::G::Scanner::peek_next_token ( ) const

Gets the next token, without removing it from the input stream.

The token data is placed in the next_token(), next_value(), next_line(), and next_position() fields.

void Xfc::G::Scanner::scope_add_symbol ( unsigned int  scope_id,
const char *  symbol,
void *  value 
)

Adds a symbol to the given scope.

Parameters:
scope_idThe scope id.
symbolThe symbol to add.
valueThe value of the symbol.
void Xfc::G::Scanner::scope_foreach_symbol ( unsigned int  scope_id,
const ScopeForeachSymbolSlot slot 
)

Calls the given slot for each of the symbol/value pairs in the given scope of the scanner.

Parameters:
scope_idThe scope id.
slotThe ScopeForeachSymbolSlot method to call.

The slot method is passed the symbol and value of each pair as a parameter.

void* Xfc::G::Scanner::scope_lookup_symbol ( unsigned int  scope_id,
const char *  symbol 
)

Looks up a symbol in a scope and returns its value.

Parameters:
scope_idThe scope id.
symbolThe symbol to look up.

If the symbol is not bound in the scope, null is returned.

void Xfc::G::Scanner::scope_remove_symbol ( unsigned int  scope_id,
const char *  symbol 
)

Removes a symbol from a scope.

Parameters:
scope_idThe scope id.
symbolThe symbol to remove.
unsigned int Xfc::G::Scanner::set_scope ( unsigned int  scope_id)

Sets the current scope.

Parameters:
scope_idThe new scope id.
Returns:
The old scope id.

Rewinds the file descriptor to the current buffer position and blows the file read ahead buffer.

This is useful for third party uses of the scanners filedescriptor, which hooks onto the current scanning position.

void Xfc::G::Scanner::warn ( const char *  format,
  ... 
)

Outputs a warning message, via the GScanner message handler.

Parameters:
formatThe message format. See the printf() documentation.
...The parameters to insert into the format string.

The documentation for this class was generated from the following file:
Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC