Reorganise to remove redundant folder
[profile/ivi/common-api-dbus-runtime.git] / src / CommonAPI / DBus / DBusError.cpp
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "DBusError.h"
5
6 #include <cassert>
7 #include <cstring>
8
9 namespace CommonAPI {
10 namespace DBus {
11
12
13 DBusError::DBusError() {
14         dbus_error_init(&libdbusError_);
15 }
16
17 DBusError::~DBusError() {
18         dbus_error_free(&libdbusError_);
19 }
20
21 DBusError::operator bool() const {
22         return dbus_error_is_set(&libdbusError_);
23 }
24
25 void DBusError::clear() {
26         dbus_error_free(&libdbusError_);
27 }
28
29 std::string DBusError::getName() const {
30         assert(*this);
31
32         return std::string(libdbusError_.name);
33 }
34
35 std::string DBusError::getMessage() const {
36         assert(*this);
37
38         return std::string(libdbusError_.message);
39 }
40
41 } // namespace DBus
42 } // namespace CommonAPI