backup.h

Go to the documentation of this file.
00001 ///
00002 /// \file       backup.h
00003 ///             Special parser class to support creation of Barry Backup files
00004 ///
00005 
00006 /*
00007     Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRYBACKUP_BACKUP_H__
00023 #define __BARRYBACKUP_BACKUP_H__
00024 
00025 #include "dll.h"
00026 #include "parser.h"
00027 #include <string>
00028 #include <memory>
00029 
00030 // forward declarations
00031 namespace reuse {
00032         class TarFile;
00033 }
00034 
00035 namespace Barry {
00036 
00037 class BXEXPORT Backup : public Barry::Parser
00038 {
00039 public:
00040         typedef std::map<std::string, int>              StatsType;
00041 
00042 private:
00043         std::auto_ptr<reuse::TarFile> m_tar;
00044 
00045         std::string m_current_dbname;
00046         std::string m_tar_id_text;
00047         std::string m_record_data;
00048         StatsType m_stats;
00049 
00050 public:
00051         explicit Backup(const std::string &tarpath);
00052         ~Backup();
00053 
00054         void Close();
00055 
00056         void ClearStats();
00057         const StatsType& GetStats() const { return m_stats; }
00058 
00059         // Barry::Parser overrides
00060         virtual void ParseRecord(const Barry::DBData &data,
00061                         const Barry::IConverter *ic);
00062 };
00063 
00064 } // namespace Barry
00065 
00066 #endif
00067