tlx
parse_si_iec_units.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * tlx/string/parse_si_iec_units.hpp
3 *
4 * Part of tlx - http://panthema.net/tlx
5 *
6 * Copyright (C) 2016-2017 Timo Bingmann <tb@panthema.net>
7 *
8 * All rights reserved. Published under the Boost Software License, Version 1.0
9 ******************************************************************************/
10
11#ifndef TLX_STRING_PARSE_SI_IEC_UNITS_HEADER
12#define TLX_STRING_PARSE_SI_IEC_UNITS_HEADER
13
14#include <string>
15
16namespace tlx {
17
18//! \addtogroup tlx_string
19//! \{
20
21/*!
22 * Parse a string like "343KB" or "44 GiB" into the corresponding size in
23 * bytes. Returns the number of bytes and sets ok = true if the string could be
24 * parsed correctly. If no units indicator is given, use def_unit in k/m/g/t/p
25 * (powers of ten) or in K/M/G/T/P (power of two).
26 */
28 const char* str, uint64_t* out_size, char default_unit = 0);
29
30/*!
31 * Parse a string like "343KB" or "44 GiB" into the corresponding size in
32 * bytes. Returns the number of bytes and sets ok = true if the string could be
33 * parsed correctly. If no units indicator is given, use def_unit in k/m/g/t/p
34 * (powers of ten) or in K/M/G/T/P (power of two).
35 */
37 const std::string& str, uint64_t* out_size, char default_unit = 0);
38
39//! \}
40
41} // namespace tlx
42
43#endif // !TLX_STRING_PARSE_SI_IEC_UNITS_HEADER
44
45/******************************************************************************/
bool parse_si_iec_units(const char *str, uint64_t *out_size, char default_unit)
Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes.