Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7aebba

Browse files
committed
Add ability to detect null string (happens when nodes gets deleted)
1 parent08bed6b commitd7aebba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

‎src/FirebaseObject.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ float FirebaseObject::getFloat(const String& path) const {
5454

5555
StringFirebaseObject::getString(const String& path)const {
5656
JsonVariant variant =getJsonVariant(path);
57-
if (!variant.is<constchar *>()) {
57+
if (!variant.is<constchar *>() ||isNullString(path)) {
5858
error_ ="failed to convert to string";
5959
return"";
6060
}
6161
returnstatic_cast<constchar*>(variant);
6262
}
6363

64+
boolFirebaseObject::isNullString(const String& path)const {
65+
JsonVariant variant =getJsonVariant(path);
66+
return variant.is<constchar *>() && variant.asString() ==NULL;
67+
}
68+
6469
JsonVariantFirebaseObject::getJsonVariant(const String& path)const {
6570
Stringkey(path);
6671
char* start = &key[0];

‎src/FirebaseObject.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ class FirebaseObject {
4343
*/
4444
boolgetBool(const String& path ="")const;
4545

46+
/**
47+
* Returns true if specified path is NULL string.
48+
* Useful to detect tree deletions.
49+
* \param optional path in the JSON object.
50+
* \return result as a bool.
51+
*/
52+
boolisNullString(const String& path ="")const;
53+
4654
/**
4755
* Return the value as an int.
4856
* \param optional path in the JSON object.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp