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 Internal::BaseObjectFwd<DebugOutput, ClassId::DebugOutput, ISerOutput, ISerNodeVisitor> { 29 public: 30 BASE_NS::string Process(const ISerNode::Ptr& tree) override; 31 32 private: 33 void Visit(const IRootNode&) override; 34 void Visit(const INilNode&) override; 35 void Visit(const IObjectNode&) override; 36 void Visit(const IArrayNode&) override; 37 void Visit(const IMapNode&) override; 38 void Visit(const IBuiltinValueNode<bool>&) override; 39 void Visit(const IBuiltinValueNode<double>&) override; 40 void Visit(const IBuiltinValueNode<int64_t>&) override; 41 void Visit(const IBuiltinValueNode<uint64_t>&) override; 42 void Visit(const IBuiltinValueNode<BASE_NS::string>&) override; 43 void Visit(const IBuiltinValueNode<RefUri>&) override; 44 void Visit(const ISerNode&) override; 45 46 void Output(const BASE_NS::string& v); 47 void IncOutputIndent(); 48 void DecIndentEndLine(); 49 void NewLine(); 50 51 private: 52 size_t indent_ {}; 53 BASE_NS::string result_; 54 }; 55 56 } // namespace Serialization 57 META_END_NAMESPACE() 58 59 #endif 60