PageRenderTime 45ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/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. #define DBUS_API_SUBJECT_TO_CHANGE 1
  23. #include <dbus/dbus.h>
  24. #include <set>
  25. #include <map>
  26. #include <string>
  27. #include <vector>
  28. #include <strigi/strigiconfig.h>
  29. #ifdef HAVE_STDINT_H
  30. #include <stdint.h>
  31. #endif
  32. class DBusMessageReader {
  33. private:
  34. DBusMessage* msg;
  35. bool ok;
  36. public:
  37. DBusMessageIter it;
  38. explicit DBusMessageReader(DBusMessage* msg);
  39. explicit DBusMessageReader(const DBusMessageReader& r)
  40. :msg(r.msg), ok(r.ok) {
  41. dbus_message_ref(msg);
  42. }
  43. ~DBusMessageReader() {
  44. close();
  45. }
  46. void close() {
  47. if (msg) {
  48. dbus_message_unref(msg);
  49. msg = 0;
  50. }
  51. ok = false;
  52. }
  53. DBusMessageReader& operator>>(std::set<std::string>& s);
  54. DBusMessageReader& operator>>(std::vector<std::string>& s);
  55. DBusMessageReader& operator>>(std::vector<char>& s);
  56. DBusMessageReader& operator>>(std::vector<int32_t>& s);
  57. DBusMessageReader& operator>>(std::vector<uint32_t>& s);
  58. DBusMessageReader& operator>>(std::string& s);
  59. DBusMessageReader& operator>>(dbus_int32_t& s);
  60. DBusMessageReader& operator>>(dbus_uint32_t& s);
  61. DBusMessageReader& operator>>(dbus_uint64_t& s);
  62. DBusMessageReader& operator>>(dbus_int64_t& s);
  63. DBusMessageReader& operator>>(std::multimap<int, std::string>&);
  64. DBusMessageReader& operator>>(std::vector<std::pair<bool, std::string> >&);
  65. bool isOk() const { return ok; }
  66. bool atEnd();
  67. };
  68. #endif