levelz-cpp 0.2.0
Loading...
Searching...
No Matches
LevelZ::Block Struct Reference

#include <block.hpp>

Public Member Functions

 Block (std::string name)
 
 Block (std::string name, std::unordered_map< std::string, std::string > properties)
 
std::string getProperty (std::string key) const
 
std::string getProperty (std::string key, std::string defaultValue) const
 
bool hasProperty (std::string key) const
 
bool operator== (const Block &other) const
 
bool operator!= (const Block &other) const
 
std::string to_string () const
 
std::ostream & operator<< (std::ostream &strm)
 

Public Attributes

std::string name
 
std::unordered_map< std::string, std::string > properties
 

Detailed Description

Represents a block in a game level.

Constructor & Destructor Documentation

◆ Block() [1/2]

LevelZ::Block::Block ( std::string name)
inlineexplicit

Constructs a new block with the specified name and empty properties.

◆ Block() [2/2]

LevelZ::Block::Block ( std::string name,
std::unordered_map< std::string, std::string > properties )
inline

Constructs a new block with the specified name and properties.

Parameters
nameThe name of the block.
propertiesThe properties of the block.

Member Function Documentation

◆ getProperty() [1/2]

std::string LevelZ::Block::getProperty ( std::string key) const
inline

Gets the property of the block with the specified key.

Parameters
keyThe key of the property.
Returns
The value of the property.

◆ getProperty() [2/2]

std::string LevelZ::Block::getProperty ( std::string key,
std::string defaultValue ) const
inline

Gets the property of the block with the specified key, or a default value if the property does not exist.

Parameters
keyThe key of the property.
defaultValueThe default value to return if the property does not exist.
Returns
The value of the property, or the default value if the property does not exist.

◆ hasProperty()

bool LevelZ::Block::hasProperty ( std::string key) const
inline

Sets the value of a property.

Parameters
keyThe key of the property.
Returns
true if the property was set, false if the property was not set

◆ operator!=()

bool LevelZ::Block::operator!= ( const Block & other) const
inline

Compares two blocks for inequality.

Parameters
otherThe other block to compare to.
Returns
True if the blocks are not equal, false otherwise.

◆ operator<<()

std::ostream & LevelZ::Block::operator<< ( std::ostream & strm)
inline

Overloads the << operator to allow for easy printing of a Block.

Parameters
strmThe output stream to write to.
Returns
The output stream.

◆ operator==()

bool LevelZ::Block::operator== ( const Block & other) const
inline

Compares two blocks for equality.

Parameters
otherThe other block to compare to.
Returns
True if the blocks are equal, false otherwise.

◆ to_string()

std::string LevelZ::Block::to_string ( ) const
inline

Converts this Block into a string.

Returns
The string representation of this Block.

Member Data Documentation

◆ name

std::string LevelZ::Block::name

The name of the block.

◆ properties

std::unordered_map<std::string, std::string> LevelZ::Block::properties

The properties of the block.


The documentation for this struct was generated from the following file: