LCOV - code coverage report
Current view: top level - atermpp/include/mcrl2/atermpp - aterm_io_text.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 2 2 100.0 %
Date: 2020-02-13 00:44:47 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Jan Friso Groote
       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             : 
      10             : #ifndef MCRL2_ATERMPP_ATERM_IO_TEXT_H
      11             : #define MCRL2_ATERMPP_ATERM_IO_TEXT_H
      12             : 
      13             : #include "mcrl2/atermpp/aterm_io.h"
      14             : 
      15             : namespace atermpp
      16             : {
      17             : 
      18             : /// \brief Writes terms in textual format to an output stream.
      19       12510 : class text_aterm_ostream final : public aterm_ostream
      20             : {
      21             : public:
      22             :   /// \param os The output stream.
      23             :   /// \param newline When true each term is written on a new line.
      24             :   text_aterm_ostream(std::ostream& os, bool newline = false);
      25             : 
      26             :   void put(const aterm &term) override;
      27             : 
      28             : private:
      29             :   /// \brief Writes a term in textual format on the same line.
      30             :   void write_term_line(const aterm& term);
      31             : 
      32             :   std::ostream& m_stream;
      33             : 
      34             :   bool m_newline = false; ///< Indicates that terms are separated by a newline.
      35             : };
      36             : 
      37             : /// \brief Reads terms in textual format from an input stream.
      38       10103 : class text_aterm_istream final : public aterm_istream
      39             : {
      40             : public:
      41             :   text_aterm_istream(std::istream& os);
      42             : 
      43             :   aterm get() override;
      44             : 
      45             : private:
      46             :   /// \brief Parse a term from the input stream and return it.
      47             :   aterm parse_aterm(int& character);
      48             : 
      49             :   /// \brief Parses an "f"(t0, ..., tn) application as an aterm_appl.
      50             :   aterm_appl parse_aterm_appl(const std::string& function_name, int& character);
      51             : 
      52             :   /// \brief Parses an std::size_t as an aterm_int.
      53             :   aterm_int parse_aterm_int(int& character);
      54             : 
      55             :   /// \brief Parses a list of arguments [...] as terms.
      56             :   aterm_list parse_aterm_list(int& character, char begin, char end);
      57             : 
      58             :   /// \brief Reads a quoted string from the stream.
      59             :   /// \returns The parsed string and the first character after this string that is not whitespace.
      60             :   std::string parse_quoted_string(int& character);
      61             : 
      62             :   /// \brief Reads an unquoted string from the stream.
      63             :   std::string parse_unquoted_string(int& character);
      64             : 
      65             :   /// \returns A string indicating the parse error position.
      66             :   std::string print_parse_error_position();
      67             : 
      68             :   /// \returns The first character that is not whitespace or end-of-file (EOF).
      69             :   /// \param skip_whitespace, returns the next non space character.
      70             :   /// \param required Throw error when the next character is EOL.
      71             :   int next_char(bool skip_whitespace = true, bool required = false);
      72             : 
      73             :   std::istream& m_stream;
      74             : 
      75             :   std::size_t m_line = 0; ///< The line number of the current character.
      76             :   std::size_t m_column = 0; ///< The column of the current character.
      77             : 
      78             :   std::size_t m_history_limit = 64; ///< Determines the maximum number of characters that are stored.
      79             :   std::deque<char> m_history; ///< Stores the characters that have been read so-far.
      80             : 
      81             :   int character; ///< The last character that was read.
      82             : };
      83             : 
      84             : } // namespace atermpp
      85             : 
      86             : #endif // ATERM_IO_TEXT_H

Generated by: LCOV version 1.13