Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::utils Namespace Reference

Namespaces

namespace  details
 

Classes

class  ChainAdapter
 
class  Defer
 
class  DynamicLibrary
 
class  EnumerateAdapter
 
class  FastPimpl
 Implements pimpl idiom without dynamic memory allocation. More...
 
class  FilterAdapter
 
class  FunctionalAdapterBase
 
class  InspectAdapter
 
class  JoinAdapter
 
class  MapAdapter
 
class  ReverseAdapter
 
class  SkipAdapter
 
class  SkipWhileAdapter
 
class  SlideAdapter
 
class  StepByAdapter
 
class  StrideAdapter
 
struct  StringEqual
 Transparent equality comparator for string types. More...
 
struct  StringHash
 Transparent hash functor for string types. More...
 
class  TakeAdapter
 
class  TakeWhileAdapter
 
class  ZipAdapter
 

Concepts

concept  ArithmeticTrait
 
concept  UniqueTypes
 
concept  IteratorLike
 Concept for types that can be used as base iterators in adapters.
 
concept  BidirectionalIteratorLike
 Concept for bidirectional iterators that support decrement operations.
 
concept  PredicateFor
 Concept for predicate functions that can be applied to iterator values.
 
concept  TransformFor
 Concept for transformation functions that can be applied to iterator values.
 
concept  InspectorFor
 Concept for inspection functions that observe but don't modify values.
 
concept  ActionFor
 Concept for action functions that process values.
 
concept  FolderFor
 Concept for folder functions that accumulate values.
 
concept  FilterAdapterRequirements
 Concept to validate FilterAdapter requirements.
 
concept  MapAdapterRequirements
 Concept to validate MapAdapter requirements.
 
concept  TakeAdapterRequirements
 Concept to validate TakeAdapter requirements.
 
concept  SkipAdapterRequirements
 Concept to validate SkipAdapter requirements.
 
concept  TakeWhileAdapterRequirements
 Concept to validate TakeWhileAdapter requirements.
 
concept  SkipWhileAdapterRequirements
 Concept to validate SkipWhileAdapter requirements.
 
concept  EnumerateAdapterRequirements
 Concept to validate EnumerateAdapter requirements.
 
concept  InspectAdapterRequirements
 Concept to validate InspectAdapter requirements.
 
concept  StepByAdapterRequirements
 Concept to validate StepByAdapter requirements.
 
concept  ChainAdapterRequirements
 Concept to validate ChainAdapter requirements.
 
concept  ReverseAdapterRequirements
 Concept to validate ReverseAdapter requirements.
 
concept  JoinAdapterRequirements
 Concept to validate JoinAdapter requirements.
 
concept  SlideAdapterRequirements
 Concept to validate SlideAdapter requirements.
 
concept  StrideAdapterRequirements
 Concept to validate StrideAdapter requirements.
 
concept  ZipAdapterRequirements
 Concept to validate ZipAdapter requirements.
 

Enumerations

enum class  DynamicLibraryError : uint8_t {
  FileNotFound , LoadFailed , SymbolNotFound , InvalidHandle ,
  AlreadyLoaded , NotLoaded , PlatformError
}
 Error codes for dynamic library operations. More...
 
enum class  FileError : uint8_t { kCouldNotOpen , kReadError }
 

Functions

constexpr std::string_view DynamicLibraryErrorToString (DynamicLibraryError error) noexcept
 Gets a human-readable description for a DynamicLibraryError.
 
auto FromPath (const std::filesystem::path &path) -> std::expected< DynamicLibrary, DynamicLibraryError >
 
constexpr std::string_view FileErrorToString (FileError error) noexcept
 Converts FileError to a human-readable string.
 
auto ReadFileToString (std::string_view filepath) -> std::expected< std::string, FileError >
 Reads the entire contents of a file into a string.
 
auto ReadFileToString (const std::filesystem::path &filepath) -> std::expected< std::string, FileError >
 Reads the entire contents of a file into a string.
 
constexpr std::string_view GetFileName (std::string_view path)
 Extracts the file name from a given path.
 
static constexpr std::string_view GetFileExtension (std::string_view path)
 Extracts the file extension from a given path.
 
template<typename OutIt >
constexpr void Into (OutIt out) const
 
constexpr Derived & GetDerived () noexcept
 Gets reference to derived class instance.
 

Enumeration Type Documentation

◆ DynamicLibraryError

enum class helios::utils::DynamicLibraryError : uint8_t
strong

Error codes for dynamic library operations.

Enumerator
FileNotFound 

Library file not found.

LoadFailed 

Failed to load library.

SymbolNotFound 

Symbol not found in library.

InvalidHandle 

Invalid library handle.

AlreadyLoaded 

Library is already loaded.

NotLoaded 

Library is not loaded.

PlatformError 

Platform-specific error.

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/dynamic_library.hpp.

Definition at line 19 of file dynamic_library.hpp.

19 : uint8_t {
20 FileNotFound, ///< Library file not found
21 LoadFailed, ///< Failed to load library
22 SymbolNotFound, ///< Symbol not found in library
23 InvalidHandle, ///< Invalid library handle
24 AlreadyLoaded, ///< Library is already loaded
25 NotLoaded, ///< Library is not loaded
26 PlatformError, ///< Platform-specific error
27};
@ FileNotFound
Library file not found.
@ InvalidHandle
Invalid library handle.
@ LoadFailed
Failed to load library.
@ AlreadyLoaded
Library is already loaded.
@ PlatformError
Platform-specific error.
@ SymbolNotFound
Symbol not found in library.

◆ FileError

enum class helios::utils::FileError : uint8_t
strong
Enumerator
kCouldNotOpen 
kReadError 

Definition at line 16 of file filesystem.hpp.

Function Documentation

◆ DynamicLibraryErrorToString()

constexpr std::string_view helios::utils::DynamicLibraryErrorToString ( DynamicLibraryError  error)
constexprnoexcept

Gets a human-readable description for a DynamicLibraryError.

Parameters
errorThe error code
Returns
String description of the error
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/dynamic_library.hpp.

Definition at line 34 of file dynamic_library.hpp.

34 {
35 switch (error) {
36 case DynamicLibraryError::FileNotFound:
37 return "Library file not found";
38 case DynamicLibraryError::LoadFailed:
39 return "Failed to load library";
40 case DynamicLibraryError::SymbolNotFound:
41 return "Symbol not found in library";
42 case DynamicLibraryError::InvalidHandle:
43 return "Invalid library handle";
44 case DynamicLibraryError::AlreadyLoaded:
45 return "Library is already loaded";
46 case DynamicLibraryError::NotLoaded:
47 return "Library is not loaded";
48 case DynamicLibraryError::PlatformError:
49 return "Platform-specific error";
50 default:
51 return "Unknown error";
52 }
53}

◆ FileErrorToString()

constexpr std::string_view helios::utils::FileErrorToString ( FileError  error)
constexprnoexcept

Converts FileError to a human-readable string.

Parameters
errorThe FileError to convert
Returns
A string view representing the error

Definition at line 23 of file filesystem.hpp.

23 {
24 switch (error) {
25 case FileError::kCouldNotOpen:
26 return "Could not open file";
27 case FileError::kReadError:
28 return "Could not read file";
29 default:
30 return "Unknown file error";
31 }
32}

◆ FromPath()

auto helios::utils::FromPath ( const std::filesystem::path &  path) -> std::expected<DynamicLibrary, DynamicLibraryError>
inline
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/dynamic_library.hpp.

Definition at line 228 of file dynamic_library.hpp.

228 {
229 DynamicLibrary lib;
230 if (const auto result = lib.Load(path); !result) {
231 return std::unexpected(result.error());
232 }
233 return lib;
234}
auto Load(const std::filesystem::path &path) -> std::expected< void, DynamicLibraryError >
Loads a dynamic library from the specified path.

◆ GetDerived()

constexpr const Derived & helios::utils::GetDerived ( )
constexprprotectednoexcept

Gets reference to derived class instance.

Gets const reference to derived class instance.

Returns
Reference to derived class
Const reference to derived class
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 2636 of file functional_adapters.hpp.

2636{ return static_cast<Derived&>(*this); }

◆ GetFileExtension()

static constexpr std::string_view helios::utils::GetFileExtension ( std::string_view  path)
staticconstexpr

Extracts the file extension from a given path.

Parameters
pathThe full file path
Returns
The file extension, including the dot (e.g., ".txt"), or an empty string if none exists

Definition at line 118 of file filesystem.hpp.

118 {
119 const size_t last_dot = path.find_last_of('.');
120 return (last_dot != std::string_view::npos) ? path.substr(last_dot) : "";
121}

◆ GetFileName()

constexpr std::string_view helios::utils::GetFileName ( std::string_view  path)
constexpr

Extracts the file name from a given path.

Parameters
pathThe full file path
Returns
The file name

Definition at line 108 of file filesystem.hpp.

108 {
109 const size_t last_slash = path.find_last_of("/\\");
110 return (last_slash != std::string_view::npos) ? path.substr(last_slash + 1) : path;
111}

◆ Into()

template<typename OutIt >
constexpr void helios::utils::Into ( OutIt  out) const
constexpr

◆ ReadFileToString() [1/2]

auto helios::utils::ReadFileToString ( const std::filesystem::path &  filepath) -> std::expected<std::string, FileError>
inline

Reads the entire contents of a file into a string.

Parameters
filepathThe path to the file
Returns
An expected containing the file contents or a FileError

Definition at line 73 of file filesystem.hpp.

74 {
75 if (filepath.empty()) {
76 return std::unexpected(FileError::kCouldNotOpen);
77 }
78
79 std::ifstream in(filepath, std::ios::in | std::ios::binary);
80 if (!in) {
81 return std::unexpected(FileError::kCouldNotOpen);
82 }
83
84 std::string result;
85 in.seekg(0, std::ios::end);
86 const auto pos = in.tellg();
87 if (pos == std::ifstream::pos_type(-1)) {
88 return std::unexpected(FileError::kReadError);
89 }
90
91 const auto size = static_cast<size_t>(pos);
92 result.resize(size);
93 in.seekg(0, std::ios::beg);
94 in.read(result.data(), static_cast<std::streamsize>(result.size()));
95 if (!in) {
96 return std::unexpected(FileError::kReadError);
97 }
98 in.close();
99
100 return result;
101}

◆ ReadFileToString() [2/2]

auto helios::utils::ReadFileToString ( std::string_view  filepath) -> std::expected<std::string, FileError>
inline

Reads the entire contents of a file into a string.

Parameters
filepathThe path to the file
Returns
An expected containing the file contents or a FileError

Definition at line 39 of file filesystem.hpp.

39 {
40 if (filepath.empty()) {
41 return std::unexpected(FileError::kCouldNotOpen);
42 }
43
44 std::ifstream in(filepath.data(), std::ios::in | std::ios::binary);
45 if (!in) {
46 return std::unexpected(FileError::kCouldNotOpen);
47 }
48
49 std::string result;
50 in.seekg(0, std::ios::end);
51 const auto pos = in.tellg();
52 if (pos == std::ifstream::pos_type(-1)) {
53 return std::unexpected(FileError::kReadError);
54 }
55
56 const auto size = static_cast<size_t>(pos);
57 result.resize(size);
58 in.seekg(0, std::ios::beg);
59 in.read(result.data(), static_cast<std::streamsize>(result.size()));
60 if (!in) {
61 return std::unexpected(FileError::kReadError);
62 }
63 in.close();
64
65 return result;
66}