Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
errno_to_str.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 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/target_posix/roc_core/errno_to_str.h
10//! @brief Convert errno to string.
11
12#ifndef ROC_CORE_ERRNO_TO_STR_H_
13#define ROC_CORE_ERRNO_TO_STR_H_
14
16
17namespace roc {
18namespace core {
19
20//! Convert errno to string.
21//! @remarks
22//! Uses strerror_r(), which is thread-safe unlike strerror().
23class errno_to_str : public NonCopyable<> {
24public:
25 //! Construct from errno.
27
28 //! Construct from custom error code.
29 explicit errno_to_str(int err);
30
31 //! Get error message.
32 const char* c_str() const {
33 return buffer_;
34 }
35
36private:
37 void format_(int err);
38
39 char buffer_[96];
40};
41
42} // namespace core
43} // namespace roc
44
45#endif // ROC_CORE_ERRNO_TO_STR_H_
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Convert errno to string.
const char * c_str() const
Get error message.
errno_to_str(int err)
Construct from custom error code.
errno_to_str()
Construct from errno.
Root namespace.
Non-copyable object.