LCOV - code coverage report
Current view: top level - lps/include/mcrl2/lps/detail - lps_io.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 0 20 0.0 %
Date: 2024-04-26 03:18:02 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Wieger Wesselink
       2             : // Copyright: see the accompanying file COPYING or copy at
       3             : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0.
       6             : // (See accompanying file LICENSE_1_0.txt or copy at
       7             : // http://www.boost.org/LICENSE_1_0.txt)
       8             : //
       9             : /// \file mcrl2/lps/detail/lps_io.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_LPS_DETAIL_LPS_IO_H
      13             : #define MCRL2_LPS_DETAIL_LPS_IO_H
      14             : 
      15             : #include "mcrl2/atermpp/aterm_io_binary.h"
      16             : #include "mcrl2/lps/io.h"
      17             : 
      18             : #include <fstream>
      19             : 
      20             : namespace mcrl2 {
      21             : 
      22             : namespace lps {
      23             : 
      24             : namespace detail {
      25             : 
      26             : /// \brief Loads an lps from filename, or from stdin if filename equals "".
      27             : inline
      28           0 : lps::specification load_lps(const std::string& filename)
      29             : {
      30           0 :   lps::specification result;
      31           0 :   if (filename.empty())
      32             :   {
      33           0 :     atermpp::binary_aterm_istream(std::cin) >> result;
      34             :   }
      35             :   else
      36             :   {
      37           0 :     std::ifstream from(filename, std::ifstream::in | std::ifstream::binary);
      38           0 :     if (!from.good())
      39             :     {
      40           0 :       throw mcrl2::runtime_error("Could not read from filename " + filename);
      41             :     }
      42           0 :     atermpp::binary_aterm_istream(from) >> result;
      43           0 :   }
      44           0 :   return result;
      45           0 : }
      46             : 
      47             : /// \brief Saves an LPS to filename, or to stdout if filename equals "".
      48             : inline
      49           0 : void save_lps(const lps::specification& lpsspec, const std::string& filename)
      50             : {
      51           0 :   if (filename.empty())
      52             :   {
      53           0 :     atermpp::binary_aterm_ostream(std::cout) << lpsspec;
      54             :   }
      55             :   else
      56             :   {
      57           0 :     std::ofstream to(filename, std::ofstream::out | std::ofstream::binary);
      58           0 :     if (!to.good())
      59             :     {
      60           0 :       throw mcrl2::runtime_error("Could not write to filename " + filename);
      61             :     }
      62           0 :     atermpp::binary_aterm_ostream(to) << lpsspec;
      63           0 :   }
      64           0 : }
      65             : 
      66             : } // namespace detail
      67             : 
      68             : } // namespace lps
      69             : 
      70             : } // namespace mcrl2
      71             : 
      72             : #endif // MCRL2_LPS_DETAIL_LPS_IO_H

Generated by: LCOV version 1.14