Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / Project 2 / src / Generic / ConsoleInterface / Toolbox.hpp
diff options
context:
space:
mode:
Commitc5431e4d321dbf0152e6826841c1ef5c1291ba5b (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 15:38:50 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 15:38:50 +0300
Filesbe7dbd4b6188924bb3a1a9398169526f236b09b9 /Year 1/Object-oriented Programming/Project 2/src/Generic/ConsoleInterface/Toolbox.hpp
uni-projects-c5431e4d321dbf0152e6826841c1ef5c1291ba5b.tar
uni-projects-c5431e4d321dbf0152e6826841c1ef5c1291ba5b.tar.gz
uni-projects-c5431e4d321dbf0152e6826841c1ef5c1291ba5b.zip
Parentccedf6f5d89f375580ff6af40296aab953f9cd09 (diff)
Added files from project 2 (mirror)
diff --git a/Year 1/Object-oriented Programming/Project 2/src/Generic/ConsoleInterface/Toolbox.hpp b/Year 1/Object-oriented Programming/Project 2/src/Generic/ConsoleInterface/Toolbox.hpp
new file mode 100644
index 0000000..4b59626
--- /dev/null
+++ b/Year 1/Object-oriented Programming/Project 2/src/Generic/ConsoleInterface/Toolbox.hpp
@@ -0,0 +1,60 @@
+#ifndef HEADER_CONSOLEINTERFACE_TOOLBOX
+#define HEADER_CONSOLEINTERFACE_TOOLBOX
+
+#include <iostream>
+#include "../List/List.hpp"
+#include "../String/String.h"
+
+/*! \file Toolbox.hpp
+ * \brief Stores a wide range of functions for simpler/more automated printing.
+ *
+ * Adds a lot of functions for printing.
+ *
+ * \remark iostream is included by necessity (templated functions), you should only use the provided functions, if you can.
+ */
+
+#define MAX_LINE_WIDTH 1024
+
+//! Prints label, gets a whole line of input and stores it to output
+void inputLineBox(char* output, unsigned maxWidth, bool ignore = true);
+
+//! Prints a string list as a table
+void printTable(const List<String>& items, unsigned columns);
+
+//! Reads user input and stores it
+template <typename T>
+void read(T* storage) {
+ std::cin >> storage;
+}
+
+//! Reads user input and stores it
+template <typename T>
+void read(T& storage) {
+ std::cin >> storage;
+}
+
+//! Prints given item
+template <typename T>
+void print(const T* item) {
+ std::cout << item;
+}
+
+//! Prints given item
+template <typename T>
+void print(const T& item) {
+ std::cout << item;
+}
+
+//! Prints given item and an endline character
+template <typename T>
+void printLine(const T* item) {
+ std::cout << item << std::endl;
+}
+
+//! Prints given item and an endline character
+template <typename T>
+void printLine(const T& item) {
+ std::cout << item << std::endl;
+}
+
+#endif