atlas  0.6
input.h
Go to the documentation of this file.
1 /*
2  This is input.h
3 
4  Copyright (C) 2004,2005 Fokko du Cloux
5  part of the Atlas of Lie Groups and Representations
6 
7  For copyright and license information see the LICENSE file
8 */
9 
10 #ifndef INPUT_H /* guard against multiple inclusions */
11 #define INPUT_H
12 
13 #include <iosfwd>
14 #include <sstream>
15 
16 #ifndef NREADLINE
17 #include <readline/history.h>
18 #endif
19 
20 /******** type declarations ************************************************/
21 
22 namespace atlas {
23 
24 namespace input {
25 
26  class InputBuffer;
27 
28 #ifndef NREADLINE
29  class HistoryBuffer;
30 #else
31  typedef InputBuffer HistoryBuffer;
32 #endif
33 
34 }
35 
36 /******** function declarations ********************************************/
37 
38 namespace input {
39 
40  bool hasQuestionMark(InputBuffer&);
41  void initReadLine();
42 
43 }
44 
45 /******** type definitions ************************************************/
46 
47 namespace input {
48 
49 class InputBuffer:public std::istringstream {
50 
51  public:
52 
53 // constructors and destructors
54  InputBuffer():std::istringstream()
55  {}
56 
57  explicit InputBuffer(const std::string& str)
58  : std::istringstream(str)
59  {}
60 
61  virtual ~InputBuffer()
62  {}
63 
64 // manipulators
65  virtual void getline(const char* prompt = "", bool toHistory = true);
66 
67  virtual void reset();
68 
69  virtual void reset(std::streampos);
70 };
71 
72 #ifndef NREADLINE
73 
74 /* A class like |InputBuffer|, but each instance creates a local version of
75  the history during its lifetime. This is managed in such a way that it is
76  invisible to other instances, or to the static history record maintained
77  in the history library.
78 */
79 class HistoryBuffer : public InputBuffer
80 {
81  HISTORY_STATE state; // records our branch of history
82 
83  public:
84 
85 // constructors and destructors
86  HistoryBuffer();
87 
88  explicit HistoryBuffer(const std::string& str);
89 
90  virtual ~HistoryBuffer();
91 
92  virtual void getline(const char* prompt = "", bool toHistory = true);
93 
94 };
95 #endif
96 
97 }
98 
99 }
100 
101 #endif
void initReadLine()
Definition: input_noreadline.c:106
HISTORY_STATE state
Definition: input.h:81
Definition: input.h:49
std::string str(T n)
Definition: global.h:310
virtual ~InputBuffer()
Definition: input.h:61
InputBuffer(const std::string &str)
Definition: input.h:57
bool hasQuestionMark(InputBuffer &)
Definition: input_noreadline.c:91
Definition: input.h:79
Definition: Atlas.h:38
Definition: cweave.c:262
InputBuffer()
Definition: input.h:54