blob: 250557c5025d4b099c65a7c45d79f054a2afd099 [file] [log] [blame]
Paul Stewartb9b3f9d2014-09-10 15:12:39 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_
6#define CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_
7
8#include <string>
9#include <vector>
10
11#include <base/macros.h>
12
13#include "chromeos-dbus-bindings/indented_text.h"
14
15namespace base {
16
17class FilePath;
18
19} // namespace base
20
21namespace chromeos_dbus_bindings {
22
23class IndentedText;
24struct Interface;
25
26class AdaptorGenerator {
27 public:
28 AdaptorGenerator() = default;
29 virtual ~AdaptorGenerator() = default;
30
31 bool GenerateAdaptor(const Interface& interface,
32 const base::FilePath& output_file);
33
34 private:
35 friend class AdaptorGeneratorTest;
36
37 // Create a unique header guard string to protect multiple includes of header.
38 static std::string GenerateHeaderGuard(const std::string& filename,
39 const std::string& interface_name);
40
41 // Generates the constructor for the adaptor.
42 static void AddConstructor(const Interface& interface,
43 const std::string& class_name,
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070044 IndentedText *text);
45
46 // Generates the method interface class.
47 static void AddMethodInterface(const Interface& interface,
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070048 IndentedText *text);
49
50 // Returns a vector of nesting namepsaces.
51 static bool GetNamespacesAndClassName(const std::string& interface_name,
52 std::vector<std::string>* namespaces,
53 std::string* class_name);
54
55 // Used to decide whether the argument should be a const reference.
56 static bool IsIntegralType(const std::string& type);
57
58 DISALLOW_COPY_AND_ASSIGN(AdaptorGenerator);
59};
60
61} // namespace chromeos_dbus_bindings
62
63#endif // CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_