1 //===- ExtractAPI/Serialization/SerializerBase.h ----------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// 9 /// \file 10 /// This file defines the ExtractAPI APISerializer interface. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H 15 #define LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H 16 17 #include "clang/ExtractAPI/API.h" 18 #include "llvm/Support/raw_ostream.h" 19 20 namespace clang { 21 namespace extractapi { 22 23 /// Common options to customize the serializer output. 24 struct APISerializerOption { 25 /// Do not include unnecessary whitespaces to save space. 26 bool Compact; 27 }; 28 29 /// The base interface of serializers for API information. 30 class APISerializer { 31 public: 32 /// Serialize the API information to \p os. 33 virtual void serialize(raw_ostream &os) = 0; 34 35 protected: 36 const APISet &API; 37 38 /// The product name of API. 39 /// 40 /// Note: This should be used for populating metadata about the API. 41 StringRef ProductName; 42 43 APISerializerOption Options; 44 45 public: 46 APISerializer() = delete; 47 APISerializer(const APISerializer &) = delete; 48 APISerializer(APISerializer &&) = delete; 49 APISerializer &operator=(const APISerializer &) = delete; 50 APISerializer &operator=(APISerializer &&) = delete; 51 52 protected: 53 APISerializer(const APISet &API, StringRef ProductName, 54 APISerializerOption Options = {}) 55 : API(API), ProductName(ProductName), Options(Options) {} 56 57 virtual ~APISerializer() = default; 58 }; 59 60 } // namespace extractapi 61 } // namespace clang 62 63 #endif // LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H 64