LC++ is a structural C++ meta-framework that combines the best practices from multiple programming paradigms. It provides a distinct coding style that mimics Pascal's structured approach while incorporating Pythonic decorators and Solidity-style documentation. The framework is designed to make C++ more accessible, readable, and maintainable while retaining all the power of the underlying language.
This framework is built entirely on standard C++ libraries (STL), ensuring compatibility with any C++ compiler that supports C++17 or higher. No external dependencies are required beyond the standard library.
- Features
- Installation
- Quick Start
- Core Concepts
- Examples
- API Reference
- Building and Running
- Version History
- License
- Header-only Design: No compilation required, just include the header
- Pascal-like Procedures: Structured named code blocks for better readability
- Decorator System: Aspect-oriented programming for logging, timing, validation
- Comprehensive Variable Platform: Mutable, Immutable, Constant, Global, NonGlobal types
- Netspec Documentation: Solidity-style comments for clear API documentation
- Namespace Utilities: Tools for organizing code into logical libraries
- Zero Runtime Overhead: Macros and templates provide compile-time abstraction
- C++17 Compatible: Uses modern C++ features for type safety and performance
cd lcpp-frameworkSimply copy include/lcpp/lcpp.hpp to your project's include directory:
your_project/
├── include/
│ └── lcpp/
│ └── lcpp.hpp <-- Copy this file
└── src/
└── your_code.cpp
Create your first LC++ program:
// SPDX-License-Identifier: MIT
pragma lcpp ^0.7.43;
#include "lcpp/lcpp.hpp"
/// @notice Calculates the sum of two numbers
/// @param a First number
/// @param b Second number
/// @return The sum
procedure(int, addNumbers, int a, int b)
begin_code
return a + b;
end_code
LCPP_MAIN("HelloWorld", "Your Name", "1.0.0")
Lotus::Procedures::printWelcome("My First LC++ App");
int result = addNumbers(10, 5);
std::cout << "10 + 5 = " << result << std::endl;
Lotus::Procedures::printGoodbye("My First LC++ App");
LCPP_MAIN_ENDg++ -std=c++17 -I./include your_program.cpp -o your_program
./your_programExpected output:
╔══════════════════════════════════════════════════════════╗
║ LC++ (Lotus C++ Framework) ║
║ Program: My First LC++ App ║
║ Author: Your Name ║
║ Notice: LC++ Framework Application ║
║ Version: 0.7.43 ║
╚══════════════════════════════════════════════════════════╝
Welcome to My First LC++ App!
Running on LC++ Framework v0.7.43
===========================================================
10 + 5 = 15
===========================================================
Program completed successfully.
Goodbye!
Every LC++ program begins with an Announce Block, inspired by Solidity's contract declaration:
LCPP_MAIN("ProgramName", "Author", "1.0.0")
// Your code here
LCPP_MAIN_ENDProcedures are the fundamental building blocks of LC++, inspired by Pascal:
// A procedure that returns a value
procedure(int, findMax, int a, int b)
begin_code
return (a > b) ? a : b;
end_code
// A void procedure
procedure(void, printMessage, const std::string& message)
begin_code
std::cout << message << std::endl;
end_codeDecorators wrap functions with additional behavior:
// Create a logged function
auto loggedFunc = Lotus::make_logged([]() {
std::cout << "Doing work..." << std::endl;
return 42;
}, "MyFunction");
// Create a timed function
auto timedFunc = Lotus::make_timed(loggedFunc, "TimedFunction");The Variable Platform provides different storage semantics:
// Mutable - can be changed freely
Lotus::Variable::Mutable<int> count(0);
count.set(10);
// Immutable - set once, read many times
Lotus::Variable::Immutable<double> pi(3.14159);
// Constant - compile-time constant
Lotus::Variable::Constant<int, 42> fortyTwo;
// Global - singleton pattern
Lotus::Variable::Global<std::string>::get() = "Global value";Organize code into logical libraries:
begin_namespace(MathUtils)
procedure(double, square, double x)
begin_code
return x * x;
end_code
end_namespace
// Usage
double result = MathUtils::square(5.0);Documentation tags similar to Solidity's NatSpec:
/// @notice Calculates the area of a rectangle
/// @dev Uses simple multiplication
/// @param width The width
/// @param height The height
/// @return The area
procedure(double, calculateArea, double width, double height)
begin_code
return width * height;
end_codeCode Documentation
- Use Doxygen or similar tools to generate documentation from
Netspectags.
The framework includes 20 comprehensive examples:
| # | Example | Description |
|---|---|---|
| 1 | 01_HelloWorld.cpp |
Basic structure and announce block |
| 2 | 02_Variables.cpp |
Variable platform demonstration |
| 3 | 03_Netspec.cpp |
Documentation style |
| 4 | 04_Procedures_Params.cpp |
Procedure parameters |
| 5 | 05_Namespaces.cpp |
Non-global libraries |
| 6 | 06_ControlFlow.cpp |
Conditional logic |
| 7 | 07_Loops.cpp |
Iteration patterns |
| 8 | 08_BasicDecorator.cpp |
Logger decorator |
| 9 | 09_GlobalDecorator.cpp |
Application-wide decorators |
| 10 | 10_InputOutput.cpp |
Console and stream I/O |
| 11 | 11_Arrays_Vectors.cpp |
Collection handling |
| 12 | 12_StringManipulation.cpp |
Text processing |
| 13 | 13_MathLib.cpp |
Custom math library |
| 14 | 14_FileIO.cpp |
File operations |
| 15 | 15_Structs.cpp |
Data structures |
| 16 | 16_Classes_vs_Procedures.cpp |
OOP vs procedural |
| 17 | 17_TimingDecorator.cpp |
Performance measurement |
| 18 | 18_ExceptionHandling.cpp |
Error handling |
| 19 | 19_Templates.cpp |
Generic programming |
| 20 | 20_FinalApp.cpp |
Complete CRUD application |
# Compile and run example 1
g++ -std=c++17 -I./include examples/01_HelloWorld.cpp -o hello
./hello
# Run all examples
for i in {01..20}; do
echo "=== Example $i ==="
g++ -std=c++17 -I./include examples/${i}_*.cpp -o temp
./temp
rm temp
done| Macro | Description |
|---|---|
procedure(RETURN_TYPE, NAME, ...) |
Define a procedure |
void_procedure(NAME, ...) |
Define a void procedure |
begin_code / end_code |
Code block delimiters |
LCPP_MAIN(...) |
Main function with announce |
LCPP_MAIN_END |
End main function |
LCPP_SECTION("Title") |
Print section header |
LCPP_ASSERT(condition, message) |
Assert with error |
| Class | Description |
|---|---|
Lotus::Variable::Mutable<T> |
Standard mutable variable |
Lotus::Variable::Immutable<T> |
Read-only variable |
Lotus::Variable::Constant<T, V> |
Compile-time constant |
Lotus::Variable::Global<T> |
Singleton global variable |
Lotus::Variable::NonGlobal<T> |
Namespace-scoped variable |
| Function | Description |
|---|---|
Lotus::make_logged(func, name) |
Add logging to function |
Lotus::make_timed(func, name) |
Add timing to function |
Lotus::make_validated(func, name, validator, error) |
Add validation |
| Procedure | Description |
|---|---|
Lotus::Procedures::printWelcome(name) |
Print welcome message |
Lotus::Procedures::printGoodbye(name) |
Print goodbye message |
Lotus::Procedures::swapValues(a, b) |
Swap two values |
Lotus::Procedures::findMax(a, b) |
Find maximum of two values |
Lotus::Procedures::findMin(a, b) |
Find minimum of two values |
Lotus::Procedures::factorial(n) |
Calculate factorial |
Lotus::Procedures::isPrime(n) |
Check if prime |
Lotus::Procedures::reverseString(s) |
Reverse a string |
Lotus::Procedures::toUpperCase(s) |
Convert to uppercase |
Lotus::Procedures::toLowerCase(s) |
Convert to lowercase |
- C++17 compatible compiler (g++ 7+, clang 5+, MSVC 2017+)
- Standard library (STL)
# Basic compilation
g++ -std=c++17 -I./include your_program.cpp -o your_program
# With optimizations
g++ -std=c++17 -O2 -I./include your_program.cpp -o your_program
# With debugging
g++ -std=c++17 -g -I./include your_program.cpp -o your_program_debug
# With sanitizers
g++ -std=c++17 -fsanitize=address,undefined -I./include your_program.cpp -o your_program_sanitizedcmake_minimum_required(VERSION 3.10)
project(MyProject)
add_executable(my_app src/main.cpp)
target_include_directories(my_app PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_features(my_app PRIVATE cxx_std_17)- Initial framework release
- Complete procedure syntax system
- Comprehensive decorator system
- Variable platform with 5 types
- Netspec documentation system
- 20 learning examples
- Full API reference documentation
- Version 0.8.0: Enhanced decorator composition
- Version 0.9.0: Coroutine support
- Version 1.0.0: Stable release with backward compatibility
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
# Clone the repository
cd lcpp-framework
# Create a feature branch
git checkout -b feature/your-feature
# Make changes and add tests
# ...
# Run tests
make test
# Submit pull requestThe LC++ Framework is licensed under the MIT License. See the LICENSE file for details.
This was built for use in our projects, we are releasing it publicly at the request of several of our clients. So this is as/is release and use at your own knowledge and risks.
- Documentation: See the
/docsdirectory - Examples: See the
/examplesdirectory - Issues: Report bugs on GitHub Issues
- Discussions: Ask questions on GitHub Discussions
LC++ (Lotus C++ Framework) - Structured C++ for Modern Development
Version 0.7.43 | Last Updated: 2025
BLUE LOTUS INNOVATION LAB [2022-2026]