Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
errno_to_str.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Roc 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 
15 #include "roc_core/noncopyable.h"
16 
17 namespace roc {
18 namespace core {
19 
20 //! Convert errno to string.
21 //! @remarks
22 //! Uses strerror_r(), which is thread-safe unlike strerror().
23 class errno_to_str : public NonCopyable<> {
24 public:
25  //! Construct from errno.
26  errno_to_str();
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 
36 private:
37  char buffer_[96];
38 };
39 
40 } // namespace core
41 } // namespace roc
42 
43 #endif // ROC_CORE_ERRNO_TO_STR_H_
Convert errno to string.
Definition: errno_to_str.h:23
Root namespace.
errno_to_str()
Construct from errno.
Base class for non-copyable objects.
Definition: noncopyable.h:23
const char * c_str() const
Get error message.
Definition: errno_to_str.h:32
Non-copyable object.