1 /* 2 * Copyright (C) 2021, 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 #pragma once 17 18 #include <iostream> 19 #include <optional> 20 #include <string> 21 #include <vector> 22 23 namespace android { 24 namespace aidl { 25 26 // Represents a single comment 27 struct Comment { 28 enum class Type { LINE, BLOCK }; 29 Type type; 30 std::string body; 31 32 Comment(const std::string& body); 33 34 // for GTest assertions 35 friend inline bool operator==(const Comment& lhs, const Comment& rhs) { 36 return lhs.body == rhs.body; 37 } 38 friend std::ostream& operator<<(std::ostream& out, const Comment& c) { return out << c.body; } 39 }; 40 41 using Comments = std::vector<Comment>; 42 43 bool HasHideInComments(const Comments& comments); 44 45 struct Deprecated { 46 std::string note; // can be empty("") 47 }; 48 49 std::optional<Deprecated> FindDeprecated(const Comments& comments); 50 51 std::string FormatCommentsForJava(const Comments& comments); 52 53 } // namespace aidl 54 } // namespace android