Debian Codegraph @

src/status/DavixStatus.hpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2019
4 * Author: Georgios Bitzes <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #ifndef DAVIX_STATUS_OBJECT_HPP
23 #define DAVIX_STATUS_OBJECT_HPP
24
25 #include <status/DavixErrorInternal.hpp>
26
27 namespace Davix {
28
29 class Status {
30 public:
31 //----------------------------------------------------------------------------
32 // Empty constructor - OK status, with empty error message, and empty scope
33 //----------------------------------------------------------------------------
34 Status();
35
36 //----------------------------------------------------------------------------
37 // Destructor
38 //----------------------------------------------------------------------------
39 ~Status();
40
41 //----------------------------------------------------------------------------
42 // Copy constructor
43 //----------------------------------------------------------------------------
44 Status(const Status &other);
45
46 //----------------------------------------------------------------------------
47 // Copy assignment operator
48 //----------------------------------------------------------------------------
49 Status& operator=(const Status &other);
50
51 //----------------------------------------------------------------------------
52 // Constructor - specify scope, errno, and error message
53 //----------------------------------------------------------------------------
54 Status(const std::string &scope, StatusCode::Code errcode, const std::string& errmsg);
55
56 //----------------------------------------------------------------------------
57 // Constructor from DavixError**
58 //----------------------------------------------------------------------------
59 Status(DavixError** err);
60
61 //----------------------------------------------------------------------------
62 // Check if status indicates any error
63 //----------------------------------------------------------------------------
64 bool ok() const;
65
66 //----------------------------------------------------------------------------
67 // Check if status indicates any error - as integer, 0 for OK, -1 for not-ok
68 //----------------------------------------------------------------------------
69 bool okAsInt() const;
70
71 //----------------------------------------------------------------------------
72 // Get status code
73 //----------------------------------------------------------------------------
74 StatusCode::Code getCode() const;
75
76 //----------------------------------------------------------------------------
77 // Get error message
78 //----------------------------------------------------------------------------
79 std::string getErrorMessage() const;
80
81 //----------------------------------------------------------------------------
82 // Get scope
83 //----------------------------------------------------------------------------
84 std::string getScope() const;
85
86 //----------------------------------------------------------------------------
87 // Clear contents
88 //----------------------------------------------------------------------------
89 void clear();
90
91 //----------------------------------------------------------------------------
92 // To DavixError (ugh)
93 //----------------------------------------------------------------------------
94 int toDavixError(DavixError **err) const;
95
96 private:
97 DavixErrorInternal* d_ptr;
98 };
99
100 }
101
102 #endif