changeset 24732:f079a0856321

move internal input reader classes out of header file * input.cc (class terminal_reader, class file_reader, class eval_string_reader): Move declarations and definitions here from input.h. (input_reader::input_reader): Move definitinos here from input.h.
author John W. Eaton <jwe@octave.org>
date Sat, 10 Feb 2018 23:32:04 -0500
parents a01472d4a170
children e15d53d2de1e
files libinterp/corefcn/input.cc libinterp/corefcn/input.h
diffstat 2 files changed, 83 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/input.cc	Sun Feb 11 10:57:46 2018 +0100
+++ b/libinterp/corefcn/input.cc	Sat Feb 10 23:32:04 2018 -0500
@@ -187,8 +187,7 @@
 
 namespace octave
 {
-  std::string
-  base_reader::octave_gets (bool& eof)
+  std::string base_reader::octave_gets (bool& eof)
   {
     octave_quit ();
 
@@ -271,23 +270,95 @@
     return retval;
   }
 
-  bool
-  base_reader::reading_fcn_file (void) const
+  bool base_reader::reading_fcn_file (void) const
   {
     return lexer ? lexer->reading_fcn_file : false;
   }
 
-  bool
-  base_reader::reading_classdef_file (void) const
+  bool base_reader::reading_classdef_file (void) const
   {
     return lexer ? lexer->reading_classdef_file : false;
   }
 
-  bool
-  base_reader::reading_script_file (void) const
+  bool base_reader::reading_script_file (void) const
   {
     return lexer ? lexer->reading_script_file : false;
   }
+
+  class
+  terminal_reader : public base_reader
+  {
+  public:
+
+    terminal_reader (base_lexer *lxr = nullptr)
+      : base_reader (lxr)
+    { }
+
+    std::string get_input (bool& eof);
+
+    std::string input_source (void) const { return in_src; }
+
+    bool input_from_terminal (void) const { return true; }
+
+  private:
+
+    static const std::string in_src;
+  };
+
+  class
+  file_reader : public base_reader
+  {
+  public:
+
+    file_reader (FILE *f_arg, base_lexer *lxr = nullptr)
+      : base_reader (lxr), file (f_arg) { }
+
+    std::string get_input (bool& eof);
+
+    std::string input_source (void) const { return in_src; }
+
+    bool input_from_file (void) const { return true; }
+
+  private:
+
+    FILE *file;
+
+    static const std::string in_src;
+  };
+
+  class
+  eval_string_reader : public base_reader
+  {
+  public:
+
+    eval_string_reader (const std::string& str, base_lexer *lxr = nullptr)
+      : base_reader (lxr), eval_string (str)
+    { }
+
+    std::string get_input (bool& eof);
+
+    std::string input_source (void) const { return in_src; }
+
+    bool input_from_eval_string (void) const { return true; }
+
+  private:
+
+    std::string eval_string;
+
+    static const std::string in_src;
+  };
+
+  input_reader::input_reader (base_lexer *lxr)
+    : rep (new terminal_reader (lxr))
+  { }
+
+  input_reader::input_reader (FILE *file, base_lexer *lxr)
+    : rep (new file_reader (file, lxr))
+  { }
+
+  input_reader::input_reader (const std::string& str, base_lexer *lxr)
+    : rep (new eval_string_reader (str, lxr))
+  { }
 }
 
 // Fix things up so that input can come from the standard input.  This
--- a/libinterp/corefcn/input.h	Sun Feb 11 10:57:46 2018 +0100
+++ b/libinterp/corefcn/input.h	Sat Feb 10 23:32:04 2018 -0500
@@ -136,84 +136,15 @@
   };
 
   class
-  terminal_reader : public base_reader
-  {
-  public:
-
-    terminal_reader (base_lexer *lxr = nullptr)
-      : base_reader (lxr)
-    { }
-
-    std::string get_input (bool& eof);
-
-    std::string input_source (void) const { return in_src; }
-
-    bool input_from_terminal (void) const { return true; }
-
-  private:
-
-    static const std::string in_src;
-  };
-
-  class
-  file_reader : public base_reader
+  input_reader
   {
   public:
 
-    file_reader (FILE *f_arg, base_lexer *lxr = nullptr)
-      : base_reader (lxr), file (f_arg) { }
-
-    std::string get_input (bool& eof);
-
-    std::string input_source (void) const { return in_src; }
-
-    bool input_from_file (void) const { return true; }
-
-  private:
-
-    FILE *file;
-
-    static const std::string in_src;
-  };
-
-  class
-  eval_string_reader : public base_reader
-  {
-  public:
-
-    eval_string_reader (const std::string& str,
-                               base_lexer *lxr = nullptr)
-      : base_reader (lxr), eval_string (str)
-    { }
+    input_reader (base_lexer *lxr = nullptr);
 
-    std::string get_input (bool& eof);
-
-    std::string input_source (void) const { return in_src; }
-
-    bool input_from_eval_string (void) const { return true; }
-
-  private:
-
-    std::string eval_string;
-
-    static const std::string in_src;
-  };
+    input_reader (FILE *file, base_lexer *lxr = nullptr);
 
-  class
-  input_reader
-  {
-  public:
-    input_reader (base_lexer *lxr = nullptr)
-      : rep (new terminal_reader (lxr))
-    { }
-
-    input_reader (FILE *file, base_lexer *lxr = nullptr)
-      : rep (new file_reader (file, lxr))
-    { }
-
-    input_reader (const std::string& str, base_lexer *lxr = nullptr)
-      : rep (new eval_string_reader (str, lxr))
-    { }
+    input_reader (const std::string& str, base_lexer *lxr = nullptr);
 
     input_reader (const input_reader& ir)
     {