Files
scylladb/util/conversions.hh
Avi Kivity cca41658aa util: add conversions library
At this time, support parsing a memory size (e.g "2T" == 2 << 40).
2014-10-12 16:34:16 +03:00

25 lines
491 B
C++

/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*/
#ifndef CONVERSIONS_HH_
#define CONVERSIONS_HH_
#include <cstdlib>
#include <string>
// Convert a string to a memory size, allowing binary SI
// suffixes (intentionally, even though SI suffixes are
// decimal, to follow existing usage).
//
// "5" -> 5
// "4k" -> (4 << 10)
// "8M" -> (8 << 20)
// "7G" -> (7 << 30)
// "1T" -> (1 << 40)
// anything else: exception
size_t parse_memory_size(std::string s);
#endif /* CONVERSIONS_HH_ */