blob: 5b9c94876ce51f499efe4c984f11aad16e7c9d66 [file] [log] [blame]
Steven Morelandf1a35f72016-08-17 08:41:49 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef DECLARATION_H_
18#define DECLARATION_H_
19
20#include <android-base/macros.h>
21#include <android-base/logging.h>
22#include <string>
23#include <vector>
Iliyan Malcheva72e0d22016-09-09 11:03:08 -070024#include <hidl-util/Formatter.h>
Steven Morelandf1a35f72016-08-17 08:41:49 -070025
26namespace android {
27
28struct AST;
29
30struct Declaration {
31 Declaration(const std::string &name);
32 virtual ~Declaration();
33
34 const std::string &getName() const;
Steven Moreland95b46232016-09-20 14:46:55 -070035 virtual void setName(const std::string &name);
36
37 void forceCamelCase();
38 void forcePascalCase();
Yifan Hong42009032016-09-29 09:38:15 -070039 void forceUpperSnakeCase();
Steven Morelandf1a35f72016-08-17 08:41:49 -070040
41 const std::string& getComment() const;
42 void setComment(const std::string &comment);
43
44 std::string getInterfaceName() const;
45
46 void generateCommentText(Formatter &out) const;
47
48 virtual const std::string decType() const = 0;
49
50 /* for example "int test;" */
51 virtual void generateSource(Formatter &out) const = 0;
52
53 /* for example "int test" in fun(int test, float jeff) */
54 virtual void generateParameterSource(Formatter &out) const;
55
56 virtual void processContents(AST &ast) = 0;
57
58private:
59 std::string mName;
60 std::string mComment;
61
62 DISALLOW_COPY_AND_ASSIGN(Declaration);
63};
64
65} // namespace android
66
Yifan Hong42009032016-09-29 09:38:15 -070067#endif // DECLARATION_H_