Skip to content

ddn.ddn

The ddn.ddn module is the core version information module for the DDN library. It provides compile-time constants and utility functions for querying the library's semantic version.

Overview

This module serves as the central point for version management in the DDN library. It exposes the major, minor, and patch version numbers as compile-time constants, along with helper functions to retrieve the version as either a numeric value or a human-readable string.

Key Features

  • Compile-Time Version Constants: Access MAJOR, MINOR, and PATCH version numbers at compile time
  • Numeric Version Function: Get a single integer representing the full version for easy comparison
  • String Version Function: Retrieve the version as a formatted string (e.g., "2.0.0")
  • Pure and @nogc: All functions are marked nothrow, @nogc, and pure for maximum compatibility

Usage Example

import ddn.ddn;

void main() {
    // Access version constants directly
    static assert(MAJOR == 2);
    static assert(MINOR == 0);
    static assert(PATCH == 0);

    // Get numeric version for comparison
    int ver = ddnVersion();
    // ver == 2_000_000 (MAJOR * 1_000_000 + MINOR * 1_000 + PATCH)

    // Get version as string
    string verStr = ddnVersionString();
    // verStr == "2.0.0"
}

Version Encoding

The ddnVersion() function encodes the version as a single integer using the formula:

version = PATCH + (MINOR × 1,000) + (MAJOR × 1,000,000)

This encoding allows for easy version comparison using standard integer operators:

import ddn.ddn;

// Check if running version 2.0.0 or later
if (ddnVersion() >= 2_000_000) {
    // Use features from version 2.0.0+
}

When to Use

Use this module when you need to:

  • Check the DDN library version at runtime or compile time
  • Implement version-dependent behavior in your application
  • Log or display the library version for debugging purposes
  • Ensure compatibility with specific DDN versions