Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::config::SimpleJson Class Reference

#include <SimpleJsonParser.hpp>

Collaboration diagram for rtp::config::SimpleJson:

Public Member Functions

bool parse (const std::string &filepath)
 
bool parseContent (const std::string &jsonContent)
 
std::string getString (const std::string &key, const std::string &defaultVal="") const
 
int getInt (const std::string &key, int defaultVal=0) const
 
float getFloat (const std::string &key, float defaultVal=0.0f) const
 
bool getBool (const std::string &key, bool defaultVal=false) const
 
const std::unordered_map< std::string, std::string > & getData () const
 

Public Attributes

std::unordered_map< std::string, std::string > data
 

Private Member Functions

bool parseObject (const std::string &content)
 
void skipWhitespace (const std::string &str, size_t &pos)
 
std::string parseString (const std::string &str, size_t &pos)
 
std::string parseValue (const std::string &str, size_t &pos)
 
std::string extractNestedObject (const std::string &str, size_t &pos)
 

Detailed Description

Definition at line 15 of file SimpleJsonParser.hpp.

Member Function Documentation

◆ extractNestedObject()

std::string rtp::config::SimpleJson::extractNestedObject ( const std::string &  str,
size_t &  pos 
)
inlineprivate

Definition at line 143 of file SimpleJsonParser.hpp.

Referenced by parseObject().

◆ getBool()

bool rtp::config::SimpleJson::getBool ( const std::string &  key,
bool  defaultVal = false 
) const
inline

Definition at line 59 of file SimpleJsonParser.hpp.

References data.

◆ getData()

const std::unordered_map< std::string, std::string > & rtp::config::SimpleJson::getData ( ) const
inline

Definition at line 165 of file SimpleJsonParser.hpp.

References data.

Referenced by rtp::config::loadSpriteMappings().

◆ getFloat()

float rtp::config::SimpleJson::getFloat ( const std::string &  key,
float  defaultVal = 0.0f 
) const
inline

Definition at line 49 of file SimpleJsonParser.hpp.

References data.

◆ getInt()

int rtp::config::SimpleJson::getInt ( const std::string &  key,
int  defaultVal = 0 
) const
inline

Definition at line 39 of file SimpleJsonParser.hpp.

References data.

◆ getString()

std::string rtp::config::SimpleJson::getString ( const std::string &  key,
const std::string &  defaultVal = "" 
) const
inline

Definition at line 34 of file SimpleJsonParser.hpp.

References data.

◆ parse()

bool rtp::config::SimpleJson::parse ( const std::string &  filepath)
inline

Definition at line 19 of file SimpleJsonParser.hpp.

References parseObject().

◆ parseContent()

bool rtp::config::SimpleJson::parseContent ( const std::string &  jsonContent)
inline

Definition at line 30 of file SimpleJsonParser.hpp.

References parseObject().

Referenced by rtp::config::loadSpriteMappings(), and rtp::config::parseWeaponsFile().

◆ parseObject()

bool rtp::config::SimpleJson::parseObject ( const std::string &  content)
inlineprivate

Definition at line 66 of file SimpleJsonParser.hpp.

References data, extractNestedObject(), parseString(), parseValue(), and skipWhitespace().

Referenced by parse(), and parseContent().

◆ parseString()

std::string rtp::config::SimpleJson::parseString ( const std::string &  str,
size_t &  pos 
)
inlineprivate

Definition at line 109 of file SimpleJsonParser.hpp.

Referenced by parseObject(), and parseValue().

◆ parseValue()

std::string rtp::config::SimpleJson::parseValue ( const std::string &  str,
size_t &  pos 
)
inlineprivate

Definition at line 125 of file SimpleJsonParser.hpp.

References parseString().

Referenced by parseObject().

◆ skipWhitespace()

void rtp::config::SimpleJson::skipWhitespace ( const std::string &  str,
size_t &  pos 
)
inlineprivate

Definition at line 105 of file SimpleJsonParser.hpp.

Referenced by parseObject().

Member Data Documentation

◆ data

std::unordered_map<std::string, std::string> rtp::config::SimpleJson::data

Definition at line 17 of file SimpleJsonParser.hpp.

Referenced by getBool(), getData(), getFloat(), getInt(), getString(), and parseObject().


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