FMI Table
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 2 | Project Topic 7 |
Macros | Functions
Toolbox.hpp File Reference

Stores a wide range of functions for simpler/more automated printing. More...

#include <iostream>
#include "../List/List.hpp"
#include "../String/String.h"

Go to the source code of this file.

Macros

#define MAX_LINE_WIDTH   1024
 

Functions

void inputLineBox (char *output, unsigned maxWidth, bool ignore=true)
 Prints label, gets a whole line of input and stores it to output. More...
 
void printTable (const List< String > &items, unsigned columns)
 Prints a string list as a table. More...
 
template<typename T >
void read (T *storage)
 Reads user input and stores it.
 
template<typename T >
void read (T &storage)
 Reads user input and stores it.
 
template<typename T >
void print (const T *item)
 Prints given item.
 
template<typename T >
void print (const T &item)
 Prints given item.
 
template<typename T >
void printLine (const T *item)
 Prints given item and an endline character.
 
template<typename T >
void printLine (const T &item)
 Prints given item and an endline character.
 

Detailed Description

Stores a wide range of functions for simpler/more automated printing.

Adds a lot of functions for printing.

Remarks
iostream is included by necessity (templated functions), you should only use the provided functions, if you can.

Function Documentation

◆ inputLineBox()

void inputLineBox ( char *  output,
unsigned  maxWidth,
bool  ignore 
)

Prints label, gets a whole line of input and stores it to output.

Parameters
labelC-style string, there are no size check so it could wrap
outputPointer to a char array
maxWidthMaximum count of characters to read from user input. output MUST be able to hold that many characters!
ignoreWhether or not to ignore the first new-line delimiter. true by default, should be set to false only when an inputLineBox/SubBox has been issued directly prior or when it's the very first issued box command.

Prints "(+)" before the label.

◆ printTable()

void printTable ( const List< String > &  items,
unsigned  columns 
)

Prints a string list as a table.

Parameters
startNumberThe number by which column and row enumeration begins
columnsHow many columns the table should have
itemsC-style string, each cell is a single character from the string

Prints a string as a grid/table of characters from top to bottom, left to right. The first character is on the top left, the last one is on the bottom right.

Table is printed until a terminating zero is encountered. The rows are "calculated" from the columns count and the items length.