|
Wexus2 0.20
|
#include <ActiveFile.h>

Classes | |
| struct | DataSpec |
| struct | DirSpec |
| struct | IteratorSpec |
Public Member Functions | |
| ActiveFile (const QString &dirname, const QRegExp ®exp) | |
| just the filename, no directory | |
| virtual QVariant | getIDAsVariant (void) |
| implementation | |
| void | checkFileName (const QString &filename) |
| void | checkFileName (void) |
| void | find (const QVariant &keyVal) |
| bool | exists (const QVariant &keyVal) |
| QByteArray & | asByteArray (void) |
| void | all (bool reverseOrder=false) |
| bool | next (void) |
Public Attributes | |
| QString | id |
Protected Member Functions | |
| virtual bool | onLoad (const QString &fullfilename) |
Protected Attributes | |
| std::shared_ptr< DirSpec > | dm_dirspec |
| std::shared_ptr< DataSpec > | dm_data |
| std::shared_ptr< IteratorSpec > | dm_iterator |
A database-record like representation of a file. Instead of a table, it uses a directory (plus a filtering regexp). Instead of record, it uses an individual file.
This concept is still being fleshed out. Future ideas include:
a) filename->field like decomposition based on regexp (with custom user-made field lists)
b) a query system for a)
c) more file load types, like images and xml.
d) rename this to ActiveFile?
| wexus::ActiveFile::ActiveFile | ( | const QString & | dirname, |
| const QRegExp & | regexp | ||
| ) |
just the filename, no directory
Constructor
| void wexus::ActiveFile::all | ( | bool | reverseOrder = false | ) |
Returns all the records.
| QByteArray& wexus::ActiveFile::asByteArray | ( | void | ) |
Demand load the curren file. Throws on errors.
| void wexus::ActiveFile::checkFileName | ( | void | ) | [inline] |
Runs checkFileName on id
| void wexus::ActiveFile::checkFileName | ( | const QString & | filename | ) |
Security routine. throws if the filename:
| bool wexus::ActiveFile::exists | ( | const QVariant & | keyVal | ) |
| void wexus::ActiveFile::find | ( | const QVariant & | keyVal | ) |
Finds the record that that has the given value as its primary key. Throws an exception on not-found.
| bool wexus::ActiveFile::next | ( | void | ) |
Returns the next record in file list, or false if done.
| virtual bool wexus::ActiveFile::onLoad | ( | const QString & | fullfilename | ) | [protected, virtual] |
This is called after loading a record. id (the filename) is already set up entering this function. You can also examine the full filename parameter.
Decendants should be able to work with empty-string ids and can throw exceptions on errors.
TODO in the future, this might be implemented in a more automatic/regex manner using .eh-like files.
The default implementation does nothing but return true;
Reimplemented in blogapp::Post.