Andreas Huber | 1aec397 | 2016-08-26 09:26:32 -0700 | [diff] [blame] | 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 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 17 | #ifndef ANNOTATION_H_ |
| 18 | |
| 19 | #define ANNOTATION_H_ |
| 20 | |
| 21 | #include <android-base/macros.h> |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 22 | #include <map> |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 23 | #include <string> |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 24 | |
Yifan Hong | f24fa85 | 2016-09-23 11:03:15 -0700 | [diff] [blame] | 25 | #include "ConstantExpression.h" |
| 26 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 27 | namespace android { |
| 28 | |
| 29 | struct Formatter; |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 30 | |
| 31 | struct AnnotationParam { |
| 32 | AnnotationParam(const std::string &name, |
| 33 | std::vector<std::string> *values); |
Yifan Hong | f24fa85 | 2016-09-23 11:03:15 -0700 | [diff] [blame] | 34 | AnnotationParam(const std::string &name, |
| 35 | std::vector<ConstantExpression *> *values); |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 36 | |
| 37 | const std::string &getName() const; |
| 38 | const std::vector<std::string> *getValues() const; |
| 39 | |
| 40 | private: |
| 41 | const std::string mName; |
| 42 | std::vector<std::string> *mValues; |
| 43 | }; |
| 44 | |
| 45 | using AnnotationParamVector = std::vector<const AnnotationParam*>; |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 46 | |
| 47 | struct Annotation { |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 48 | Annotation(const char *name, AnnotationParamVector *params); |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 49 | |
| 50 | std::string name() const; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 51 | const AnnotationParamVector ¶ms() const; |
Andreas Huber | 019d21d | 2016-10-03 12:59:47 -0700 | [diff] [blame] | 52 | const AnnotationParam *getParam(const std::string &name) const; |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 53 | |
| 54 | void dump(Formatter &out) const; |
| 55 | |
| 56 | private: |
| 57 | std::string mName; |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 58 | AnnotationParamVector *mParams; |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 59 | |
| 60 | DISALLOW_COPY_AND_ASSIGN(Annotation); |
| 61 | }; |
| 62 | |
| 63 | } // namespace android |
| 64 | |
| 65 | #endif // ANNOTATION_H_ |