Line data Source code
1 : /* 2 : * 3 : * Copyright (c) 2020-2021 Project CHIP Authors 4 : * All rights reserved. 5 : * 6 : * Licensed under the Apache License, Version 2.0 (the "License"); 7 : * you may not use this file except in compliance with the License. 8 : * You may obtain a copy of the License at 9 : * 10 : * http://www.apache.org/licenses/LICENSE-2.0 11 : * 12 : * Unless required by applicable law or agreed to in writing, software 13 : * distributed under the License is distributed on an "AS IS" BASIS, 14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 : * See the License for the specific language governing permissions and 16 : * limitations under the License. 17 : */ 18 : #include <lib/core/TLVTags.h> 19 : 20 : #include <inttypes.h> 21 : 22 : #include <lib/support/StringBuilder.h> 23 : #include <lib/support/logging/TextOnlyLogging.h> 24 : 25 : namespace chip { 26 : namespace TLV { 27 : 28 : /// Appends the text representation for a tag to the given string builder base. 29 49 : StringBuilderBase & Tag::AppendTo(StringBuilderBase & out) 30 : { 31 49 : if (TLV::IsProfileTag(*this)) 32 : { 33 0 : out.AddFormat("ProfileTag(0x%X::0x%X::0x%" PRIX32 ")", TLV::VendorIdFromTag(*this), TLV::ProfileNumFromTag(*this), 34 : TLV::TagNumFromTag(*this)); 35 : } 36 49 : else if (TLV::IsContextTag(*this)) 37 : { 38 44 : out.AddFormat("ContextTag(0x%" PRIX32 ")", TLV::TagNumFromTag(*this)); 39 : } 40 5 : else if (*this == TLV::AnonymousTag()) 41 : { 42 5 : out.Add("AnonymousTag()"); 43 : } 44 : else 45 : { 46 0 : out.AddFormat("UnknownTag(0x" ChipLogFormatX64 ")", ChipLogValueX64(mVal)); 47 : } 48 : 49 49 : return out; 50 : } 51 : 52 : } // namespace TLV 53 : } // namespace chip