Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
parse_units.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/parse_units.h
10//! @brief Parse units like duration, size, etc.
11
12#ifndef ROC_CORE_PARSE_UNITS_H_
13#define ROC_CORE_PARSE_UNITS_H_
14
15#include "roc_core/attributes.h"
16#include "roc_core/time.h"
17
18namespace roc {
19namespace core {
20
21//! Parse duration from string.
22//!
23//! @remarks
24//! The input string should be in one of the following forms:
25//! - "<number>ns"
26//! - "<number>us"
27//! - "<number>ms"
28//! - "<number>s"
29//! - "<number>m"
30//! - "<number>h"
31//!
32//! @returns
33//! false if string can't be parsed.
35
36//! Parse size from string.
37//!
38//! @remarks
39//! The input string should be in one of the following forms:
40//! - "<number>"
41//! - "<number>K"
42//! - "<number>M"
43//! - "<number>G"
44//!
45//! @returns
46//! false if string can't be parsed.
47ROC_ATTR_NODISCARD bool parse_size(const char* string, size_t& result);
48
49} // namespace core
50} // namespace roc
51
52#endif // ROC_CORE_PARSE_UNITS_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
bool parse_size(const char *string, size_t &result)
Parse size from string.
bool parse_duration(const char *string, nanoseconds_t &result)
Parse duration from string.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
Root namespace.
Time definitions.