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


Xfc::G::Completion Class Reference

A GCompletion C++ wrapper interface. More...

#include <xfc/glib/completion.hh>

Inheritance diagram for Xfc::G::Completion:

Xfc::Object Xfc::Trackable List of all members.

Public Member Functions

Accessors
Methods

Detailed Description

A GCompletion C++ wrapper interface.

Completion provides support for automatic completion of a string using any group of target strings. It is typically used for file name completion as is common in many UNIX shells.

The default constructor creates a completion object that uses strings as the completion items. The other constructor creates a completion object that uses pointers to arbitrary data structures as the completion items. Target items are added and removed with add_items(), remove_items() and clear_items(). A completion attempt is requested with complete().

Items in the completion can be simple strings (e.g. filenames), or pointers to arbitrary data structures. If data structures are used you must provide a GCompletionFunc (in the second constructor) which retrieves the item's string from the data structure. You can change the way in which strings are compared by setting a different GCompletionStrncmpFunc in set_compare().


Constructor & Destructor Documentation

Xfc::G::Completion::Completion ( GCompletionFunc  func  ) 

Constructs a new Completion object that uses data structures as the completion items.

Parameters:
func The function to be called to return the string representing an item in the completion.
The GCompletionFunc should return the string corresponding to the given target item.

Xfc::G::Completion::Completion ( GCompletionFunc  func  ) 

Constructs a new Completion object that uses data structures as the completion items.

Parameters:
func The function to be called to return the string representing an item in the completion.
The GCompletionFunc should return the string corresponding to the given target item.


Member Function Documentation

void Xfc::G::Completion::add_items ( const std::vector< String > &  items  ) 

Adds items to the completion.

Parameters:
items The vector of strings to add.

void Xfc::G::Completion::remove_items ( const std::vector< String > &  items  ) 

Removes items from the completion.

Parameters:
items The vector of strings to remove.

String Xfc::G::Completion::complete ( const String prefix,
std::vector< String > &  items 
)

Attempts to complete the string prefix using the completion target items.

Parameters:
prefix The prefix string, typically used by the user, which is compared with each of the items.
items A vector of String to store the strings that begin with prefix.
Returns:
The longest prefix common to all items that matched prefix, or null if no items matched prefix.
This method returns the largest common prefix that is a valid UTF-8 string, omitting a possible common partial character.

void Xfc::G::Completion::set_compare ( GCompletionStrncmpFunc  strncmp_func  ) 

Sets the function to use for string comparisons.

The default string comparison function is strncmp().

Parameters:
strncmp_func The string comparison function.


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