projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Flesh out Optional members swap, reset, emplace, has_value
[folly.git]
/
folly
/
IPAddressV4.h
diff --git
a/folly/IPAddressV4.h
b/folly/IPAddressV4.h
index 626c974f33841574cedf243b425a9a59ba045a45..96de8adda6add3a61ab4b09a3e2c3274caf9addb 100644
(file)
--- a/
folly/IPAddressV4.h
+++ b/
folly/IPAddressV4.h
@@
-22,6
+22,7
@@
#include <functional>
#include <iosfwd>
#include <functional>
#include <iosfwd>
+#include <folly/FBString.h>
#include <folly/Hash.h>
#include <folly/Range.h>
#include <folly/detail/IPAddress.h>
#include <folly/Hash.h>
#include <folly/Range.h>
#include <folly/detail/IPAddress.h>
@@
-80,7
+81,7
@@
class IPAddressV4 {
* Returns the address as a Range.
*/
ByteRange toBinary() const {
* Returns the address as a Range.
*/
ByteRange toBinary() const {
- return ByteRange((const unsigned char
*)
&addr_.inAddr_.s_addr, 4);
+ return ByteRange((const unsigned char
*)
&addr_.inAddr_.s_addr, 4);
}
/**
}
/**
@@
-140,7
+141,9
@@
class IPAddressV4 {
* @see IPAddress#bitCount
* @returns 32
*/
* @see IPAddress#bitCount
* @returns 32
*/
- static size_t bitCount() { return 32; }
+ static constexpr size_t bitCount() {
+ return 32;
+ }
/**
* @See IPAddress#toJson
/**
* @See IPAddress#toJson
@@
-197,7
+200,9
@@
class IPAddressV4 {
std::string toInverseArpaName() const;
// return underlying in_addr structure
std::string toInverseArpaName() const;
// return underlying in_addr structure
- in_addr toAddr() const { return addr_.inAddr_; }
+ in_addr toAddr() const {
+ return addr_.inAddr_;
+ }
sockaddr_in toSockAddr() const {
sockaddr_in addr;
sockaddr_in toSockAddr() const {
sockaddr_in addr;
@@
-214,13
+219,17
@@
class IPAddressV4 {
}
// @see IPAddress#toFullyQualified
}
// @see IPAddress#toFullyQualified
- std::string toFullyQualified() const { return str(); }
+ std::string toFullyQualified() const {
+ return str();
+ }
// @see IPAddress#toFullyQualifiedAppend
void toFullyQualifiedAppend(std::string& out) const;
// @see IPAddress#version
// @see IPAddress#toFullyQualifiedAppend
void toFullyQualifiedAppend(std::string& out) const;
// @see IPAddress#version
- uint8_t version() const { return 4; }
+ uint8_t version() const {
+ return 4;
+ }
/**
* Return the mask associated with the given number of bits.
/**
* Return the mask associated with the given number of bits.
@@
-238,35
+247,40
@@
class IPAddressV4 {
const CIDRNetworkV4& one,
const CIDRNetworkV4& two);
// Number of bytes in the address representation.
const CIDRNetworkV4& one,
const CIDRNetworkV4& two);
// Number of bytes in the address representation.
- static size_t byteCount() { return 4; }
- //get nth most significant bit - 0 indexed
+ static size_t byteCount() {
+ return 4;
+ }
+ // get nth most significant bit - 0 indexed
bool getNthMSBit(size_t bitIndex) const {
return detail::getNthMSBitImpl(*this, bitIndex, AF_INET);
}
bool getNthMSBit(size_t bitIndex) const {
return detail::getNthMSBitImpl(*this, bitIndex, AF_INET);
}
- //get nth most significant byte - 0 indexed
+ //
get nth most significant byte - 0 indexed
uint8_t getNthMSByte(size_t byteIndex) const;
uint8_t getNthMSByte(size_t byteIndex) const;
- //get nth bit - 0 indexed
+ //
get nth bit - 0 indexed
bool getNthLSBit(size_t bitIndex) const {
return getNthMSBit(bitCount() - bitIndex - 1);
}
bool getNthLSBit(size_t bitIndex) const {
return getNthMSBit(bitCount() - bitIndex - 1);
}
- //get nth byte - 0 indexed
+ //
get nth byte - 0 indexed
uint8_t getNthLSByte(size_t byteIndex) const {
return getNthMSByte(byteCount() - byteIndex - 1);
}
uint8_t getNthLSByte(size_t byteIndex) const {
return getNthMSByte(byteCount() - byteIndex - 1);
}
- const unsigned char* bytes() const { return addr_.bytes_.data(); }
+ const unsigned char* bytes() const {
+ return addr_.bytes_.data();
+ }
private:
union AddressStorage {
private:
union AddressStorage {
- static_assert(sizeof(in_addr) == sizeof(ByteArray4),
- "size of in_addr and ByteArray4 are different");
+ static_assert(
+ sizeof(in_addr) == sizeof(ByteArray4),
+ "size of in_addr and ByteArray4 are different");
in_addr inAddr_;
ByteArray4 bytes_;
AddressStorage() {
std::memset(this, 0, sizeof(AddressStorage));
}
in_addr inAddr_;
ByteArray4 bytes_;
AddressStorage() {
std::memset(this, 0, sizeof(AddressStorage));
}
- explicit AddressStorage(const ByteArray4 bytes): bytes_(bytes) {}
- explicit AddressStorage(const in_addr addr): inAddr_(addr) {}
+ explicit AddressStorage(const ByteArray4 bytes)
: bytes_(bytes) {}
+ explicit AddressStorage(const in_addr addr)
: inAddr_(addr) {}
} addr_;
/**
} addr_;
/**