LCOV - code coverage report
Current view: top level - src/ar/internal/files - string_file.cpp (source / functions) Hit Total Coverage
Test: ar-cpp code coverage Lines: 14 14 100.0 %
Date: 2017-12-27 13:15:38 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : ///
       2             : /// @file      ar/internal/files/string_file.cpp
       3             : /// @copyright (c) 2015 by Petr Zemek (s3rvac@gmail.com) and contributors
       4             : /// @license   MIT, see the @c LICENSE file for more details
       5             : /// @brief     Implementation of the file storing its content in a string.
       6             : ///
       7             : 
       8             : #include <utility>
       9             : 
      10             : #include "ar/internal/files/string_file.h"
      11             : #include "ar/internal/utilities/os.h"
      12             : 
      13             : namespace ar {
      14             : namespace internal {
      15             : 
      16             : ///
      17             : /// Constructs a file with the given content.
      18             : ///
      19           2 : StringFile::StringFile(const std::string& content):
      20           2 :     content{content} {}
      21             : 
      22             : ///
      23             : /// Constructs a file with the given content and name.
      24             : ///
      25          18 : StringFile::StringFile(const std::string& content, const std::string& name):
      26          18 :     content{content}, name{name} {}
      27             : 
      28             : StringFile::~StringFile() = default;
      29             : 
      30          11 : std::string StringFile::getName() const {
      31          11 :     return name;
      32             : }
      33             : 
      34          10 : std::string StringFile::getContent() {
      35          10 :     return content;
      36             : }
      37             : 
      38           1 : void StringFile::saveCopyTo(const std::string& directoryPath) {
      39           1 :     saveCopyTo(directoryPath, name);
      40           1 : }
      41             : 
      42           1 : void StringFile::saveCopyTo(const std::string& directoryPath,
      43             :         const std::string& name) {
      44           1 :     writeFile(joinPaths(directoryPath, name), getContent());
      45           1 : }
      46             : 
      47             : } // namespace internal
      48             : } // namespace ar

Generated by: LCOV version 1.13