Skip to content

Commit e33e78d

Browse files
committed
Rename undocumented JsonString::isLinked() to isStatic()
1 parent ed5f890 commit e33e78d

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ HEAD
99
* Change string copy policy: only string literal are stored by pointer
1010
* `JsonString` is now stored by copy, unless specified otherwise
1111
* Replace undocumented `JsonString::Ownership` with `bool`
12+
* Rename undocumented `JsonString::isLinked()` to `isStatic()`
1213

1314
> ### BREAKING CHANGES
1415
>

extras/tests/JsonVariant/as.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ TEST_CASE("JsonVariant::as()") {
184184

185185
REQUIRE(variant.as<long>() == 42L);
186186
REQUIRE(variant.as<JsonString>() == "42");
187-
REQUIRE(variant.as<JsonString>().isLinked() == true);
187+
REQUIRE(variant.as<JsonString>().isStatic() == true);
188188
}
189189

190190
SECTION("set(\"hello\")") {
@@ -207,7 +207,7 @@ TEST_CASE("JsonVariant::as()") {
207207
REQUIRE(variant.as<const char*>() == "4.2"_s);
208208
REQUIRE(variant.as<std::string>() == "4.2"_s);
209209
REQUIRE(variant.as<JsonString>() == "4.2");
210-
REQUIRE(variant.as<JsonString>().isLinked() == false);
210+
REQUIRE(variant.as<JsonString>().isStatic() == false);
211211
}
212212

213213
SECTION("set(\"true\")") {

extras/tests/Misc/JsonString.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ TEST_CASE("JsonString") {
1313

1414
CHECK(s.isNull() == true);
1515
CHECK(s.c_str() == 0);
16-
CHECK(s.isLinked() == true);
16+
CHECK(s.isStatic() == true);
1717
CHECK(s == JsonString());
1818
CHECK(s != "");
1919
}
@@ -96,7 +96,7 @@ TEST_CASE("JsonString") {
9696
JsonString s("hello world", 5);
9797

9898
CHECK(s.size() == 5);
99-
CHECK(s.isLinked() == false);
99+
CHECK(s.isStatic() == false);
100100
CHECK(s == "hello");
101101
CHECK(s != "hello world");
102102
}

extras/tests/Misc/StringAdapters.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ TEST_CASE("adaptString()") {
2222

2323
CHECK(s.isNull() == false);
2424
CHECK(s.size() == 11);
25-
CHECK(s.isLinked() == true);
25+
CHECK(s.isStatic() == true);
2626
}
2727

2828
SECTION("null const char*") {
@@ -38,39 +38,39 @@ TEST_CASE("adaptString()") {
3838

3939
CHECK(s.isNull() == false);
4040
CHECK(s.size() == 5);
41-
CHECK(s.isLinked() == false);
41+
CHECK(s.isStatic() == false);
4242
CHECK(s.data() == p);
4343
}
4444

4545
SECTION("null const char* + size") {
4646
auto s = adaptString(static_cast<const char*>(0), 10);
4747

4848
CHECK(s.isNull() == true);
49-
CHECK(s.isLinked() == false);
49+
CHECK(s.isStatic() == false);
5050
}
5151

5252
SECTION("non-null const char* + size") {
5353
auto s = adaptString("bravo", 5);
5454

5555
CHECK(s.isNull() == false);
5656
CHECK(s.size() == 5);
57-
CHECK(s.isLinked() == false);
57+
CHECK(s.isStatic() == false);
5858
}
5959

6060
SECTION("null Flash string") {
6161
auto s = adaptString(static_cast<const __FlashStringHelper*>(0));
6262

6363
CHECK(s.isNull() == true);
6464
CHECK(s.size() == 0);
65-
CHECK(s.isLinked() == false);
65+
CHECK(s.isStatic() == false);
6666
}
6767

6868
SECTION("non-null Flash string") {
6969
auto s = adaptString(F("bravo"));
7070

7171
CHECK(s.isNull() == false);
7272
CHECK(s.size() == 5);
73-
CHECK(s.isLinked() == false);
73+
CHECK(s.isStatic() == false);
7474
}
7575

7676
SECTION("std::string") {
@@ -79,7 +79,7 @@ TEST_CASE("adaptString()") {
7979

8080
CHECK(s.isNull() == false);
8181
CHECK(s.size() == 5);
82-
CHECK(s.isLinked() == false);
82+
CHECK(s.isStatic() == false);
8383
}
8484

8585
SECTION("Arduino String") {
@@ -88,7 +88,7 @@ TEST_CASE("adaptString()") {
8888

8989
CHECK(s.isNull() == false);
9090
CHECK(s.size() == 5);
91-
CHECK(s.isLinked() == false);
91+
CHECK(s.isStatic() == false);
9292
}
9393

9494
SECTION("custom_string") {
@@ -97,7 +97,7 @@ TEST_CASE("adaptString()") {
9797

9898
CHECK(s.isNull() == false);
9999
CHECK(s.size() == 5);
100-
CHECK(s.isLinked() == false);
100+
CHECK(s.isStatic() == false);
101101
}
102102

103103
SECTION("JsonString linked") {
@@ -106,7 +106,7 @@ TEST_CASE("adaptString()") {
106106

107107
CHECK(s.isNull() == false);
108108
CHECK(s.size() == 5);
109-
CHECK(s.isLinked() == true);
109+
CHECK(s.isStatic() == true);
110110
}
111111

112112
SECTION("JsonString copied") {
@@ -115,7 +115,7 @@ TEST_CASE("adaptString()") {
115115

116116
CHECK(s.isNull() == false);
117117
CHECK(s.size() == 5);
118-
CHECK(s.isLinked() == false);
118+
CHECK(s.isStatic() == false);
119119
}
120120
}
121121

src/ArduinoJson/Strings/Adapters/FlashString.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class FlashString {
6363
::memcpy_P(p, s.str_, n);
6464
}
6565

66-
bool isLinked() const {
66+
bool isStatic() const {
6767
return false;
6868
}
6969

src/ArduinoJson/Strings/Adapters/RamString.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class RamString {
2626
static constexpr size_t sizeMask = size_t(-1);
2727
#endif
2828

29-
RamString(const char* str, size_t sz, bool linked = false)
30-
: str_(str), size_(sz & sizeMask), linked_(linked) {
29+
RamString(const char* str, size_t sz, bool isStatic = false)
30+
: str_(str), size_(sz & sizeMask), static_(isStatic) {
3131
ARDUINOJSON_ASSERT(size_ == sz);
3232
}
3333

@@ -49,8 +49,8 @@ class RamString {
4949
return str_;
5050
}
5151

52-
bool isLinked() const {
53-
return linked_;
52+
bool isStatic() const {
53+
return static_;
5454
}
5555

5656
protected:
@@ -59,10 +59,10 @@ class RamString {
5959
#if ARDUINOJSON_SIZEOF_POINTER <= 2
6060
// Use a bitfield only on 8-bit microcontrollers
6161
size_t size_ : sizeof(size_t) * 8 - 1;
62-
bool linked_ : 1;
62+
bool static_ : 1;
6363
#else
6464
size_t size_;
65-
bool linked_;
65+
bool static_;
6666
#endif
6767
};
6868

src/ArduinoJson/Strings/JsonString.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class JsonString {
4242

4343
// Returns true if the string is stored by address.
4444
// Returns false if the string is stored by copy.
45-
bool isLinked() const {
46-
return str_.isLinked();
45+
bool isStatic() const {
46+
return str_.isStatic();
4747
}
4848

4949
// Returns length of the string.

src/ArduinoJson/Variant/VariantImpl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ inline bool VariantData::setString(TAdaptedString value,
2626
if (value.isNull())
2727
return false;
2828

29-
if (value.isLinked()) {
29+
if (value.isStatic()) {
3030
setLinkedString(value.data());
3131
return true;
3232
}

0 commit comments

Comments
 (0)