1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef META_SRC_SERIALIZATION_BACKEND_DEBUG_OUTPUT_H 17 #define META_SRC_SERIALIZATION_BACKEND_DEBUG_OUTPUT_H 18 19 #include <meta/base/namespace.h> 20 #include <meta/interface/builtin_objects.h> 21 #include <meta/interface/serialization/intf_ser_output.h> 22 23 #include "base_object.h" 24 META_BEGIN_NAMESPACE()25META_BEGIN_NAMESPACE() 26 namespace Serialization { 27 28 class DebugOutput : public IntroduceInterfaces<BaseObject, ISerOutput, ISerNodeVisitor> { 29 META_OBJECT(DebugOutput, ClassId::DebugOutput, IntroduceInterfaces) 30 public: 31 BASE_NS::string Process(const ISerNode::Ptr& tree) override; 32 33 private: 34 void Visit(const IRootNode&) override; 35 void Visit(const INilNode&) override; 36 void Visit(const IObjectNode&) override; 37 void Visit(const IArrayNode&) override; 38 void Visit(const IMapNode&) override; 39 void Visit(const IBuiltinValueNode<bool>&) override; 40 void Visit(const IBuiltinValueNode<double>&) override; 41 void Visit(const IBuiltinValueNode<int64_t>&) override; 42 void Visit(const IBuiltinValueNode<uint64_t>&) override; 43 void Visit(const IBuiltinValueNode<BASE_NS::string>&) override; 44 void Visit(const IBuiltinValueNode<RefUri>&) override; 45 void Visit(const ISerNode&) override; 46 47 void Output(const BASE_NS::string& v); 48 void IncOutputIndent(); 49 void DecIndentEndLine(); 50 void NewLine(); 51 52 private: 53 size_t indent_ {}; 54 BASE_NS::string result_; 55 }; 56 57 } // namespace Serialization 58 META_END_NAMESPACE() 59 60 #endif 61