Public Member Functions | Static Public Member Functions | Static Protected Member Functions

Barry::Restore Class Reference

Barry Backup Restore builder class. More...

#include <restore.h>

Inheritance diagram for Barry::Restore:
Inheritance graph
[legend]
Collaboration diagram for Barry::Restore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Restore (const std::string &tarpath, bool default_all_db=true)
 If default_all_db is true, and none of the Add*() functions are called (meaning that Restore has an empty database list), then all records are restored.
void AddDB (const std::string &dbName)
 Add database name to the read filter.
void Add (const DBListType &dbList)
 Add all database names in dblist to the read filter.
void Add (const DatabaseDatabase &dbdb)
 Add all database names in the DBDB to the read filter.
void AddSkipDB (const std::string &dbName)
 Add database name to the skip list.
unsigned int GetRecordTotal () const
 Loads the given file, and counts all records according to the current read filter.
DBListType GetDBList () const
 Loads the given file, and creates a DBListType list of all database names available in the tarball, using no filters.
bool GetNextMeta (DBData &data)
 If this function returns true, it fills data with the meta data that the next call to BuildRecord() will retrieve.
bool BuildRecord (Barry::DBData &data, size_t &offset, const Barry::IConverter *ic)
 Called to build the record field data.
bool FetchRecord (Barry::DBData &data, const Barry::IConverter *ic)
 Same as BuildRecord, but does not care about any offsets.
bool EndOfFile () const
 Sometimes a builder can have multiple databases stored in it, so when Build/Fetch returns false, check if there is more data with this function.

Static Public Member Functions

static unsigned int GetRecordTotal (const std::string &tarpath, const DBListType &dbList, bool default_all_db)
 Static version of above call.
static DBListType GetDBList (const std::string &tarpath)
 Static version of GetDBList().

Static Protected Member Functions

static bool SplitTarPath (const std::string &tarpath, std::string &dbname, std::string &dbid_text, uint8_t &dbrectype, uint32_t &dbid)
 Splits a tarpath of the form "DBName/DBID" into separate string values.

Detailed Description

Barry Backup Restore builder class.

This class is suitable to be used as a builder object anywhere a builder object is accepted. It reads from a Barry Backup tar.gz backup file, and builds records in a staged manner.

If a backup file contains more than one database (for example both Address Book and Calendar), then it will build one database first, return false on Retrieve(), and then build the next. If Retrieve() returns false, but EndOfFile() also returns false, then more databases are available.

The idea is that you can call Desktop::SaveDatabase() multiple times with this same Restore object, for all the databases in the backup file.

It is safe to call Retrieve() multiple times, so when first starting a restore:

Definition at line 64 of file restore.h.


Constructor & Destructor Documentation

Barry::Restore::Restore ( const std::string &  tarpath,
bool  default_all_db = true 
) [explicit]

If default_all_db is true, and none of the Add*() functions are called (meaning that Restore has an empty database list), then all records are restored.

If false in this situation, nothing is restored.

If any of the Add*() functions are called, then the database list takes precedence, and default_all_db has no effect.

Definition at line 100 of file restore.cc.


Member Function Documentation

void Barry::Restore::Add ( const DBListType dbList  ) 

Add all database names in dblist to the read filter.

Definition at line 149 of file restore.cc.

References AddDB().

Here is the call graph for this function:

void Barry::Restore::Add ( const DatabaseDatabase dbdb  ) 

Add all database names in the DBDB to the read filter.

Definition at line 159 of file restore.cc.

References AddDB().

Here is the call graph for this function:

void Barry::Restore::AddDB ( const std::string &  dbName  ) 

Add database name to the read filter.

Definition at line 141 of file restore.cc.

Referenced by Add().

Here is the caller graph for this function:

void Barry::Restore::AddSkipDB ( const std::string &  dbName  ) 

Add database name to the skip list.

The skip list prevents any matching database from appearing in the restore process. It is the converse of AddDB() in ultimate behaviour.

Definition at line 169 of file restore.cc.

bool Barry::Restore::BuildRecord ( Barry::DBData data,
size_t &  offset,
const Barry::IConverter ic 
) [virtual]

Called to build the record field data.

Store the raw data in data, using offset to know where to write. Be sure to update offset, and be sure to adjust the size of the data packet (possibly with Data::ReleaseBuffer()).

Returns true if successful, and false if at the end of the series. Note that if EndOfFile() is false after this function returns false, then there may be another series available, which the next call to BuildRecord() will determine.

Implements Barry::Builder.

Definition at line 328 of file restore.cc.

bool Barry::Restore::EndOfFile (  )  const [virtual]

Sometimes a builder can have multiple databases stored in it, so when Build/Fetch returns false, check if there is more data with this function.

This function is not used by database-oriented functions, but by pipe- oriented functions.

Implements Barry::Builder.

Definition at line 423 of file restore.cc.

bool Barry::Restore::FetchRecord ( Barry::DBData data,
const Barry::IConverter ic 
) [virtual]

Same as BuildRecord, but does not care about any offsets.

The caller should call DBData::GetOffset() afterward to discover if there is an offset to the result.

This is usually the fastest of the two functions, since extra copying may be required if a specific offset is given. When building records from Record classes, both functions are the same speed. But when building records from the device, the device decides the offset, so FetchRecord() is faster, since BuildRecord requires a copy to adjust to the right offset.

The caller should use the function that results in the least amount of copying for the caller. If the caller doesn't care about where the resulting record is in data, use FetchRecord().

Implements Barry::Builder.

Definition at line 371 of file restore.cc.

Barry::Restore::DBListType Barry::Restore::GetDBList (  )  const

Loads the given file, and creates a DBListType list of all database names available in the tarball, using no filters.

Does not use the main Restore file, but opens the file separately. It is safe to call this function as often as needed.

Definition at line 225 of file restore.cc.

Barry::Restore::DBListType Barry::Restore::GetDBList ( const std::string &  tarpath  )  [static]

Static version of GetDBList().

Definition at line 230 of file restore.cc.

bool Barry::Restore::GetNextMeta ( DBData data  ) 

If this function returns true, it fills data with the meta data that the next call to BuildRecord() will retrieve.

This is useful for applications that need to setup a manual call to Desktop::SaveDatabase().

Definition at line 247 of file restore.cc.

unsigned int Barry::Restore::GetRecordTotal (  )  const

Loads the given file, and counts all records according to the current read filter.

Does not use the main Restore file, but opens the file separately. It is safe to call this function as often as needed.

Definition at line 200 of file restore.cc.

unsigned int Barry::Restore::GetRecordTotal ( const std::string &  tarpath,
const DBListType dbList,
bool  default_all_db 
) [static]

Static version of above call.

Definition at line 205 of file restore.cc.

bool Barry::Restore::SplitTarPath ( const std::string &  tarpath,
std::string &  dbname,
std::string &  dbid_text,
uint8_t &  dbrectype,
uint32_t &  dbid 
) [static, protected]

Splits a tarpath of the form "DBName/DBID" into separate string values.

Returns true if successful, false if tarpath is a bad name.

Definition at line 73 of file restore.cc.


The documentation for this class was generated from the following files: