/strigi-0.7.7/strigidaemon/bin/daemon/dbus/dbuscpp/dbusmessagereader.h
C Header | 73 lines | 49 code | 5 blank | 19 comment | 1 complexity | 161e83a6ee5cfccd2857e183ba5dbd93 MD5 | raw file
Possible License(s): LGPL-2.0
1/* This file is part of Strigi Desktop Search
2 *
3 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef DBUSMESSAGEREADER_H
21#define DBUSMESSAGEREADER_H
22
23#define DBUS_API_SUBJECT_TO_CHANGE 1
24#include <dbus/dbus.h>
25
26#include <set>
27#include <map>
28#include <string>
29#include <vector>
30#include <strigi/strigiconfig.h>
31#ifdef HAVE_STDINT_H
32#include <stdint.h>
33#endif
34
35class DBusMessageReader {
36private:
37 DBusMessage* msg;
38 bool ok;
39
40public:
41 DBusMessageIter it;
42 explicit DBusMessageReader(DBusMessage* msg);
43 explicit DBusMessageReader(const DBusMessageReader& r)
44 :msg(r.msg), ok(r.ok) {
45 dbus_message_ref(msg);
46 }
47 ~DBusMessageReader() {
48 close();
49 }
50 void close() {
51 if (msg) {
52 dbus_message_unref(msg);
53 msg = 0;
54 }
55 ok = false;
56 }
57 DBusMessageReader& operator>>(std::set<std::string>& s);
58 DBusMessageReader& operator>>(std::vector<std::string>& s);
59 DBusMessageReader& operator>>(std::vector<char>& s);
60 DBusMessageReader& operator>>(std::vector<int32_t>& s);
61 DBusMessageReader& operator>>(std::vector<uint32_t>& s);
62 DBusMessageReader& operator>>(std::string& s);
63 DBusMessageReader& operator>>(dbus_int32_t& s);
64 DBusMessageReader& operator>>(dbus_uint32_t& s);
65 DBusMessageReader& operator>>(dbus_uint64_t& s);
66 DBusMessageReader& operator>>(dbus_int64_t& s);
67 DBusMessageReader& operator>>(std::multimap<int, std::string>&);
68 DBusMessageReader& operator>>(std::vector<std::pair<bool, std::string> >&);
69 bool isOk() const { return ok; }
70 bool atEnd();
71};
72
73#endif