Numworks Epsilon  1.4.1
Graphing Calculator Operating System
console_line.h
Go to the documentation of this file.
1 #ifndef CODE_CONSOLE_LINE_H
2 #define CODE_CONSOLE_LINE_H
3 
4 #include <stddef.h>
5 
6 namespace Code {
7 
8 class ConsoleLine {
9 public:
10  enum class Type {
15  };
16  ConsoleLine(Type type = Type::CurrentSessionCommand, const char * text = nullptr) :
17  m_type(type), m_text(text) {}
18  Type type() const { return m_type; }
19  const char * text() const { return m_text; }
20  bool isFromCurrentSession() const { return m_type == Type::CurrentSessionCommand || m_type == Type::CurrentSessionResult; }
21  bool isCommand() const { return m_type == Type::CurrentSessionCommand || m_type == Type::PreviousSessionCommand; }
22  bool isResult() const { return m_type == Type::CurrentSessionResult || m_type == Type::PreviousSessionResult; }
23  static inline size_t sizeOfConsoleLine(size_t textLength) {
24  return 1 + textLength + 1; // Marker, text, null termination
25  }
26 private:
27  Type m_type;
28  const char * m_text;
29 };
30 
31 }
32 
33 #endif
static size_t sizeOfConsoleLine(size_t textLength)
Definition: console_line.h:23
ConsoleLine(Type type=Type::CurrentSessionCommand, const char *text=nullptr)
Definition: console_line.h:16
bool isFromCurrentSession() const
Definition: console_line.h:20
Type type() const
Definition: console_line.h:18
Definition: app.cpp:7
const char * text() const
Definition: console_line.h:19
bool isResult() const
Definition: console_line.h:22
bool isCommand() const
Definition: console_line.h:21