Skip to content

Commit fb1afc9

Browse files
committed
Initial
1 parent 2c29ad6 commit fb1afc9

File tree

12 files changed

+1092
-1
lines changed

12 files changed

+1092
-1
lines changed

.clang-format

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Project
2+
Language: Cpp
3+
Standard: c++20
4+
5+
ColumnLimit: 120
6+
7+
# Indentation
8+
AccessModifierOffset: -2
9+
BitFieldColonSpacing: Both
10+
ContinuationIndentWidth: 2
11+
IndentCaseLabels: true
12+
IndentCaseBlocks: false
13+
IndentExternBlock: Indent
14+
IndentPPDirectives: BeforeHash
15+
IndentRequires: true
16+
IndentWidth: 2
17+
IndentWrappedFunctionNames: true
18+
TabWidth: 2
19+
UseTab: Never
20+
# Alignment
21+
22+
AlignAfterOpenBracket: Align
23+
AlignConsecutiveAssignments: Consecutive
24+
AlignConsecutiveBitFields: Consecutive
25+
AlignConsecutiveDeclarations: Consecutive
26+
AlignConsecutiveMacros: Consecutive
27+
AlignEscapedNewlines: Left
28+
AlignOperands: DontAlign
29+
AlignTrailingComments: true
30+
31+
# Allow
32+
AllowAllArgumentsOnNextLine: false
33+
AllowAllConstructorInitializersOnNextLine: true
34+
AllowAllParametersOfDeclarationOnNextLine: false
35+
AllowShortBlocksOnASingleLine: Never
36+
AllowShortCaseLabelsOnASingleLine: false
37+
AllowShortEnumsOnASingleLine: false
38+
AllowShortFunctionsOnASingleLine: true
39+
AllowShortIfStatementsOnASingleLine: Never
40+
AllowShortLoopsOnASingleLine: false
41+
AllowShortLambdasOnASingleLine: All
42+
43+
# Break
44+
AlwaysBreakAfterReturnType: None
45+
AlwaysBreakBeforeMultilineStrings: true
46+
AlwaysBreakTemplateDeclarations: Yes
47+
BreakBeforeConceptDeclarations: true
48+
BreakBeforeTernaryOperators: true
49+
BreakConstructorInitializers: BeforeComma
50+
BreakBeforeBinaryOperators: None
51+
BreakInheritanceList: AfterColon
52+
BreakStringLiterals: true
53+
54+
# Initializers & arguments
55+
BinPackArguments: false
56+
BinPackParameters: false
57+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
58+
ConstructorInitializerIndentWidth: 0
59+
Cpp11BracedListStyle: true
60+
# Braces
61+
BreakBeforeBraces: Stroustrup
62+
# BraceWrapping:
63+
# AfterCaseLabel: false
64+
# AfterClass: false
65+
# AfterControlStatement: Always
66+
# AfterEnum: false
67+
# AfterFunction: true
68+
# AfterNamespace: false
69+
# AfterStruct: false
70+
# AfterUnion: false
71+
# AfterExternBlock: false
72+
# BeforeCatch: false
73+
# BeforeElse: false
74+
# BeforeLambdaBody: true
75+
# BeforeWhile: false
76+
# IndentBraces: false
77+
# SplitEmptyFunction: true
78+
# SplitEmptyRecord: true
79+
# SplitEmptyNamespace: true
80+
81+
# Namespaces
82+
ShortNamespaceLines: 0
83+
CompactNamespaces: false
84+
FixNamespaceComments: true
85+
NamespaceIndentation: Inner
86+
87+
# Derive
88+
DeriveLineEnding: false
89+
DerivePointerAlignment: false
90+
91+
# Empty lines
92+
EmptyLineBeforeAccessModifier: Leave
93+
KeepEmptyLinesAtTheStartOfBlocks: true
94+
MaxEmptyLinesToKeep: 2
95+
96+
97+
# Sorting
98+
SortUsingDeclarations: true
99+
100+
# Penalties
101+
PenaltyBreakAssignment: 1000
102+
PenaltyBreakBeforeFirstCallParameter: 1000
103+
PenaltyBreakComment: 200
104+
PenaltyBreakFirstLessLess: 100
105+
PenaltyBreakString: 1
106+
PenaltyBreakTemplateDeclaration: 0
107+
PenaltyExcessCharacter: 5
108+
PenaltyIndentedWhitespace: 1
109+
PenaltyReturnTypeOnItsOwnLine: 5000000
110+
111+
# Pointer alignment
112+
PointerAlignment: Left
113+
114+
# Comments
115+
ReflowComments: false
116+
117+
# Spaces
118+
SpaceAfterCStyleCast: false
119+
SpaceAfterLogicalNot: false
120+
SpaceAfterTemplateKeyword: false
121+
SpaceAroundPointerQualifiers: Default
122+
SpaceBeforeAssignmentOperators: true
123+
SpaceBeforeCaseColon: false
124+
SpaceBeforeCpp11BracedList: false
125+
SpaceBeforeCtorInitializerColon: true
126+
SpaceBeforeInheritanceColon: true
127+
SpaceBeforeParens: ControlStatements
128+
SpaceBeforeRangeBasedForLoopColon: true
129+
SpaceBeforeSquareBrackets: false
130+
SpaceInEmptyBlock: false
131+
SpaceInEmptyParentheses: false
132+
SpacesBeforeTrailingComments: 1
133+
SpacesInAngles: false
134+
SpacesInCStyleCastParentheses: false
135+
SpacesInConditionalStatement: false
136+
SpacesInContainerLiterals: false
137+
SpacesInParentheses: false
138+
SpacesInSquareBrackets: false
139+
140+
# Line endings
141+
UseCRLF: false
142+
143+
# Qualifiers (const, volatile, static, etc)
144+
QualifierAlignment: Custom
145+
QualifierOrder: ['static', 'inline', 'constexpr', 'const', 'volatile', 'type']

.github/workflows/ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
build:
16+
name: ${{ matrix.platform.name }}
17+
runs-on: ${{ matrix.platform.os }}
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
platform:
23+
- { name: Windows MSVC 2022, os: windows-2022, compiler: msvc,flags: "" }
24+
25+
- { name: Windows Clang 19, os: windows-latest, compiler: clang, version: 19.1.0, flags: "-DCMAKE_CXX_COMPILER=clang++" }
26+
- { name: Windows Clang 20, os: windows-latest, compiler: clang, version: 20.1.0, flags: "-DCMAKE_CXX_COMPILER=clang++" }
27+
28+
- { name: MacOS Clang Latest, os: macos-latest, compiler: clang, flags: "-DCMAKE_CXX_COMPILER=clang++" }
29+
30+
- { name: Ubuntu GCC 11, os: ubuntu-latest, compiler: gcc, version: 11, flags: "-DCMAKE_CXX_COMPILER=g++" }
31+
- { name: Ubuntu GCC 12, os: ubuntu-latest, compiler: gcc, version: 12, flags: "-DCMAKE_CXX_COMPILER=g++" }
32+
- { name: Ubuntu GCC 13, os: ubuntu-latest, compiler: gcc, version: 13, flags: "-DCMAKE_CXX_COMPILER=g++" }
33+
- { name: Ubuntu GCC 14, os: ubuntu-latest, compiler: gcc, version: 14, flags: "-DCMAKE_CXX_COMPILER=g++" }
34+
# Sadly cannot install
35+
#- { name: Ubuntu GCC 15, os: ubuntu-latest, compiler: gcc, version: 15, flags: "-DCMAKE_CXX_COMPILER=g++" }
36+
37+
- { name: Ubuntu Clang 18, os: ubuntu-latest, compiler: clang, version: 18, flags: "-DCMAKE_CXX_COMPILER=clang++" }
38+
- { name: Ubuntu Clang 19, os: ubuntu-latest, compiler: clang, version: 19, flags: "-DCMAKE_CXX_COMPILER=clang++" }
39+
- { name: Ubuntu Clang 20, os: ubuntu-latest, compiler: clang, version: 20, flags: "-DCMAKE_CXX_COMPILER=clang++" }
40+
- { name: Ubuntu Clang 21, os: ubuntu-latest, compiler: clang, version: 21, flags: "-DCMAKE_CXX_COMPILER=clang++" }
41+
42+
steps:
43+
- name: Checkout Code
44+
uses: actions/checkout@v4
45+
46+
- name: Install CMake and Ninja
47+
uses: lukka/get-cmake@latest
48+
49+
- name: Setup MSVC Dev Command Prompt
50+
if: runner.os == 'Windows' && matrix.platform.compiler == 'msvc'
51+
uses: ilammy/msvc-dev-cmd@v1
52+
53+
- name: Setup Clang (Windows)
54+
if: runner.os == 'Windows' && matrix.platform.compiler == 'clang'
55+
run: |
56+
choco install -y llvm --version=${{ matrix.platform.version }} --force
57+
echo "C:\\Program Files\\LLVM\\bin" >> $GITHUB_PATH
58+
59+
- name: Setup Clang (Linux)
60+
if: runner.os == 'Linux' && matrix.platform.compiler == 'clang'
61+
uses: aminya/setup-cpp@v1
62+
with:
63+
compiler: llvm-${{matrix.platform.version}}
64+
65+
- name: Setup GCC
66+
if: matrix.platform.compiler == 'gcc'
67+
uses: aminya/setup-cpp@v1
68+
with:
69+
compiler: gcc-${{matrix.platform.version}}
70+
71+
- name: Configure CMake (Debug)
72+
run: >
73+
cmake -B build
74+
-G Ninja
75+
${{ matrix.platform.flags }}
76+
-DCMAKE_BUILD_TYPE=Debug
77+
-DLAHZAM_BUILD_TESTS=ON
78+
79+
- name: Build (Debug)
80+
run: cmake --build build
81+
82+
- name: Run Tests (Debug)
83+
run: ctest --test-dir build --output-on-failure
84+
85+
- name: Clean Build Directory
86+
run: "rm -rf build"
87+
shell: bash
88+
89+
- name: Configure CMake (Release)
90+
run: >
91+
cmake -B build
92+
-G Ninja
93+
${{ matrix.platform.flags }}
94+
-DCMAKE_BUILD_TYPE=Release
95+
-DLAHZAM_BUILD_TESTS=ON
96+
97+
- name: Build (Release)
98+
run: cmake --build build
99+
100+
- name: Run Tests (Release)
101+
run: ctest --test-dir build --output-on-failure

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
*.slo
2+
*.lo
3+
*.o
4+
*.obj
5+
*.gch
6+
*.pch
7+
*.so
8+
*.dylib
9+
*.dll
10+
*.lai
11+
*.la
12+
*.a
13+
*.lib
14+
*.exe
15+
*.out
16+
*.app
17+
*.user
18+
*.vcxproj
19+
*.vcxproj.user
20+
*.vcxproj.filters
21+
*.sln
22+
23+
cmake_install.cmake
24+
.cache/
25+
*.TMP
26+
27+
Testing
28+
Debug/
29+
build/
30+
buildClang/
31+
buildGCC/
32+
CMakeFiles/
33+
.vs/
34+
benchmarks/time.py
35+
benchmarks/*.cpp
36+
ignore/

CMakeLists.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
cmake_minimum_required(VERSION 3.22.0)
2+
project(lahzam
3+
VERSION 0.0.1
4+
HOMEPAGE_URL "https://github.com/ZXShady/lahzam"
5+
DESCRIPTION "Fast macro-free aggregate reflection C++ library"
6+
LANGUAGES CXX)
7+
8+
if(POLICY CMP0128)
9+
cmake_policy(SET CMP0128 NEW)
10+
endif()
11+
12+
set(INCDIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
13+
file(GLOB_RECURSE INCS "${INCDIR}/*.hpp")
14+
15+
add_library(lahzam INTERFACE ${INCS})
16+
add_library(lahzam::lahzam ALIAS lahzam)
17+
target_compile_features(lahzam INTERFACE cxx_std_20)
18+
19+
target_include_directories(lahzam INTERFACE
20+
$<BUILD_INTERFACE:${INCDIR}>
21+
$<INSTALL_INTERFACE:include>
22+
)
23+
24+
option(LAHZAM_BUILD_TESTS "Enable tests for this `lahzam` library" OFF)
25+
26+
if(LAHZAM_BUILD_TESTS)
27+
enable_testing()
28+
add_subdirectory(tests)
29+
endif()
30+
31+
install(TARGETS lahzam
32+
EXPORT lahzamTargets
33+
)
34+
35+
include(GNUInstallDirs)
36+
37+
install(DIRECTORY ${INCDIR}/
38+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
39+
FILES_MATCHING PATTERN "*.hpp"
40+
)
41+
42+
install(EXPORT lahzamTargets
43+
NAMESPACE lahzam::
44+
DESTINATION ${CMAKE_INSTALL_DATADIR}/lahzam/cmake
45+
)
46+
47+
include(CMakePackageConfigHelpers)
48+
49+
write_basic_package_version_file(
50+
"${CMAKE_CURRENT_BINARY_DIR}/lahzamConfigVersion.cmake"
51+
VERSION ${PROJECT_VERSION}
52+
COMPATIBILITY AnyNewerVersion
53+
)
54+
55+
configure_package_config_file(
56+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lahzamConfig.cmake.in"
57+
"${CMAKE_CURRENT_BINARY_DIR}/lahzamConfig.cmake"
58+
INSTALL_DESTINATION cmake
59+
)
60+
61+
install(FILES
62+
"${CMAKE_CURRENT_BINARY_DIR}/lahzamConfig.cmake"
63+
"${CMAKE_CURRENT_BINARY_DIR}/lahzamConfigVersion.cmake"
64+
DESTINATION cmake
65+
)
66+
67+
export(
68+
TARGETS lahzam
69+
NAMESPACE lahzam::
70+
FILE "${CMAKE_CURRENT_BINARY_DIR}/lahzamTargets.cmake"
71+
)

CMakePresets.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "dev",
6+
"displayName": "Developer Configuartion",
7+
"cacheVariables": {
8+
"CMAKE_CXX_STANDARD": "20",
9+
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
10+
"CMAKE_CXX_EXTENSIONS": "OFF",
11+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
12+
"LAHZAM_BUILD_TESTS": "ON"
13+
}
14+
}
15+
]
16+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 ZXShady
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)