blob: 707d3a622de06cc968f3e1207cd1c7b2dec8af88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_BINDINGS_DBUS_SIGNATURE_H_
#define CHROMEOS_DBUS_BINDINGS_DBUS_SIGNATURE_H_
#include <string>
#include <vector>
#include <base/macros.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
namespace chromeos_dbus_bindings {
class DbusSignature {
public:
DbusSignature();
virtual ~DbusSignature() = default;
// Returns a C++ typename in |output| for a D-Bus signature in |signature|
// and returns true on success. Returns false otherwise.
bool Parse(const std::string& signature, std::string* output);
void set_object_path_typename(const std::string& object_path_typename) {
object_path_typename_ = object_path_typename;
}
private:
friend class DbusSignatureTest;
FRIEND_TEST(DbusSignatureTest, DefaultObjectPathTypename);
FRIEND_TEST(DbusSignatureTest, ParseSuccesses);
// Typenames are C++ syntax types.
static const char kArrayTypename[];
static const char kBooleanTypename[];
static const char kByteTypename[];
static const char kDefaultObjectPathTypename[];
static const char kDictTypename[];
static const char kDoubleTypename[];
static const char kSigned16Typename[];
static const char kSigned32Typename[];
static const char kSigned64Typename[];
static const char kStringTypename[];
static const char kUnixFdTypename[];
static const char kUnsigned16Typename[];
static const char kUnsigned32Typename[];
static const char kUnsigned64Typename[];
static const char kVariantTypename[];
// Returns the C++ type name for the next D-Bus signature in the string at
// |signature| in |output|, as well as the next position within the string
// that parsing should continue |next|. It is not an error to pass a
// pointer to |signature| or nullptr as |next|. Returns true on success.
bool GetTypenameForSignature(std::string::const_iterator signature,
std::string::const_iterator end,
std::string::const_iterator* next,
std::string* output);
// Utility task for GetTypenameForSignature() which handles array objects
// and decodes them into a map or vector depending on the encoded sub-elements
// in the array. The arguments and return values are the same
// as GetTypenameForSignature().
bool GetArrayTypenameForSignature(std::string::const_iterator signature,
std::string::const_iterator end,
std::string::const_iterator* next,
std::string* output);
// The C++ typename to be used for D-Bus object pathnames.
std::string object_path_typename_;
DISALLOW_COPY_AND_ASSIGN(DbusSignature);
};
} // namespace chromeos_dbus_bindings
#endif // CHROMEOS_DBUS_BINDINGS_DBUS_SIGNATURE_H_
|