LCOV - code coverage report
Current view: top level - libgnucash/backend/xml - gnc-xml-backend.hpp (source / functions) Coverage Total Hit
Test: gnucash.info Lines: 66.7 % 3 2
Test Date: 2025-02-07 16:25:45 Functions: 66.7 % 3 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /********************************************************************
       2                 :             :  * gnc-xml-backend.hpp: Declare XML file backend.                 *
       3                 :             :  * Copyright 2016 John Ralls <jralls@ceridwen.us>                   *
       4                 :             :  *                                                                  *
       5                 :             :  * This program is distributed in the hope that it will be useful,  *
       6                 :             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
       7                 :             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
       8                 :             :  * GNU General Public License for more details.                     *
       9                 :             :  *                                                                  *
      10                 :             :  * You should have received a copy of the GNU General Public License*
      11                 :             :  * along with this program; if not, contact:                        *
      12                 :             :  *                                                                  *
      13                 :             :  * Free Software Foundation           Voice:  +1-617-542-5942       *
      14                 :             :  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
      15                 :             :  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
      16                 :             : \********************************************************************/
      17                 :             : 
      18                 :             : #ifndef __GNC_XML_BACKEND_HPP__
      19                 :             : #define __GNC_XML_BACKEND_HPP__
      20                 :             : 
      21                 :             : #include <qof.h>
      22                 :             : 
      23                 :             : #include <string>
      24                 :             : #include <qof-backend.hpp>
      25                 :             : 
      26                 :             : class GncXmlBackend : public QofBackend
      27                 :             : {
      28                 :             : public:
      29                 :          30 :     GncXmlBackend() = default;
      30                 :             :     GncXmlBackend(const GncXmlBackend&) = delete;
      31                 :             :     GncXmlBackend operator=(const GncXmlBackend&) = delete;
      32                 :             :     GncXmlBackend(const GncXmlBackend&&) = delete;
      33                 :             :     GncXmlBackend operator=(const GncXmlBackend&&) = delete;
      34                 :             :     ~GncXmlBackend();
      35                 :             :     void session_begin(QofSession* session, const char* new_uri,
      36                 :             :                        SessionOpenMode mode) override;
      37                 :             :     void session_end() override;
      38                 :             :     void load(QofBook* book, QofBackendLoadType loadType) override;
      39                 :             :     /* The XML backend isn't able to do anything with individual instances. */
      40                 :             :     void export_coa(QofBook*) override;
      41                 :             :     void sync(QofBook* book) override;
      42                 :           0 :     void safe_sync(QofBook* book) override { sync(book); } // XML sync is inherently safe.
      43                 :             :     void commit(QofInstance* instance) override;
      44                 :          21 :     const char * get_filename() { return m_fullpath.c_str(); }
      45                 :             :     QofBook* get_book() { return m_book; }
      46                 :             : 
      47                 :             : private:
      48                 :             :     bool save_may_clobber_data();
      49                 :             :     void get_file_lock(SessionOpenMode);
      50                 :             :     bool link_or_make_backup(const std::string& orig, const std::string& bkup);
      51                 :             :     bool backup_file();
      52                 :             :     bool write_to_file(bool make_backup);
      53                 :             :     void remove_old_files();
      54                 :             :     void write_accounts(QofBook* book);
      55                 :             :     bool check_path(const char* fullpath, bool create);
      56                 :             : 
      57                 :             :     std::string m_dirname;
      58                 :             :     std::string m_lockfile;
      59                 :             :     std::string m_linkfile;
      60                 :             :     int m_lockfd = -1;
      61                 :             : 
      62                 :             :     QofBook* m_book = nullptr;  /* The primary, main open book */
      63                 :             : };
      64                 :             : #endif // __GNC_XML_BACKEND_HPP__
        

Generated by: LCOV version 2.0-1