libptpmgmt 2.0
libptpmgmt library that provides the functionality of linuxptp pmc
Loading...
Searching...
No Matches
err.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later
2 SPDX-FileCopyrightText: Copyright © 2021 Erez Geva <ErezGeva2@gmail.com> */
3
14#ifndef __PTPMGMT_ERR_H
15#define __PTPMGMT_ERR_H
16
17#include "name.h"
18
19#ifdef __cplusplus
20__PTPMGMT_NAMESPACE_BEGIN
21
28class Error
29{
30 private:
31 int m_errnom = 0;
32 int m_line = 0;
33 std::string m_file;
34 std::string m_msg;
35 std::string m_func;
36 std::string m_fmsg;
37 std::string m_emsg;
38 void doClear();
39 void doError(bool use_errno, const char *file, int line, const char *func,
40 const std::string &msg);
41 const std::string &fetch();
42 static Error &getCur();
43 public:
44
45 #ifndef SWIG
47 static void perror(const char *file, int line, const char *func,
48 const std::string &msg)
49 { getCur().doError(true, file, line, func, msg); }
50 static void error(const char *file, int line, const char *func,
51 const std::string &msg)
52 { getCur().doError(false, file, line, func, msg); }
53 static std::string doFormat(const char *format, ...);
54 static void clear() { getCur().m_line = 0; }
56 #endif /* SWIG */
57
62 static bool isError();
67 static const std::string &getError();
72 static const std::string &getFile();
77 static int getFileLine();
82 static const std::string &getFunc();
87 static int getErrno();
93 static const std::string &getMsg();
99 static const std::string &getErrnoMsg();
100};
101
102__PTPMGMT_NAMESPACE_END
103#else /* __cplusplus */
104#include "c/err.h"
105#endif /* __cplusplus */
106
107#endif /* __PTPMGMT_ERR_H */
Get Last Error happend in library, C API.
Keep last error.
Definition err.h:29
static const std::string & getErrnoMsg()
static const std::string & getError()
static const std::string & getFile()
static bool isError()
static int getFileLine()
static const std::string & getMsg()
static int getErrno()
static const std::string & getFunc()
Define name space.