Compare commits

33 Commits

Author SHA1 Message Date
ea5d73f2ac fix module path 2025-12-15 21:54:41 -05:00
1eb901fd75 fix module path 2025-12-15 21:36:41 -05:00
055ad5aaa7 Swap remote for cmake modules 2025-12-15 21:27:29 -05:00
a46749a7a6 reflection 2025-12-15 21:24:55 -05:00
fac5494bee Sets correct branch for cmake modules 2025-11-23 03:32:04 -05:00
f5c2c86eea bump fgl cmake modules 2025-11-23 03:30:18 -05:00
a7aa1601b5 Calls pre setup for libFGL to use fgl cmake modules 2025-11-23 03:15:56 -05:00
86c05b29dc bump cmake modules 2025-11-22 09:44:26 -05:00
ae43377c57 Fix incorrect cxx26 checking 2025-11-17 04:40:30 -05:00
77b10d5215 bump cmake modules 2025-11-17 04:32:11 -05:00
7305dc2e1b bump fgl cmake modules 2025-11-15 23:30:05 -05:00
d1d58e4eba bumps cmake modules 2025-11-08 22:35:30 -05:00
7bab49f8d8 bump fgl_cmake_modules 2025-11-03 01:21:12 -05:00
f2d8d792fe Merge remote-tracking branch 'origin/detached' into HEAD 2025-10-23 14:58:54 -04:00
945310d4d7 bump fgl_cmake_modules 2025-10-23 14:58:45 -04:00
63f393e07c fump fgl modules version 2025-10-18 13:41:43 -04:00
83794c7531 Fixes type warning 2025-07-28 15:45:51 -04:00
fec9c7a904 Merge remote-tracking branch 'origin/master' 2025-07-25 01:32:24 -04:00
14e83f176a Fixes invalid module url for libFGL 2025-07-25 01:15:28 -04:00
02dc51a698 Fixes invalid module url for libFGL 2025-07-25 01:15:15 -04:00
b663c74706 Fixes warning in toHuman 2025-07-16 02:25:12 -04:00
1ce9f47c59 Adds new feature flags for libFGL 2025-07-16 02:03:48 -04:00
d70a0f7bad bump fgl_cmake_modules 2025-07-15 19:59:55 -04:00
77024c7561 bump fgl modules 2025-07-13 21:37:44 -04:00
8726aa8bdd Merge remote-tracking branch 'origin/master' 2025-07-13 21:23:33 -04:00
a475a261ed cmake fixes 2025-07-13 21:23:26 -04:00
6230b8f4d4 bump fgl modules 2025-07-13 21:21:10 -04:00
59907f5b56 bump modules again 2025-06-26 16:33:48 -04:00
698311842f Merge remote-tracking branch 'origin/master' 2025-06-26 16:31:20 -04:00
331adada15 bump fgl cmake modules version 2025-06-26 16:30:09 -04:00
a7eb469f13 Bump fgl modules version 2025-06-11 14:46:14 -04:00
40bb17e2aa Bumps cmake modules 2025-06-11 04:36:32 -04:00
KJ16609
25f0fc63b9 Merge pull request #1 from KJNeko/modules
Modules
2025-05-29 13:56:09 -04:00
6 changed files with 96 additions and 15 deletions

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "fgl_cmake_modules"] [submodule "fgl_cmake_modules"]
path = fgl_cmake_modules path = fgl_cmake_modules
url = git@github.com:KJNeko/fgl_cmake_modules.git url = https://git.futuregadgetlabs.net/KJ16609/fgl_cmake_modules.git

View File

@@ -1,5 +1,5 @@
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fgl_cmake_modules) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fgl_cmake_modules)
PreSetup()
AddFGLLibrary(libFGL STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include) AddFGLLibrary(libFGL STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include)

16
include/fgl/features.hpp Normal file
View File

@@ -0,0 +1,16 @@
//
// Created by kj16609 on 7/16/25.
//
#pragma once
#ifdef __cpp_pp_embed
#if __cpp_pp_embed >= 202502L
#define FGL_HAS_EMBED 1
#else
#define FGL_HAS_EMBED 0
#endif
#endif
#ifndef FGL_HAS_EMBED
#define FGL_HAS_EMBED 0
#endif

View File

@@ -0,0 +1,32 @@
//
// Created by kj16609 on 11/24/25.
//
#pragma once
namespace fgl
{
template < typename E >
consteval E enumFromString( std::string_view s )
{
constexpr std::meta::info info { ^^E };
static_assert( std::meta::is_enum_type( info ), "E must be an enum" );
for ( const auto member : std::meta::enumerators_of( info ) )
{
const auto name { std::meta::identifier_of( member ) };
if ( name == s ) return std::meta::extract< E >( member );
}
throw std::meta::exception( "Unable to map string to enum", info );
}
enum TestEnum
{
MY_VAR = 1
};
static_assert(
enumFromString< TestEnum >( "MY_VAR" ) == TestEnum::MY_VAR, "Enum from string did not get expected output" );
} // namespace fgl

View File

@@ -3,21 +3,54 @@
// //
#pragma once #pragma once
#include <cmath>
#include <cstdint>
#include <format> #include <format>
#include <string> #include <string>
namespace fgl::size namespace fgl::size
{ {
std::string toHuman( std::size_t size )
std::string toHuman( std::size_t size ) {
{
constexpr std::size_t mod { 1024 }; constexpr std::size_t mod { 1024 };
if ( size < mod ) return std::format( "{}B", size ); if ( size < mod ) return std::format( "{}B", size );
if ( size < std::pow( mod, 2 ) ) return std::format( "{}KiB", static_cast< int >( size / mod ) ); if ( size < mod * mod ) return std::format( "{}KiB", static_cast< int >( size / mod ) );
if ( size < std::pow( mod, 3 ) ) return std::format( "{}MiB", static_cast< int >( size / std::pow( mod, 2 ) ) ); if ( size < mod * mod * mod ) return std::format( "{}MiB", static_cast< int >( size / ( mod * mod ) ) );
if ( size < std::pow( mod, 4 ) ) return std::format( "{}GiB", static_cast< int >( size / std::pow( mod, 3 ) ) ); if ( size < mod * mod * mod * mod )
return std::format( "{}TiB", static_cast< int >( size / std::pow( mod, 4 ) ) ); return std::format( "{}GiB", static_cast< int >( size / ( mod * mod * mod ) ) );
} return std::format( "{}TiB", static_cast< int >( size / ( mod * mod * mod * mod ) ) );
}
namespace literals
{
constexpr unsigned long long int operator""_B( const unsigned long long int size )
{
return size;
}
constexpr unsigned long long int operator""_KiB( const unsigned long long int size )
{
return size * 1024;
}
constexpr unsigned long long int operator""_MiB( const unsigned long long int size )
{
return size * 1024_KiB;
}
constexpr unsigned long long int operator""_GiB( const unsigned long long int size )
{
return size * 1024_MiB;
}
inline std::string toString( const unsigned long long int size )
{
if ( size < 1024_B ) return std::to_string( size ) + " B";
if ( size < 1024_KiB ) return std::to_string( size / 1024 ) + " KiB";
if ( size < 1024_MiB ) return std::to_string( size / 1024_KiB ) + " MiB";
if ( size < 1024_GiB ) return std::to_string( size / 1024_MiB ) + " GiB";
return std::to_string( size / 1024_GiB ) + " TiB";
}
} // namespace literals
} // namespace fgl::size } // namespace fgl::size