Scarab  v3.4.3
Project 8 C++ Utility Library
Public Types | Public Member Functions | Static Private Member Functions | List of all members
AsSizeValue Class Reference

#include <CLI11.hpp>

Inheritance diagram for AsSizeValue:
Inheritance graph

Public Types

using result_t = 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
}
 

Public Member Functions

 AsSizeValue (bool kb_is_1000)
 
- 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 ()=default
 
 Validator (std::string validator_desc)
 Construct a Validator with just the description string. More...
 
 Validator (std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
 
Validatoroperation (std::function< std::string(std::string &)> op)
 Set the Validator operation function. More...
 
std::string operator() (std::string &str) const
 
std::string operator() (const std::string &str) const
 
Validatordescription (std::string validator_desc)
 Specify the type string. More...
 
std::string get_description () const
 Generate type description information for the Validator. More...
 
Validatorname (std::string validator_name)
 Specify the type string. More...
 
const std::string & get_name () const
 Get the name of the Validator. More...
 
Validatoractive (bool active_val=true)
 Specify whether the Validator is active or not. More...
 
Validatornon_modifying (bool no_modify=true)
 Specify whether the Validator can be modifying or not. More...
 
bool get_active () const
 Get a boolean if the validator is active. More...
 
bool get_modifying () const
 Get a boolean if the validator is allowed to modify the input returns true if it can modify the input. More...
 
Validator operator & (const Validator &other) const
 
Validator operator| (const Validator &other) const
 
Validator operator! () const
 Create a validator that fails when a given validator succeeds. More...
 

Static Private Member Functions

static std::map< std::string, result_tinit_mapping (bool kb_is_1000)
 Get <size unit, factor> mapping. More...
 
static std::map< std::string, result_tget_mapping (bool kb_is_1000)
 Cache calculated mapping. More...
 

Additional Inherited Members

- 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. More...
 
std::function< std::string(std::string &)> func_ {[](std::string &) { return std::string{}; }}
 
std::string name_
 The name for search purposes of the Validator. More...
 
bool active_ {true}
 Enable for Validator to allow it to be disabled if need be. More...
 
bool non_modifying_ {false}
 specify that a validator should not modify the input More...
 

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 2410 of file CLI11.hpp.

Member Typedef Documentation

◆ result_t

using result_t = uint64_t

Definition at line 2412 of file CLI11.hpp.

Constructor & Destructor Documentation

◆ AsSizeValue()

AsSizeValue ( bool  kb_is_1000)
inlineexplicit

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 2421 of file CLI11.hpp.

Member Function Documentation

◆ get_mapping()

static std::map<std::string, result_t> get_mapping ( bool  kb_is_1000)
inlinestaticprivate

Cache calculated mapping.

Definition at line 2450 of file CLI11.hpp.

◆ init_mapping()

static std::map<std::string, result_t> init_mapping ( bool  kb_is_1000)
inlinestaticprivate

Get <size unit, factor> mapping.

Definition at line 2431 of file CLI11.hpp.


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