SDOM - Simple SDL Document Object Model
A lightweight, extensible Document Object Model for SDL-based applications.
Loading...
Searching...
No Matches
SDOM.hpp File Reference
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <any>
#include <algorithm>
#include <chrono>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <mutex>
#include <queue>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <sol/sol.hpp>
#include <SDOM/SDOM_SDL_Utils.hpp>
#include <SDOM/SDOM_CLR.hpp>
#include <SDOM/SDOM_DisplayHandle.hpp>
#include <SDOM/SDOM_AssetHandle.hpp>
#include <SDOM/SDOM_UnitTests.hpp>
#include <SDOM/SDOM_Utils.hpp>

Go to the source code of this file.

Classes

class  SDOM::Exception
 Custom exception class for SDOM errors. More...
 
struct  SDOM::Bounds
 Represents a rectangle's position and size in 2D space. More...
 

Namespaces

namespace  SDOM
 Contains all core classes and utilities for the SDOM library.
 

Macros

#define DEBUG_LUA_TESTS   0
 
#define ERROR(message)   throw SDOM::Exception(message, __FILE__, __LINE__)
 Throws an SDOM exception with file and line info.
 
#define WARNING(message)   SDOM::showWarning(message, __FILE__, __LINE__)
 Shows a warning message with file and line info.
 
#define DEBUG_LOG(...)
 Logs a debug message in green text.
 
#define FAIL(...)
 Logs a failure message in red text.
 
#define INFO(...)
 Logs an informational message to stdout.
 
#define LUA_INFO(...)   do { if (DEBUG_LUA_TESTS) { std::ostringstream _sdom_lua_dbg_oss; _sdom_lua_dbg_oss << __VA_ARGS__; std::cout << CLR::YELLOW << "[LUA-INFO] " << (_sdom_lua_dbg_oss.str()) << CLR::RESET << std::endl; } } while(0)
 
#define DEBUG_ERR(message)
 Logs a debug error (non-fatal) with file and line info in dark text.
 
#define ASSERT_EQ(val, expected)
 Asserts that two values are equal; throws an error if not.
 

Enumerations

enum class  SDOM::AnchorPoint : uint8_t {
  SDOM::DEFAULT = 0 , SDOM::TOP_LEFT = 0 , SDOM::TOP_CENTER = 1 , SDOM::TOP_RIGHT = 2 ,
  SDOM::MIDDLE_LEFT = 3 , SDOM::MIDDLE_CENTER = 4 , SDOM::MIDDLE_RIGHT = 5 , SDOM::BOTTOM_LEFT = 6 ,
  SDOM::BOTTOM_CENTER = 7 , SDOM::BOTTOM_RIGHT = 8 , SDOM::Aliases for anchor points , SDOM::LEFT = MIDDLE_LEFT ,
  SDOM::CENTER = MIDDLE_CENTER , SDOM::RIGHT = MIDDLE_RIGHT , SDOM::TOP = TOP_CENTER , SDOM::MIDDLE = MIDDLE_CENTER ,
  SDOM::BOTTOM = BOTTOM_CENTER , SDOM::LEFT_TOP = TOP_LEFT , SDOM::CENTER_TOP = TOP_CENTER , SDOM::RIGHT_TOP = TOP_RIGHT ,
  SDOM::LEFT_MIDDLE = MIDDLE_LEFT , SDOM::CENTER_MIDDLE = MIDDLE_CENTER , SDOM::RIGHT_MIDDLE = MIDDLE_RIGHT , SDOM::LEFT_BOTTOM = BOTTOM_LEFT ,
  SDOM::CENTER_BOTTOM = BOTTOM_CENTER , SDOM::RIGHT_BOTTOM = BOTTOM_RIGHT
}
 Reference points for anchoring child edges to a parent. More...
 

Variables

constexpr bool DEBUG_REGISTER_LUA = false
 
constexpr int ORPHAN_GRACE_PERIOD = 5000
 
static const std::unordered_map< AnchorPoint, std::string > SDOM::anchorPointToString_
 Maps AnchorPoint enum values to their corresponding string names.
 
static const std::unordered_map< std::string, AnchorPointSDOM::stringToAnchorPoint_
 Maps string names to AnchorPoint enum values.
 

Macro Definition Documentation

◆ ASSERT_EQ

#define ASSERT_EQ (   val,
  expected 
)
Value:
if ((val) != (expected)) { \
ERROR("Assertion failed: " + std::string(#val) + " == " + std::string(#expected) \
+ ", actual: " + std::to_string((val)) + ", expected: " + std::to_string((expected))); \
}

Asserts that two values are equal; throws an error if not.

Parameters
valValue to test.
expectedExpected value.

◆ DEBUG_ERR

#define DEBUG_ERR (   message)
Value:
do { std::cout << CLR::DARK << \
"\n Debug: " << \
CLR::YELLOW << (message) << std::endl << CLR::DARK << \
" File: " << CLR::ORANGE << __FILE__ << CLR::DARK << std::endl << \
" Line: " << CLR::ORANGE << __LINE__ << CLR::RESET << "\n" << std::endl; } while(0)
static const std::string RESET
ANSI escape sequence to reset formatting.
Definition SDOM_CLR.hpp:245
static const std::string YELLOW
ANSI escape sequence for yellow foreground.
Definition SDOM_CLR.hpp:278
static const std::string ORANGE
ANSI escape sequence for orange foreground.
Definition SDOM_CLR.hpp:276
static const std::string DARK
ANSI escape sequence for dark grey foreground.
Definition SDOM_CLR.hpp:275

Logs a debug error (non-fatal) with file and line info in dark text.

Parameters
messageDebug message to include.

◆ DEBUG_LOG

#define DEBUG_LOG (   ...)
Value:
do { \
std::ostringstream _sdom_dbg_oss; \
_sdom_dbg_oss << __VA_ARGS__; \
std::cout << CLR::GREEN << "[DEBUG] " << _sdom_dbg_oss.str() << CLR::RESET << std::endl; \
} while(0)
static const std::string GREEN
ANSI escape sequence for green foreground.
Definition SDOM_CLR.hpp:268

Logs a debug message in green text.

Parameters
messageDebug message to display.

◆ DEBUG_LUA_TESTS

#define DEBUG_LUA_TESTS   0

◆ ERROR

#define ERROR (   message)    throw SDOM::Exception(message, __FILE__, __LINE__)

Throws an SDOM exception with file and line info.

Parameters
messageError message to report.

◆ FAIL

#define FAIL (   ...)
Value:
do { \
std::ostringstream _sdom_dbg_oss; \
_sdom_dbg_oss << __VA_ARGS__; \
std::cout << CLR::RED << "[FAILED] " << _sdom_dbg_oss.str() << CLR::RESET << std::endl; \
} while(0)
static const std::string RED
ANSI escape sequence for red foreground.
Definition SDOM_CLR.hpp:267

Logs a failure message in red text.

Parameters
messageFailure message to display.

◆ INFO

#define INFO (   ...)
Value:
do { \
std::ostringstream _sdom_dbg_oss; \
_sdom_dbg_oss << __VA_ARGS__; \
std::cout << CLR::YELLOW << "[INFO] " << (_sdom_dbg_oss.str()) << CLR::RESET << std::endl; } while(0)

Logs an informational message to stdout.

Parameters
messageInformational message to display.

◆ LUA_INFO

#define LUA_INFO (   ...)    do { if (DEBUG_LUA_TESTS) { std::ostringstream _sdom_lua_dbg_oss; _sdom_lua_dbg_oss << __VA_ARGS__; std::cout << CLR::YELLOW << "[LUA-INFO] " << (_sdom_lua_dbg_oss.str()) << CLR::RESET << std::endl; } } while(0)

◆ WARNING

#define WARNING (   message)    SDOM::showWarning(message, __FILE__, __LINE__)

Shows a warning message with file and line info.

Parameters
messageWarning message to display.

Variable Documentation

◆ DEBUG_REGISTER_LUA

constexpr bool DEBUG_REGISTER_LUA = false
constexpr

◆ ORPHAN_GRACE_PERIOD

constexpr int ORPHAN_GRACE_PERIOD = 5000
constexpr