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

Allow creating IPAddress object from string and provide = overload#174

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
facchinm merged 3 commits intoarduino:masterfrompennam:ip-string
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
11 changes: 11 additions & 0 deletionsapi/IPAddress.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,6 +89,11 @@ IPAddress::IPAddress(IPType ip_type, const uint8_t *address)
}
}

IPAddress::IPAddress(const char *address)
{
fromString(address);
}

bool IPAddress::fromString(const char *address) {
if (!fromString4(address)) {
return fromString6(address);
Expand DownExpand Up@@ -225,6 +230,12 @@ IPAddress& IPAddress::operator=(const uint8_t *address)
return *this;
}

IPAddress& IPAddress::operator=(const char *address)
{
fromString(address);
return *this;
}

IPAddress& IPAddress::operator=(uint32_t address)
{
// IPv4 conversion
Expand Down
4 changes: 4 additions & 0 deletionsapi/IPAddress.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,6 +67,8 @@ class IPAddress : public Printable {
// Default IPv4
IPAddress(const uint8_t *address);
IPAddress(IPType ip_type, const uint8_t *address);
// If IPv4 fails tries IPv6 see fromString function
IPAddress(const char *address);

bool fromString(const char *address);
bool fromString(const String &address) { return fromString(address.c_str()); }
Expand All@@ -90,6 +92,8 @@ class IPAddress : public Printable {
IPAddress& operator=(const uint8_t *address);
// NOTE: IPv4 only; see implementation note
IPAddress& operator=(uint32_t address);
// If IPv4 fails tries IPv6 see fromString function
IPAddress& operator=(const char *address);

virtual size_t printTo(Print& p) const;

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp