Skip to content

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. T

License

Notifications You must be signed in to change notification settings

Lotus-OS-Core/LCpp-Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LC++ (Lotus C++ Framework) Version 0.7.43

Overview

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.

Table of Contents

  1. Features
  2. Installation
  3. Quick Start
  4. Core Concepts
  5. Examples
  6. API Reference
  7. Building and Running
  8. Version History
  9. License

Features

  • 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

Installation

Method 1: Clone the Repository

cd lcpp-framework

Method 2: Copy the Header File

Simply copy include/lcpp/lcpp.hpp to your project's include directory:

your_project/
├── include/
│   └── lcpp/
│       └── lcpp.hpp    <-- Copy this file
└── src/
    └── your_code.cpp

Quick Start

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_END

Compile and Run

g++ -std=c++17 -I./include your_program.cpp -o your_program
./your_program

Expected 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!

Core Concepts

Announce Block

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_END

Procedures

Procedures 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_code

Decorators

Decorators 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");

Variable Platform

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";

Namespaces

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);

Netspec Comments

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_code

Code Documentation

  • Use Doxygen or similar tools to generate documentation from Netspec tags.

Examples

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

Running Examples

# 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

API Reference

Macros

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

Variable Classes

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

Decorator Functions

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

Framework Procedures

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

Building and Running

Requirements

  • C++17 compatible compiler (g++ 7+, clang 5+, MSVC 2017+)
  • Standard library (STL)

Compilation Flags

# 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_sanitized

CMake Integration

cmake_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)

Version History

Version 0.7.43 (Current)

  • 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

Future Versions (perhabs/maybe)

  • Version 0.8.0: Enhanced decorator composition
  • Version 0.9.0: Coroutine support
  • Version 1.0.0: Stable release with backward compatibility

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

Development Setup

# 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 request

License

The 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.

Support

  • Documentation: See the /docs directory
  • Examples: See the /examples directory
  • 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]

About

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. T

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages