Libmagicxx v9.0.2
A C++ wrapper library over the Magic Number Recognition Library.
Loading...
Searching...
No Matches
recognition::utility::percentage Class Reference

Represents a value in the range [0, 100]. More...

#include <percentage.hpp>

Public Member Functions

 percentage (int percentage=0) noexcept
 Construct percentage with a given value.
 
 percentage (std::uint64_t completed_steps, std::uint64_t total_steps) noexcept
 Construct percentage from completed and total steps.
 
int get () const noexcept
 
void set (int percentage) noexcept
 Set the percentage value.
 
std::string to_string () const noexcept
 Convert percentage to string.
 

Private Attributes

int m_percentage
 

Detailed Description

Represents a value in the range [0, 100].

Constructor & Destructor Documentation

◆ percentage() [1/2]

recognition::utility::percentage::percentage ( int percentage = 0)
inlineexplicitnoexcept

Construct percentage with a given value.

Parameters
percentageValue in range [0, 100]. Clamped if out of range. Default is 0.

◆ percentage() [2/2]

recognition::utility::percentage::percentage ( std::uint64_t completed_steps,
std::uint64_t total_steps )
inlinenoexcept

Construct percentage from completed and total steps.

Parameters
completed_stepsNumber of steps completed.
total_stepsTotal number of steps.

Member Function Documentation

◆ get()

int recognition::utility::percentage::get ( ) const
inlinenodiscardnoexcept
Returns
The percentage value.

◆ set()

void recognition::utility::percentage::set ( int percentage)
inlinenoexcept

Set the percentage value.

Parameters
percentageNew value in range [0, 100]. Clamped if out of range.

◆ to_string()

std::string recognition::utility::percentage::to_string ( ) const
inlinenodiscardnoexcept

Convert percentage to string.

Returns
String representation of the percentage, in the format "???%".

Member Data Documentation

◆ m_percentage

int recognition::utility::percentage::m_percentage
private

The documentation for this class was generated from the following file: