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

Make String& parameters const String&, use JsonVariantConst::is/as<const char *>() #2

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions esp_uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ UUID::UUID() {
buffer_[8] = (buffer_[8] & 0x3F) | 0x80;
}

UUID::UUID(String& uuid) : UUID(uuid.c_str()) {}
UUID::UUID(const String& uuid) : UUID(uuid.c_str()) {}

UUID::UUID(const char* uuid) { fromString(uuid); }

UUID::UUID(const JsonVariantConst& uuid) {
if (uuid.isNull() || !uuid.is<char*>()) {
if (uuid.isNull() || !uuid.is<const char*>()) {
clear();
return;
}

fromString(uuid.as<char*>());
fromString(uuid.as<const char*>());
}

bool UUID::operator<(const UUID& rhs) const { return buffer_ < rhs.buffer_; }
Expand Down Expand Up @@ -104,7 +104,7 @@ bool UUID::fromString(const char* uuid) {
}
}

bool UUID::fromString(String& uuid) { return fromString(uuid.c_str()); }
bool UUID::fromString(const String& uuid) { return fromString(uuid.c_str()); }

void UUID::clear() {
memset(buffer_.data(), 0,
Expand Down
4 changes: 2 additions & 2 deletions esp_uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UUID : public Printable {
/**
* Construct the UUID from the given string
*/
UUID(String& uuid);
UUID(const String& uuid);

/**
* Construct the UUID from the given JsonVariantConst as a string
Expand Down Expand Up @@ -76,7 +76,7 @@ class UUID : public Printable {
* \param uuid The UUID in string form (Hex 8-4-4-4-12)
* \return True if it is a valid UUID string
*/
bool fromString(String& uuid);
bool fromString(const String& uuid);

/**
* Clears the UUID and makes it invalid
Expand Down