rp-scrabble
Simple, terminal-based Scrabble game
Functions
utils.cc File Reference
#include <vector>
#include <fstream>
#include <sstream>
#include "tile.h"
#include "square.h"
#include "play.h"
#include "utils.h"
Include dependency graph for utils.cc:

Go to the source code of this file.

Functions

bool squarePresent (std::vector< Square * > s, Square *target)
 
bool tilePresent (std::vector< Tile * > t, Tile *target)
 
bool charPresent (string str, char ch)
 
std::vector< std::string > parsePlay (std::string in)
 
void log (string logFilePath, string str)
 
string RawTimeToString (const time_t &t)
 

Function Documentation

◆ charPresent()

bool charPresent ( string  str,
char  ch 
)

Checks whether a char is present in a string

Parameters
strString to search in
chSearch target
Returns
true if found, false otherwise

This function shall not throw exceptions.

Definition at line 62 of file utils.cc.

Here is the caller graph for this function:

◆ log()

void log ( string  logFilePath,
string  str 
)

Log a message to a file

Parameters
logFilePathPath to the file to write to
strLog message
Exceptions
std::stringcontaining the error message

Definition at line 104 of file utils.cc.

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:

◆ RawTimeToString()

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:

◆ squarePresent()

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

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.

◆ 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: