Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json to Tlv and Tlv to Json Converters Implementation in CPP #27635

Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3ef4394
Json to Tlv and Tlv to Json Converters Implemented in CPP
emargolis Jun 24, 2023
f25def6
Merge branch 'master' into emargolis/feature/implement-jsontlv-in-cpp
emargolis Jul 25, 2023
a9bb185
Update src/lib/support/jsontlv/JsonToTlv.cpp
emargolis Jul 26, 2023
3be7853
Update src/lib/support/jsontlv/TlvToJson.cpp
emargolis Jul 26, 2023
4b0cfdd
Update src/lib/support/jsontlv/TlvToJson.cpp
emargolis Jul 26, 2023
d6c608b
Update src/lib/support/jsontlv/TlvToJson.cpp
emargolis Jul 26, 2023
f2bcd35
Update src/lib/support/jsontlv/JsonToTlv.h
emargolis Jul 26, 2023
6da8f04
Update src/lib/support/jsontlv/JsonToTlv.h
emargolis Jul 26, 2023
d7f470c
Addressed Review Comments
emargolis Jul 27, 2023
ae43d5f
Restyled by clang-format
restyled-commits Jul 27, 2023
13486e1
Restyled by prettier-markdown
restyled-commits Jul 27, 2023
24f3202
Removed Debug Prints
emargolis Jul 27, 2023
49a68d7
Added Support for Float/Double Infinity Values
emargolis Jul 28, 2023
231b1a8
Restyled by clang-format
restyled-commits Jul 28, 2023
bb125f8
Restyled by prettier-markdown
restyled-commits Jul 28, 2023
dcce2d5
Update src/lib/support/jsontlv/JsonToTlv.cpp
emargolis Jul 28, 2023
9ebe79e
Addressed Review Comments
emargolis Jul 29, 2023
24c2d78
Merge branch 'master' into emargolis/feature/implement-jsontlv-in-cpp
andreilitvin Aug 2, 2023
0c76ffe
Switch from CommonTag to ProfileTag with an implicit profile id
andreilitvin Aug 2, 2023
e5ee3bf
Documentation update
andreilitvin Aug 2, 2023
21d6e00
Restyle
andreilitvin Aug 2, 2023
175d94b
Fix type of variable in unit test
andreilitvin Aug 2, 2023
bb1e7ba
Update src/lib/support/jsontlv/README.md
andy31415 Aug 4, 2023
75f8f08
Update src/lib/support/jsontlv/TlvToJson.cpp
andy31415 Aug 4, 2023
1c06610
Update src/lib/support/jsontlv/TlvToJson.cpp
andy31415 Aug 4, 2023
1d07cc2
Update src/lib/support/jsontlv/TlvToJson.cpp
andy31415 Aug 4, 2023
d5b721c
Update src/lib/support/jsontlv/TlvJson.cpp
andy31415 Aug 4, 2023
a99c460
Merge branch 'master' into emargolis/feature/implement-jsontlv-in-cpp
andreilitvin Aug 4, 2023
92a1957
Added more comments about kTemporaryImplicitProfileId not being actua…
andreilitvin Aug 4, 2023
e17a3a0
Revert old code updates
andreilitvin Aug 4, 2023
102219e
Casing on json updated according to code review
andreilitvin Aug 4, 2023
82f1cb0
Make the tlv element naming a bit more consistent, including invalid …
andreilitvin Aug 4, 2023
0a86978
Remove obsolete comment
andreilitvin Aug 4, 2023
4935d29
Update src/lib/support/jsontlv/TlvToJson.cpp
andy31415 Aug 4, 2023
a06d865
Update src/lib/support/jsontlv/TlvToJson.cpp
yunhanw-google Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ blocklist
blockquote
bluetoothd
bluez
BOOL
BooleanState
bootable
Bootloader
Expand Down
5 changes: 5 additions & 0 deletions scripts/tools/check_includes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,9 @@
# Library meant for non-embedded
'src/tracing/json/json_tracing.cpp': {'string', 'sstream'},
'src/tracing/json/json_tracing.h': {'fstream'},

# Not intended for embedded clients
'src/lib/support/jsontlv/JsonToTlv.cpp': {'sstream'},
'src/lib/support/jsontlv/JsonToTlv.h': {'string'},
'src/lib/support/jsontlv/TlvToJson.h': {'string'}
}
5 changes: 5 additions & 0 deletions src/lib/core/TLVReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@ class DLL_EXPORT TLVReader
*/
TLVBackingStore * GetBackingStore() { return mBackingStore; }

/**
* Returns true if the current TLV element type is a double.
*/
bool IsElementDouble() { return ElementType() == TLVElementType::FloatingPointNumber64; }

/**
* Gets the point in the underlying input buffer that corresponds to the reader's current position.
*
Expand Down
15 changes: 13 additions & 2 deletions src/lib/support/jsontlv/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Project CHIP Authors
# Copyright (c) 2020-2023 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,18 @@ config("jsontlv_config") {
}

static_library("jsontlv") {
sources = [ "TlvJson.cpp" ]
sources = [
"ElementTypes.h",
"JsonToTlv.cpp",
"TlvJson.cpp",
"TlvToJson.cpp",
]
emargolis marked this conversation as resolved.
Show resolved Hide resolved

public = [
"JsonToTlv.h",
"TlvJson.h",
"TlvToJson.h",
]

public_configs = [ ":jsontlv_config" ]

Expand Down
43 changes: 43 additions & 0 deletions src/lib/support/jsontlv/ElementTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <lib/core/TLV.h>

namespace {

const char kElementTypeInt[] = "INT";
const char kElementTypeUInt[] = "UINT";
const char kElementTypeBool[] = "BOOL";
const char kElementTypeFloat[] = "FLOAT";
const char kElementTypeDouble[] = "DOUBLE";
const char kElementTypeBytes[] = "BYTES";
const char kElementTypeString[] = "STRING";
const char kElementTypeNull[] = "NULL";
const char kElementTypeStruct[] = "STRUCT";
const char kElementTypeArray[] = "ARRAY";
const char kElementTypeEmpty[] = "?";

const char kFloatingPointPositiveInfinity[] = "Infinity";
const char kFloatingPointNegativeInfinity[] = "-Infinity";

struct ElementTypeContext
{
chip::TLV::TLVType tlvType = chip::TLV::kTLVType_NotSpecified;
bool isDouble = false;
};

} // namespace
Loading
Loading