DataFile Class Reference

[kfortune Index] [kfortune Hierarchy] [Headers]


A structure used by KFortune More...

#include <datafile.h>

Inherits: QObject

Public Members

Protected Members


Detailed Description

A DataFile is a structure which manages a file containing fortunes It is used by the KFortune program. The class creates a cache file in ~/.kde/share/apps/kfortune/ to speed up the program.


void setName( const char *dir=0, const char *file=0) [public]

Give the database a new file to hanlde

Parameters:
file The new fortune file
dir The directory which contains the fortune file

QString getFortune(int n) [public]

This function is used to get a fortune.

Parameters:
n Number of the fortune which has to be fetched
Returns:
Returns the requested fortune or an empty string if the requested fortune doesn't exist.

void addFortune(QString fort) [public]

This function adds a fortune the the database. Note : this function hasn't been implemented yet and will probably never be implemented.

Parameters:
fort The fortune to be added to the database

void updateCache() [public]

Rebuilds the cache-file from scratch

The format of the cache-file :

# "Comment line"
Number of fortunes in database
# "Comment line"
Streamposition of fortune number x
Streamposition of fortune number 2*x
Streamposition of fortune number 3*x
etc.

where x is a constant defined in defines.h

int getNumberCache() [protected]

Get the number of fortunes from the fortune-file, not from the cache file.

int getCache(int x) [protected]

This function is used to get data from the cache file

Parameters:
x Number of fortune * CACHENUMBER which streamposition has to be returned
Returns:
returns the streamposition of a fortune

Documentation generated by root@ziep on Tue Dec 29 15:38:56 CET 1998
Kdoc