Annotation.h revision 019d21db821ee4ae6dd3858174a0a5cee4d33c25
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 ANNOTATION_H_ 18 19#define ANNOTATION_H_ 20 21#include <android-base/macros.h> 22#include <map> 23#include <string> 24 25#include "ConstantExpression.h" 26 27namespace android { 28 29struct Formatter; 30 31struct AnnotationParam { 32 AnnotationParam(const std::string &name, 33 std::vector<std::string> *values); 34 AnnotationParam(const std::string &name, 35 std::vector<ConstantExpression *> *values); 36 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*>; 46 47struct Annotation { 48 Annotation(const char *name, AnnotationParamVector *params); 49 50 std::string name() const; 51 const AnnotationParamVector ¶ms() const; 52 const AnnotationParam *getParam(const std::string &name) const; 53 54 void dump(Formatter &out) const; 55 56private: 57 std::string mName; 58 AnnotationParamVector *mParams; 59 60 DISALLOW_COPY_AND_ASSIGN(Annotation); 61}; 62 63} // namespace android 64 65#endif // ANNOTATION_H_ 66