amath  1.8.5
Simple command line calculator
console.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 #ifndef AMATH_CONSOLE_BASE
31 #define AMATH_CONSOLE_BASE
32 
33 /**
34  * @file console.h
35  * @brief Generic console system calls.
36  *
37  */
38 
39 /**
40  * @brief Abstract base class encapsulating console logic.
41  *
42  */
44 {
45 public:
46  explicit ConsoleBase(const char* prompt);
47  virtual ~ConsoleBase();
48  const char* GetName();
49  virtual bool Open();
50  virtual void Close();
51  virtual void Start() = 0;
52  virtual void Exit() = 0;
53  virtual void Clear();
54  virtual void ShowHelp();
55  virtual void ShowAbout();
56  virtual void ShowLicense();
57  virtual void ShowVersion();
58  virtual void SetPrompt(const char* string);
59  virtual void WriteString(const char* string) = 0;
60  virtual bool SetAnsiMode(bool value);
61  virtual void ResetConsole();
62 
63 protected:
64  virtual void StartMessage();
65  void Prompt();
66  const char* GetVersionText();
67  const char* GetCompilerText();
68  char* prompt;
69  bool ansiMode;
70 
71 private:
72  void AnsiItalics();
73  void AnsiBold();
74 };
75 
76 #endif
char * prompt
Definition: console.h:68
virtual void Clear()
Definition: console.cpp:142
const char * GetName()
Definition: console.cpp:85
virtual void ShowAbout()
Definition: console.cpp:174
ConsoleBase(const char *prompt)
Definition: console.cpp:75
virtual void Start()=0
Abstract base class encapsulating console logic.
Definition: console.h:43
void AnsiBold()
Definition: console.cpp:124
const char * GetVersionText()
Definition: console.cpp:90
virtual bool SetAnsiMode(bool value)
Definition: console.cpp:109
virtual void Close()
Definition: console.cpp:105
virtual void ResetConsole()
Definition: console.cpp:115
void Prompt()
Definition: console.cpp:207
virtual void WriteString(const char *string)=0
virtual ~ConsoleBase()
Definition: console.cpp:80
virtual void ShowHelp()
Definition: console.cpp:158
const char * GetCompilerText()
Definition: console.cpp:95
virtual void Exit()=0
virtual void SetPrompt(const char *string)
Definition: console.cpp:214
virtual void ShowLicense()
Definition: console.cpp:186
virtual bool Open()
Definition: console.cpp:100
virtual void StartMessage()
Definition: console.cpp:201
bool ansiMode
Definition: console.h:69
void AnsiItalics()
Definition: console.cpp:133
virtual void ShowVersion()
Definition: console.cpp:163