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 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 
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.
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  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
Convert errno to string.
Definition: errno_to_str.h:23
errno_to_str(int err)
Construct from custom error code.
errno_to_str()
Construct from errno.
const char * c_str() const
Get error message.
Definition: errno_to_str.h:32
Root namespace.
Non-copyable object.