• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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>
24 #include <hidl-util/Formatter.h>
25 
26 namespace android {
27 
28 struct AST;
29 
30 struct Declaration {
31     Declaration(const std::string &name);
32     virtual ~Declaration();
33 
34     const std::string &getName() const;
35     virtual void setName(const std::string &name);
36 
37     void forceCamelCase();
38     void forcePascalCase();
39     void forceUpperSnakeCase();
40 
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 
58 private:
59     std::string mName;
60     std::string mComment;
61 
62     DISALLOW_COPY_AND_ASSIGN(Declaration);
63 };
64 
65 }  // namespace android
66 
67 #endif  // DECLARATION_H_
68