[go: nahoru, domu]

blob: 258bf606bde20d2457adbceace600e869cd59d95 [file] [log] [blame]
Avi Drissmanf75e37f2022-09-13 19:40:311// Copyright 2012 The Chromium Authors
satorux@chromium.orga51076112011-08-17 20:58:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef DBUS_SCOPED_DBUS_ERROR_H_
6#define DBUS_SCOPED_DBUS_ERROR_H_
satorux@chromium.orga51076112011-08-17 20:58:127
8#include <dbus/dbus.h>
9
Hidehiko Abe3afb59a2023-07-06 07:34:3810namespace dbus::internal {
satorux@chromium.orga51076112011-08-17 20:58:1211
12// Utility class to ensure that DBusError is freed.
Hidehiko Abe3afb59a2023-07-06 07:34:3813class ScopedDBusError {
satorux@chromium.orga51076112011-08-17 20:58:1214 public:
avakulenko7c5b40c2014-09-24 18:47:5215 // Do not inline methods that call dbus_error_xxx() functions.
16 // See http://crbug.com/416628
17 ScopedDBusError();
18 ~ScopedDBusError();
satorux@chromium.orga51076112011-08-17 20:58:1219
20 DBusError* get() { return &error_; }
avakulenko7c5b40c2014-09-24 18:47:5221 bool is_set() const;
Hidehiko Abeac7a3c52023-07-06 11:18:1022 const char* name() const { return error_.name; }
23 const char* message() const { return error_.message; }
satorux@chromium.orga51076112011-08-17 20:58:1224
25 private:
26 DBusError error_;
27};
28
Hidehiko Abe3afb59a2023-07-06 07:34:3829} // namespace dbus::internal
satorux@chromium.orga51076112011-08-17 20:58:1230
31#endif // DBUS_SCOPED_DBUS_ERROR_H_