Skip to content

Commit

Permalink
Merge 6f95045 into bdee512
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis authored Jul 11, 2023
2 parents bdee512 + 6f95045 commit 2095873
Show file tree
Hide file tree
Showing 19 changed files with 3,338 additions and 124 deletions.
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,6 @@
url = https://github.com/google/perfetto.git
branch = master
platforms = linux,android
[submodule "third_party/json/repo"]
path = third_party/json/repo
url = https://github.com/nlohmann/json.git
7 changes: 6 additions & 1 deletion scripts/tools/check_includes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,10 @@

# Library meant for non-embedded
'src/tracing/json/json_tracing.cpp': {'string', 'sstream'},
'src/tracing/json/json_tracing.h': {'fstream'}
'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 @@ -857,6 +857,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
9 changes: 7 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,12 +19,17 @@ config("jsontlv_config") {
}

static_library("jsontlv") {
sources = [ "TlvJson.cpp" ]
sources = [
"JsonToTlv.cpp",
"TlvJson.cpp",
"TlvToJson.cpp",
]

public_configs = [ ":jsontlv_config" ]

public_deps = [
"${chip_root}/src/lib/core",
"${chip_root}/third_party/json",
jsoncpp_root,
]

Expand Down
32 changes: 32 additions & 0 deletions src/lib/support/jsontlv/ElementTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*
* 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.
*/

namespace {

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

} // namespace
Loading

0 comments on commit 2095873

Please sign in to comment.