CPP-AP 2.7.0
Command-line argument parser for C++20
Loading...
Searching...
No Matches
version.hpp
Go to the documentation of this file.
1// Copyright (c) 2023-2025 Jakub MusiaƂ
2// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap).
3// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
4
5#pragma once
6
7#include <format>
8#include <iostream>
9
10namespace ap {
11
13struct version {
14 std::uint32_t major;
15 std::uint32_t minor;
16 std::uint32_t patch;
17
19 [[nodiscard]] std::string str() const noexcept {
20 return std::format("v{}.{}.{}", this->major, this->minor, this->patch);
21 }
22
24 friend std::ostream& operator<<(std::ostream& os, const version& v) {
25 os << v.str();
26 return os;
27 }
28};
29
30} // namespace ap
Definition utility.hpp:17
A helper structure used to represent a program's version.
Definition version.hpp:13
std::string str() const noexcept
Converts the structure into a string in the v{major}.{minor}.{path} format.
Definition version.hpp:19
friend std::ostream & operator<<(std::ostream &os, const version &v)
The stream insertion operator.
Definition version.hpp:24
std::uint32_t major
The major version number.
Definition version.hpp:14
std::uint32_t minor
The minor version number.
Definition version.hpp:15
std::uint32_t patch
The patch number.
Definition version.hpp:16