LCOV - code coverage report
Current view: top level - snapwebsites - file_content.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 6 0.0 %
Date: 2019-12-15 17:13:15 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Snap Websites Servers -- handle file content (i.e. read all / write all)
       2             : // Copyright (c) 2011-2019  Made to Order Software Corp.  All Rights Reserved
       3             : //
       4             : // This program is free software; you can redistribute it and/or modify
       5             : // it under the terms of the GNU General Public License as published by
       6             : // the Free Software Foundation; either version 2 of the License, or
       7             : // (at your option) any later version.
       8             : //
       9             : // This program is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             : // GNU General Public License for more details.
      13             : //
      14             : // You should have received a copy of the GNU General Public License
      15             : // along with this program; if not, write to the Free Software
      16             : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      17             : #pragma once
      18             : 
      19             : #include "snapwebsites/snap_exception.h"
      20             : 
      21             : // C++ lib
      22             : //
      23             : #include <memory>
      24             : #include <vector>
      25             : 
      26             : namespace snap
      27             : {
      28             : 
      29           0 : class file_content_exception : public snap_exception
      30             : {
      31             : public:
      32           0 :     explicit file_content_exception(char const *        whatmsg) : snap_exception("file_content", whatmsg) {}
      33             :     explicit file_content_exception(std::string const & whatmsg) : snap_exception("file_content", whatmsg) {}
      34             :     explicit file_content_exception(QString const &     whatmsg) : snap_exception("file_content", whatmsg) {}
      35             : };
      36             : 
      37           0 : class file_content_exception_invalid_parameter : public file_content_exception
      38             : {
      39             : public:
      40           0 :     explicit file_content_exception_invalid_parameter(char const *        whatmsg) : file_content_exception(whatmsg) {}
      41             :     explicit file_content_exception_invalid_parameter(std::string const & whatmsg) : file_content_exception(whatmsg) {}
      42             :     explicit file_content_exception_invalid_parameter(QString const &     whatmsg) : file_content_exception(whatmsg) {}
      43             : };
      44             : 
      45           0 : class file_content_exception_io_error : public file_content_exception
      46             : {
      47             : public:
      48           0 :     explicit file_content_exception_io_error(char const *        whatmsg) : file_content_exception(whatmsg) {}
      49             :     explicit file_content_exception_io_error(std::string const & whatmsg) : file_content_exception(whatmsg) {}
      50             :     explicit file_content_exception_io_error(QString const &     whatmsg) : file_content_exception(whatmsg) {}
      51             : };
      52             : 
      53             : 
      54             : 
      55             : 
      56             : 
      57             : 
      58             : 
      59             : class file_content
      60             : {
      61             : public:
      62             :     typedef std::shared_ptr<file_content>   pointer_t;
      63             : 
      64             :                                 file_content(std::string const & filename, bool create_missing_directories = false, bool temporary = false);
      65             :     virtual                     ~file_content();
      66             : 
      67             :     std::string const &         get_filename() const;
      68             :     bool                        exists() const;
      69             : 
      70             :     bool                        read_all();
      71             :     bool                        write_all(std::string const & filename = std::string());
      72             : 
      73             :     void                        set_content(std::string const & new_content);
      74             :     std::string const &         get_content() const;
      75             : 
      76             : protected:
      77             :     std::string                 f_filename = std::string();
      78             :     std::string                 f_content = std::string();
      79             :     bool                        f_temporary = false;
      80             : };
      81             : 
      82             : 
      83             : 
      84             : } // namespace snap
      85             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13