rp-scrabble
Simple, terminal-based Scrabble game
Macros | Functions | Variables
utils.h File Reference
#include <iostream>
#include <algorithm>
#include <vector>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEBUG_PRINT(x, y)   std::cout << x << ":" << y << std::endl
 
#define NUM_ROWS   15
 
#define NUM_COLS   15
 

Functions

void BOLD (std::string x)
 
void BOLD_BRIGHT_GREEN_FG (std::string x)
 
void BOLD_CYAN_FG (std::string x)
 
void BOLD_BLUE_FG (std::string x)
 
void BOLD_PINK_FG (std::string x)
 
void BOLD_ORANGE_FG (std::string x)
 
void BOLD_BROWN_FG (std::string x)
 
void BOLD_WHITE_FG (std::string x)
 
void BOLD_RED_FG (std::string x)
 
void PALE_GREEN_FG (std::string x)
 
void BOLD_LIGHT_GRAY_FG (std::string x)
 
void BOLD_BLACK_FG (std::string x)
 
void BROWN_BG (std::string x)
 
void RED_BG (std::string x)
 
void PINK_BG (std::string x)
 
void DARK_BLUE_BG (std::string x)
 
void LIGHT_BLUE_BG (std::string x)
 
void OFF_WHITE_BG (std::string x)
 
void TILE_COLOURS (std::string x)
 
void BOARD_COLOURS (std::string x)
 
bool squarePresent (std::vector< Square * > s, Square *target)
 
bool tilePresent (std::vector< Tile * > t, Tile *target)
 
bool charPresent (std::string str, char target)
 
std::vector< std::string > parsePlay (std::string in)
 
void log (std::string logFilePath, std::string str)
 
std::string RawTimeToString (const time_t &t)
 

Variables

const std::string alphabets = "abcdefghijklmnopqrstuvwxyz"
 

Macro Definition Documentation

◆ DEBUG_PRINT

#define DEBUG_PRINT (   x,
 
)    std::cout << x << ":" << y << std::endl

Helper to print variables for debugging

Definition at line 15 of file utils.h.

◆ NUM_COLS

#define NUM_COLS   15

Number of columns in the Board

Definition at line 19 of file utils.h.

◆ NUM_ROWS

#define NUM_ROWS   15

Number of rows in the Board

Definition at line 17 of file utils.h.

Function Documentation

◆ BOARD_COLOURS()

void BOARD_COLOURS ( std::string  x)
inline

Definition at line 132 of file utils.h.

Here is the caller graph for this function:

◆ BOLD()

void BOLD ( std::string  x)
inline

Definition at line 37 of file utils.h.

Here is the caller graph for this function:

◆ BOLD_BLACK_FG()

void BOLD_BLACK_FG ( std::string  x)
inline

Definition at line 92 of file utils.h.

◆ BOLD_BLUE_FG()

void BOLD_BLUE_FG ( std::string  x)
inline

Definition at line 52 of file utils.h.

◆ BOLD_BRIGHT_GREEN_FG()

void BOLD_BRIGHT_GREEN_FG ( std::string  x)
inline

Definition at line 42 of file utils.h.

Here is the caller graph for this function:

◆ BOLD_BROWN_FG()

void BOLD_BROWN_FG ( std::string  x)
inline

Definition at line 67 of file utils.h.

◆ BOLD_CYAN_FG()

void BOLD_CYAN_FG ( std::string  x)
inline

Definition at line 47 of file utils.h.

◆ BOLD_LIGHT_GRAY_FG()

void BOLD_LIGHT_GRAY_FG ( std::string  x)
inline

Definition at line 87 of file utils.h.

◆ BOLD_ORANGE_FG()

void BOLD_ORANGE_FG ( std::string  x)
inline

Definition at line 62 of file utils.h.

◆ BOLD_PINK_FG()

void BOLD_PINK_FG ( std::string  x)
inline

Definition at line 57 of file utils.h.

◆ BOLD_RED_FG()

void BOLD_RED_FG ( std::string  x)
inline

Definition at line 77 of file utils.h.

Here is the caller graph for this function:

◆ BOLD_WHITE_FG()

void BOLD_WHITE_FG ( std::string  x)
inline

Definition at line 72 of file utils.h.

Here is the caller graph for this function:

◆ BROWN_BG()

void BROWN_BG ( std::string  x)
inline

Definition at line 97 of file utils.h.

◆ charPresent()

bool charPresent ( std::string  str,
char  target 
)

◆ DARK_BLUE_BG()

void DARK_BLUE_BG ( std::string  x)
inline

Definition at line 112 of file utils.h.

Here is the caller graph for this function:

◆ LIGHT_BLUE_BG()

void LIGHT_BLUE_BG ( std::string  x)
inline

Definition at line 117 of file utils.h.

Here is the caller graph for this function:

◆ log()

void log ( std::string  logFilePath,
std::string  str 
)

◆ OFF_WHITE_BG()

void OFF_WHITE_BG ( std::string  x)
inline

Definition at line 122 of file utils.h.

◆ PALE_GREEN_FG()

void PALE_GREEN_FG ( std::string  x)
inline

Definition at line 82 of file utils.h.

Here is the caller graph for this function:

◆ parsePlay()

std::vector<std::string> parsePlay ( std::string  in)

Parses a Play in the format <tiles>-<row>-<column>-<direction>

Parameters
inString to parse
Returns
Parsed components

This function shall not throw exceptions.

Definition at line 78 of file utils.cc.

Here is the caller graph for this function:

◆ PINK_BG()

void PINK_BG ( std::string  x)
inline

Definition at line 107 of file utils.h.

Here is the caller graph for this function:

◆ RawTimeToString()

std::string RawTimeToString ( const time_t &  t)

Converts a time_t to a std::string

Parameters
tRaw time to convert
Returns
Converted time_t

This function shall not throw exceptions.

Definition at line 127 of file utils.cc.

Here is the caller graph for this function:

◆ RED_BG()

void RED_BG ( std::string  x)
inline

Definition at line 102 of file utils.h.

Here is the caller graph for this function:

◆ squarePresent()

bool squarePresent ( std::vector< Square * >  s,
Square target 
)

Other helper functions

Checks whether a Square* is present in a vector<Square*>

Parameters
sVector to search in
targetSearch target
Returns
true if found, false otherwise

This function shall not throw exceptions.

Definition at line 24 of file utils.cc.

◆ TILE_COLOURS()

void TILE_COLOURS ( std::string  x)
inline

Definition at line 127 of file utils.h.

Here is the caller graph for this function:

◆ tilePresent()

bool tilePresent ( std::vector< Tile * >  t,
Tile target 
)

Checks whether a Tile* is present in a vector<Tile*>

Parameters
tVector to search in
targetSearch target
Returns
true if found, false otherwise

This function shall not throw exceptions.

Definition at line 43 of file utils.cc.

Here is the caller graph for this function:

Variable Documentation

◆ alphabets

const std::string alphabets = "abcdefghijklmnopqrstuvwxyz"

String of alphabets used for input validation

Definition at line 24 of file utils.h.