From bef3eb316288fce39d48e5e6eb1f956d8b8ddcf3 Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Thu, 23 Dec 2010 17:54:40 -0500 Subject: [PATCH] lib: added convenience Add function to Restore that takes a DBList Also fixed bug in Restorre::AddDB(), so that it is not possible to add the same dbname twice. --- src/restore.cc | 18 +++++++++++++++++- src/restore.h | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/restore.cc b/src/restore.cc index c4f64652..242e1888 100644 --- a/src/restore.cc +++ b/src/restore.cc @@ -26,6 +26,9 @@ #include #include #include +#include + +using namespace std; namespace Barry { @@ -130,7 +133,20 @@ bool Restore::IsSelected(const std::string &dbName) const void Restore::AddDB(const std::string &dbName) { - m_dbList.push_back(dbName); + if( find(m_dbList.begin(), m_dbList.end(), dbName) == m_dbList.end() ) { + // only add it if it is not already in the list + m_dbList.push_back(dbName); + } +} + +void Restore::Add(const DBListType &dbList) +{ + for( DBListType::const_iterator i = dbList.begin(); + i != dbList.end(); + ++i ) + { + AddDB(*i); + } } void Restore::SkipCurrentDB() diff --git a/src/restore.h b/src/restore.h index b5dda80d..58b568ae 100644 --- a/src/restore.h +++ b/src/restore.h @@ -106,6 +106,10 @@ public: /// Add database name to the read filter. void AddDB(const std::string &dbName); + /// Add all database names in dblist to the read filter + /// This function is additive. + void Add(const DBListType &dbList); + // Skip the current DB, in case of error, or preference void SkipCurrentDB(); -- 2.11.4.GIT