OpenShot Audio Library | OpenShotAudio
0.3.2
Loading...
Searching...
No Matches
juce_MACAddress.cpp
1
/*
2
==============================================================================
3
4
This file is part of the JUCE library.
5
Copyright (c) 2017 - ROLI Ltd.
6
7
JUCE is an open source library subject to commercial or open-source
8
licensing.
9
10
The code included in this file is provided under the terms of the ISC license
11
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12
To use, copy, modify, and/or distribute this software for any purpose with or
13
without fee is hereby granted provided that the above copyright notice and
14
this permission notice appear in all copies.
15
16
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18
DISCLAIMED.
19
20
==============================================================================
21
*/
22
23
namespace
juce
24
{
25
26
MACAddress::MACAddress
()
noexcept
27
{
28
zeromem (address,
sizeof
(address));
29
}
30
31
MACAddress::MACAddress
(
const
MACAddress
&
other
)
noexcept
32
{
33
memcpy
(address,
other
.address,
sizeof
(address));
34
}
35
36
MACAddress
&
MACAddress::operator=
(
const
MACAddress
&
other
)
noexcept
37
{
38
memcpy
(address,
other
.address,
sizeof
(address));
39
return
*
this
;
40
}
41
42
MACAddress::MACAddress
(
const
uint8
bytes
[6])
noexcept
43
{
44
memcpy
(address,
bytes
,
sizeof
(address));
45
}
46
47
MACAddress::MACAddress
(
StringRef
addressString
)
48
{
49
MemoryBlock
hex
;
50
hex
.loadFromHexString (
addressString
);
51
52
if
(
hex
.getSize() ==
sizeof
(address))
53
memcpy
(address,
hex
.getData(),
sizeof
(address));
54
else
55
zeromem (address,
sizeof
(address));
56
}
57
58
String
MACAddress::toString
()
const
59
{
60
return
toString
(
"-"
);
61
}
62
63
String
MACAddress::toString
(
StringRef
separator
)
const
64
{
65
String
s;
66
67
for
(
size_t
i = 0; i <
sizeof
(address); ++i)
68
{
69
s <<
String::toHexString
((
int
) address[i]).paddedLeft (
'0'
, 2);
70
71
if
(i <
sizeof
(address) - 1)
72
s <<
separator
;
73
}
74
75
return
s;
76
}
77
78
int64
MACAddress::toInt64
()
const
noexcept
79
{
80
int64
n = 0;
81
82
for
(
int
i = (
int
)
sizeof
(address); --i >= 0;)
83
n = (n << 8) | address[i];
84
85
return
n;
86
}
87
88
Array<MACAddress>
MACAddress::getAllAddresses
()
89
{
90
Array<MACAddress>
addresses
;
91
findAllAddresses
(
addresses
);
92
return
addresses
;
93
}
94
95
bool
MACAddress::isNull
()
const
noexcept
{
return
toInt64
() == 0; }
96
97
bool
MACAddress::operator== (
const
MACAddress
&
other
)
const
noexcept
{
return
memcmp
(address,
other
.address,
sizeof
(address)) == 0; }
98
bool
MACAddress::operator!= (
const
MACAddress& other)
const
noexcept
{
return
! operator== (other); }
99
100
}
// namespace juce
juce::Array
Definition
juce_Array.h:56
juce::MACAddress
Definition
juce_MACAddress.h:33
juce::MACAddress::isNull
bool isNull() const noexcept
Definition
juce_MACAddress.cpp:95
juce::MACAddress::toString
String toString() const
Definition
juce_MACAddress.cpp:58
juce::MACAddress::findAllAddresses
static void findAllAddresses(Array< MACAddress > &results)
juce::MACAddress::operator=
MACAddress & operator=(const MACAddress &) noexcept
Definition
juce_MACAddress.cpp:36
juce::MACAddress::toInt64
int64 toInt64() const noexcept
Definition
juce_MACAddress.cpp:78
juce::MACAddress::getAllAddresses
static Array< MACAddress > getAllAddresses()
Definition
juce_MACAddress.cpp:88
juce::MACAddress::MACAddress
MACAddress() noexcept
Definition
juce_MACAddress.cpp:26
juce::MemoryBlock
Definition
juce_MemoryBlock.h:33
juce::StringRef
Definition
juce_StringRef.h:62
juce::String
Definition
juce_String.h:39
juce::String::toHexString
static String toHexString(IntegerType number)
Definition
juce_String.h:1053
JuceLibraryCode
modules
juce_core
network
juce_MACAddress.cpp
Generated by
1.9.8