lab_memory
Malevolent Memories
fileio Namespace Reference

Utility functions for reading students/rooms from files. More...

Namespaces

 fileio_internal
 Holds variables that only need to be accessed by the namespace itself.
 

Typedefs

typedef map< string, vector
< string > > 
FileMap
 Stores config name options if necessary. More...
 

Functions

void init ()
 Sets up the students and rooms variables as empty vectors. More...
 
void halt ()
 Acts as a destructor for the fileio reader. More...
 
void loadStudents (const string &file)
 Reads the student file into the students vector. More...
 
void loadRooms (const string &file)
 Reads the rooms file into the rooms vector. More...
 
int getNumStudents ()
 
int getNumRooms ()
 
bool areMoreStudents ()
 
bool areMoreRooms ()
 
string nextStudent ()
 
Room nextRoom ()
 
Room readRoom (const string &line)
 Reads a line parsed from the rooms file into a list of rooms. More...
 
vector< stringtokenize (const string &str, char delim)
 Tokenizes a string of delimiter-separated elements. More...
 
void readFile (const string &file, vector< string > &lines)
 Reads a file into a vector of lines. More...
 
void readFileGeneric (const string &filename, FileMap *map, vector< string > *lines)
 

Detailed Description

Utility functions for reading students/rooms from files.

Note
There are NO bugs in fileio

Typedef Documentation

Stores config name options if necessary.

Function Documentation

void fileio::init ( )

Sets up the students and rooms variables as empty vectors.

void fileio::halt ( )

Acts as a destructor for the fileio reader.

void fileio::loadStudents ( const string file)

Reads the student file into the students vector.

Parameters
fileThe student file
void fileio::loadRooms ( const string file)

Reads the rooms file into the rooms vector.

Parameters
fileThe room file
int fileio::getNumStudents ( )
Returns
The amount of students read from the students file.
int fileio::getNumRooms ( )
Returns
The number of rooms read from the rooms file.
bool fileio::areMoreStudents ( )
Returns
Whether there are more students to read from the students vector.
bool fileio::areMoreRooms ( )
Returns
Whether there are more rooms left to read from the rooms vector.
string fileio::nextStudent ( )
Returns
The next student in the list of students.
Room fileio::nextRoom ( )
Returns
The next room in the list of rooms.
Room fileio::readRoom ( const string line)

Reads a line parsed from the rooms file into a list of rooms.

Parameters
lineA line containing Room text
Returns
The Room read from the file
vector< string > fileio::tokenize ( const string str,
char  delim 
)

Tokenizes a string of delimiter-separated elements.

Parameters
strThe string to tokenize
delimDelimiters to tokenize the string by
Returns
A vector of the tokenized items
void fileio::readFile ( const string file,
vector< string > &  lines 
)

Reads a file into a vector of lines.

Parameters
fileThe file to read
linesThe vector to fill with lines
void fileio::readFileGeneric ( const string filename,
FileMap *  map,
vector< string > *  lines 
)
Parameters
filenameThe file to read. It may be stdin or similar.
mapThe options map (if needed)
linesWhere to store the lines read from the file