wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
convert.hpp File Reference

Version conversion scaffolding: convert<to>() composes hand-written adjacent-version steps along a format's supported-version ladder. More...

#include <array>
#include <cstddef>
#include <wowlib/core/client_version.hpp>
#include <wowlib/core/error.hpp>
#include <wowlib/formats/common/version_range.hpp>
Include dependency graph for convert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wowlib::formats::VersionTag< V >
 Tags the target version in convert_step overload signatures. More...

Namespaces

namespace  wowlib
namespace  wowlib::formats
namespace  wowlib::formats::detail

Concepts

concept  wowlib::formats::detail::HasConvertStep

Functions

template<std::size_t N>
consteval std::size_t wowlib::formats::detail::indexOf (const std::array< ClientVersion, N > &versions, ClientVersion v)
template<template< ClientVersion > class E>
consteval ClientVersion wowlib::formats::detail::nextCanonical (ClientVersion from, ClientVersion to)
 The next CANONICAL version on E's ladder walking from from toward to — the first range boundary crossed in that direction.
template<template< ClientVersion > class E, ClientVersion From, ClientVersion To>
consteval bool wowlib::formats::hasConvertPath ()
 Whether every convert_step along the CANONICAL ladder from from to to exists, i.e.
template<ClientVersion To, template< ClientVersion > class E, ClientVersion From>
requires (!std::is_same_v< decltype(SupportedVersions<E>), const std::nullptr_t>)
auto wowlib::formats::convert (const E< From > &src) -> Result< E< canonicalVersion(To, VersionPivots< E >, SupportedVersions< E >)> >
 Convert src to its to - version representation by composing convert_step overloads along the format's CANONICAL ladder (one step per range boundary crossed; versions inside one range are the same type and cost nothing).

Variables

template<template< ClientVersion > class E>
constexpr auto wowlib::formats::SupportedVersions = nullptr
 The ordered release list of format template E.
template<template< ClientVersion > class E>
constexpr auto wowlib::formats::VersionPivots = nullptr
 The canonicalization pivots of format template E (the assembly's pivot list from its boundaries header) — convert() walks the CANONICAL ladder these define: versions inside one range are the same type and need no step.

Detailed Description

Version conversion scaffolding: convert<to>() composes hand-written adjacent-version steps along a format's supported-version ladder.

A format contributes:

  • a SupportedVersions<E> specialization (its instantiation list, in release order), and
  • convert_step overloads for each adjacent pair it can translate:
    Result<WMO<versions::cata>> convert_step(const WMO<versions::wotlk>&,
    VersionTag<versions::cata>);

convert<to>(src) then walks the ladder one step at a time — each step encodes exactly one era's format changes; N supported versions cost 2(N-1) steps instead of an N^2 pair matrix. A missing step is a compile-time error naming the versions. Identity conversion (from == to) is a copy, and so is any step BETWEEN versions the format canonicalizes to one range — with range-collapsed instantiation E<vanilla> and E<wotlk> can be the same type, and such steps need (and can have) no convert_step overload.

Definition in file convert.hpp.