Merge remote-tracking branch 'matthijs/ide-1.5.x-ipaddress-const' into ide-1.5.x

This commit is contained in:
Cristian Maglie 2014-01-16 13:17:44 +01:00
commit c2e9860cff
5 changed files with 9 additions and 8 deletions

View File

@ -16,6 +16,7 @@ ARDUINO 1.5.6 BETA
* sam: Optimized delayMicroseconds() (Rob Tillaart) #1121
* Optimized Print::print(String&) method, now uses internal string buffer to perform block write
* Improved portability of String class (maniacbug) #695
* Make some operators in IPAddress const (Matthijs Kooijman)
ARDUINO 1.5.5-r2 BETA 2014.01.10

View File

@ -37,7 +37,7 @@ IPAddress& IPAddress::operator=(uint32_t address)
return *this;
}
bool IPAddress::operator==(const uint8_t* addr)
bool IPAddress::operator==(const uint8_t* addr) const
{
return memcmp(addr, _address, sizeof(_address)) == 0;
}

View File

@ -49,9 +49,9 @@ public:
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
operator uint32_t() { return *((uint32_t*)_address); };
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
bool operator==(const uint8_t* addr);
operator uint32_t() const { return *((uint32_t*)_address); };
bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
bool operator==(const uint8_t* addr) const;
// Overloaded index operator to allow getting and setting individual octets of the address
uint8_t operator[](int index) const { return _address[index]; };

View File

@ -37,7 +37,7 @@ IPAddress& IPAddress::operator=(uint32_t address)
return *this;
}
bool IPAddress::operator==(const uint8_t* addr)
bool IPAddress::operator==(const uint8_t* addr) const
{
return memcmp(addr, _address, sizeof(_address)) == 0;
}

View File

@ -48,9 +48,9 @@ public:
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
operator uint32_t() { return *((uint32_t*)_address); };
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
bool operator==(const uint8_t* addr);
operator uint32_t() const { return *((uint32_t*)_address); };
bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
bool operator==(const uint8_t* addr) const;
// Overloaded index operator to allow getting and setting individual octets of the address
uint8_t operator[](int index) const { return _address[index]; };