Skip to content

Coding Standards & Guidelines: Aegis Packet Engine

1. Code Style and Conventions

Aegis adheres to standard modern C++ guidelines to ensure codebase clarity, maintainability, and correctness.

Style Rules:

  • Naming Conventions:
  • Namespaces: Aegis (all lowercase or PascalCase for sub-components, e.g., Aegis::Network).
  • Classes / Structs: PascalCase (e.g. PacketBufferPool).
  • Functions / Methods: camelCase (e.g. readNextPacket).
  • Variables / Members: snake_case (e.g. packet_id). Member variables must end with a trailing underscore (e.g. ref_count_).
  • Constants / Enums: UPPER_CASE (e.g. MAX_PACKET_SIZE).
  • Formatting:
  • Indentation: 4 spaces (no tabs).
  • Line Length: Soft limit of 100 characters.
  • Braces: K&R style (opening brace on the same line as statement, closing brace on its own line).

2. C++17/20 Feature Checklist

Aegis uses C++17. The following features are encouraged: * std::string_view for non-owning string references (ideal for SNI / Host parsing). * std::optional for return values that may be empty (e.g., extracting SNI from a non-TLS packet). * std::variant / std::any for polymorphism without inheritance overhead (if needed). * constexpr for all compile-time constants instead of #define. * struct structured bindings for parsing tuples/arrays. * [[nodiscard]] on function declarations to prevent ignored returns.


3. Strict Resource Management (RAII)

  • All resource lifetimes must be tied to object scope (Resource Acquisition Is Initialization).
  • Manual calls to delete or free are prohibited. Use custom allocators or smart pointers if heap allocation is required outside the fast path.
  • Thread lifetimes are managed via wrapper classes. The destructor must signal shutdown and join the threads.

4. Compiler Configuration & Warnings

We compile Aegis with warnings treated as errors to catch issues early.

Compiler Flags:

  • GCC / Clang:
    -std=c++17 -Wall -Wextra -Werror -Wpedantic -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -O3 -march=native
    
  • MSVC (Windows):
    /std:c++17 /W4 /WX /EHsc /O2 /permissive-
    
  • Sanitizers: Include options for -fsanitize=address,undefined in debug builds.