CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
Text Class Reference

Lightweight text lookup service backed by a JSON file. More...

#include <text.h>

Collaboration diagram for Text:

Public Member Functions

 Text ()
 Loads text data from the JSON source.
 
const std::string & getText (const char *key) const
 Returns the text associated with the given key.
 

Detailed Description

Lightweight text lookup service backed by a JSON file.

Text loads a JSON document at construction time and provides read-only access to string values by key. It is intended for externalized game text such as UI labels, messages, or descriptions.

The underlying data is immutable after construction.

Constructor & Destructor Documentation

◆ Text()

Text::Text ( )

Loads text data from the JSON source.

The JSON file is parsed during construction and stored internally.

Member Function Documentation

◆ getText()

const std::string & Text::getText ( const char *  key) const

Returns the text associated with the given key.

Parameters
keyNull-terminated string key used to look up the text.
Returns
Reference to the stored string value.
Exceptions
Ifthe key is not present in the underlying JSON data.

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