blob: 063b8e4f4767880a3f88e0f3da808098b395a388 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -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
Andreas Huber3599d922016-08-09 10:42:57 -070017#ifndef ANNOTATION_H_
18
19#define ANNOTATION_H_
20
21#include <android-base/macros.h>
Steven Morelandd537ab02016-09-12 10:32:01 -070022#include <map>
Andreas Huber3599d922016-08-09 10:42:57 -070023#include <string>
Andreas Huber3599d922016-08-09 10:42:57 -070024
Yifan Hongf24fa852016-09-23 11:03:15 -070025#include "ConstantExpression.h"
26
Andreas Huber3599d922016-08-09 10:42:57 -070027namespace android {
28
29struct Formatter;
Steven Morelandd537ab02016-09-12 10:32:01 -070030
31struct AnnotationParam {
32 AnnotationParam(const std::string &name,
33 std::vector<std::string> *values);
Yifan Hongf24fa852016-09-23 11:03:15 -070034 AnnotationParam(const std::string &name,
35 std::vector<ConstantExpression *> *values);
Steven Morelandd537ab02016-09-12 10:32:01 -070036
37 const std::string &getName() const;
38 const std::vector<std::string> *getValues() const;
39
40private:
41 const std::string mName;
42 std::vector<std::string> *mValues;
43};
44
45using AnnotationParamVector = std::vector<const AnnotationParam*>;
Andreas Huber3599d922016-08-09 10:42:57 -070046
47struct Annotation {
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070048 Annotation(const char *name, AnnotationParamVector *params);
Andreas Huber3599d922016-08-09 10:42:57 -070049
50 std::string name() const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070051 const AnnotationParamVector &params() const;
Andreas Huber019d21d2016-10-03 12:59:47 -070052 const AnnotationParam *getParam(const std::string &name) const;
Andreas Huber3599d922016-08-09 10:42:57 -070053
54 void dump(Formatter &out) const;
55
56private:
57 std::string mName;
Steven Morelandd537ab02016-09-12 10:32:01 -070058 AnnotationParamVector *mParams;
Andreas Huber3599d922016-08-09 10:42:57 -070059
60 DISALLOW_COPY_AND_ASSIGN(Annotation);
61};
62
63} // namespace android
64
65#endif // ANNOTATION_H_