Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
parse_duration.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_duration.h
10//! @brief Parse duration.
11
12#ifndef ROC_CORE_PARSE_DURATION_H_
13#define ROC_CORE_PARSE_DURATION_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.
34ROC_ATTR_NODISCARD bool parse_duration(const char* string, nanoseconds_t& result);
35
36} // namespace core
37} // namespace roc
38
39#endif // ROC_CORE_PARSE_DURATION_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition: attributes.h:31
ROC_ATTR_NODISCARD 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.