Skip to content

Commit a5b098c

Browse files
committed
upd
1 parent cc37a21 commit a5b098c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=StringUtils
2-
version=1.4.23
2+
version=1.4.24
33
author=AlexGyver <[email protected]>
44
maintainer=AlexGyver <[email protected]>
55
sentence=Bunch of converting functions for string data

src/utils/Text.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class Text : public Printable {
3232
}
3333
#endif
3434

35-
Cstr(const Text& t) {
35+
Cstr(const Text& t, bool forceDup = false) {
3636
if (!t.length()) return;
37-
if (!t.pgm() && t.terminated()) {
37+
if (!t.pgm() && t.terminated() && !forceDup) {
3838
str = t.str();
3939
len = t.length();
4040
return;
@@ -66,6 +66,10 @@ class Text : public Printable {
6666
del = false;
6767
}
6868

69+
uint16_t length() {
70+
return len;
71+
}
72+
6973
private:
7074
const char* str = "";
7175
uint16_t len = 0;
@@ -648,8 +652,8 @@ class Text : public Printable {
648652
// ========================== CONVERT ==========================
649653

650654
// получить const char* копию (Cstr конвертируется в const char*). Всегда валидна и терминирована. Если Text из PGM или не терминирован - будет создана временная копия
651-
Cstr c_str() const {
652-
return Cstr(*this);
655+
Cstr c_str(bool forceDup = false) const {
656+
return Cstr(*this, forceDup);
653657
}
654658

655659
// Вывести в String строку. Вернёт false при неудаче

0 commit comments

Comments
 (0)