nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
BoardParser Class Reference

Opens, loads and parses a level file, returning a well-formed Board. More...

#include <BoardParser.hpp>

Static Public Member Functions

static Boardload (std::string filename)
 Loads and parses level with name.
 
static BoardloadFile (std::string filename)
 Loads and parses the level at filename.
 
static bool save (Board *board, std::string filename)
 TODO.
 
static std::vector< std::string > listLevels ()
 Lists all levels found by the game.
 

Static Public Attributes

static std::string directory = ""
 Default directory where the level files are.
 
static std::string extension = "nsnake"
 Default extension for nSnake level files.
 

Detailed Description

Opens, loads and parses a level file, returning a well-formed Board.

Definition at line 31 of file BoardParser.hpp.

Member Function Documentation

◆ listLevels()

std::vector< std::string > BoardParser::listLevels ( )
static

Lists all levels found by the game.

It looks on standard level locations. Whatever that might mean.

Definition at line 170 of file BoardParser.cpp.

◆ load()

Board * BoardParser::load ( std::string filename)
static

Loads and parses level with name.

Note
It looks for it on standard levels location, whatever that might mean.
See also
loadFile

Definition at line 18 of file BoardParser.cpp.

◆ loadFile()

Board * BoardParser::loadFile ( std::string filename)
static

Loads and parses the level at filename.

Returns
A new Board if successful, NULL if failed.
Note
Make sure to delete it later!

Definition at line 28 of file BoardParser.cpp.

Member Data Documentation

◆ directory

std::string BoardParser::directory = ""
static

Default directory where the level files are.

Note
Defaults to Globals::Config::directory + levels/, which at the time of writing is ~/.local/share/nsnake/levels

Definition at line 38 of file BoardParser.hpp.

◆ extension

std::string BoardParser::extension = "nsnake"
static

Default extension for nSnake level files.

It's all the part that comes after the dot on a file name.

Note
Defaults to "nsnake"
Files that does not end with it will be ignored.

Definition at line 47 of file BoardParser.hpp.


The documentation for this class was generated from the following files: