Loading...
Searching...
No Matches
AsSizeValue Class Reference

Converts a human-readable size string (with unit literal) to uin64_t size. More...

#include <CLI11.h>

+ Inheritance diagram for AsSizeValue:

Public Types

using result_t = std::uint64_t
 
- Public Types inherited from AsNumberWithUnit
enum  Options {
  CASE_SENSITIVE = 0 , CASE_INSENSITIVE = 1 , UNIT_OPTIONAL = 0 , UNIT_REQUIRED = 2 ,
  DEFAULT = CASE_INSENSITIVE | UNIT_OPTIONAL
}
 Adjust AsNumberWithUnit behavior. More...
 

Public Member Functions

 AsSizeValue (bool kb_is_1000)
 If kb_is_1000 is true, interpret 'kb', 'k' as 1000 and 'kib', 'ki' as 1024 (same applies to higher order units as well).
 
- Public Member Functions inherited from AsNumberWithUnit
template<typename Number >
 AsNumberWithUnit (std::map< std::string, Number > mapping, Options opts=DEFAULT, const std::string &unit_name="UNIT")
 
- Public Member Functions inherited from Validator
 Validator (std::string validator_desc)
 Construct a Validator with just the description string.
 
 Validator (std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
 Construct Validator from basic information.
 
Validatoroperation (std::function< std::string(std::string &)> op)
 Set the Validator operation function.
 
std::string operator() (std::string &str) const
 This is the required operator for a Validator - provided to help users (CLI11 uses the member func directly)
 
std::string operator() (const std::string &str) const
 This is the required operator for a Validator - provided to help users (CLI11 uses the member func directly)
 
Validatordescription (std::string validator_desc)
 Specify the type string.
 
CLI11_NODISCARD Validator description (std::string validator_desc) const
 Specify the type string.
 
CLI11_NODISCARD std::string get_description () const
 Generate type description information for the Validator.
 
Validatorname (std::string validator_name)
 Specify the type string.
 
CLI11_NODISCARD Validator name (std::string validator_name) const
 Specify the type string.
 
CLI11_NODISCARD const std::string & get_name () const
 Get the name of the Validator.
 
Validatoractive (bool active_val=true)
 Specify whether the Validator is active or not.
 
CLI11_NODISCARD Validator active (bool active_val=true) const
 Specify whether the Validator is active or not.
 
Validatornon_modifying (bool no_modify=true)
 Specify whether the Validator can be modifying or not.
 
Validatorapplication_index (int app_index)
 Specify the application index of a validator.
 
CLI11_NODISCARD Validator application_index (int app_index) const
 Specify the application index of a validator.
 
CLI11_NODISCARD int get_application_index () const
 Get the current value of the application index.
 
CLI11_NODISCARD bool get_active () const
 Get a boolean if the validator is active.
 
CLI11_NODISCARD bool get_modifying () const
 Get a boolean if the validator is allowed to modify the input returns true if it can modify the input.
 
Validator operator& (const Validator &other) const
 Combining validators is a new validator.
 
Validator operator| (const Validator &other) const
 Combining validators is a new validator.
 
Validator operator! () const
 Create a validator that fails when a given validator succeeds.
 

Additional Inherited Members

- Protected Member Functions inherited from Validator
 Validator (std::string validator_desc, std::function< std::string(std::string &)> func)
 
- Protected Attributes inherited from Validator
std::function< std::string()> desc_function_ {[]() { return std::string{}; }}
 This is the description function, if empty the description_ will be used.
 
std::function< std::string(std::string &)> func_ {[](std::string &) { return std::string{}; }}
 This is the base function that is to be called.
 
std::string name_ {}
 The name for search purposes of the Validator.
 
int application_index_ = -1
 A Validator will only apply to an indexed value (-1 is all elements)
 
bool active_ {true}
 Enable for Validator to allow it to be disabled if need be.
 
bool non_modifying_ {false}
 specify that a validator should not modify the input
 

Detailed Description

Converts a human-readable size string (with unit literal) to uin64_t size.

Example: "100" => 100 "1 b" => 100 "10Kb" => 10240 // you can configure this to be interpreted as kilobyte (*1000) or kibibyte (*1024) "10 KB" => 10240 "10 kb" => 10240 "10 kib" => 10240 // *i, *ib are always interpreted as *bibyte (*1024) "10kb" => 10240 "2 MB" => 2097152 "2 EiB" => 2^61 // Units up to exibyte are supported

Definition at line 3621 of file CLI11.h.

Member Typedef Documentation

◆ result_t

using result_t = std::uint64_t

Definition at line 3623 of file CLI11.h.

Constructor & Destructor Documentation

◆ AsSizeValue()

CLI11_INLINE AsSizeValue ( bool  kb_is_1000)
explicit

If kb_is_1000 is true, interpret 'kb', 'k' as 1000 and 'kib', 'ki' as 1024 (same applies to higher order units as well).

Otherwise, interpret all literals as factors of 1024. The first option is formally correct, but the second interpretation is more wide-spread (see https://en.wikipedia.org/wiki/Binary_prefix).

Definition at line 3891 of file CLI11.h.


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