JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MACAddress.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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
23namespace juce
24{
25
27{
28 zeromem (address, sizeof (address));
29}
30
32{
33 memcpy (address, other.address, sizeof (address));
34}
35
37{
38 memcpy (address, other.address, sizeof (address));
39 return *this;
40}
41
42MACAddress::MACAddress (const uint8 bytes[6]) noexcept
43{
44 memcpy (address, bytes, sizeof (address));
45}
46
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
59{
60 return toString ("-");
61}
62
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
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
94
95bool MACAddress::isNull() const noexcept { return toInt64() == 0; }
96
97bool MACAddress::operator== (const MACAddress& other) const noexcept { return memcmp (address, other.address, sizeof (address)) == 0; }
98bool MACAddress::operator!= (const MACAddress& other) const noexcept { return ! operator== (other); }
99
100} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Represents a MAC network card adapter address ID.
bool isNull() const noexcept
Returns true if this address is null (00-00-00-00-00-00).
String toString() const
Returns a dash-separated string in the form "11-22-33-44-55-66".
MACAddress & operator=(const MACAddress &) noexcept
Creates a copy of another address.
int64 toInt64() const noexcept
Returns the address in the lower 6 bytes of an int64.
static Array< MACAddress > getAllAddresses()
Returns a list of the MAC addresses of all the available network cards.
MACAddress() noexcept
Creates a null address (00-00-00-00-00-00).
static void findAllAddresses(Array< MACAddress > &results)
Populates a list of the MAC addresses of all the available network cards.
A class to hold a resizable block of raw data.
A simple class for holding temporary references to a string literal or String.
The JUCE String class!
Definition juce_String.h:53
String paddedLeft(juce_wchar padCharacter, int minimumLength) const
Returns a copy of this string with the specified character repeatedly added to its beginning until th...
static String toHexString(IntegerType number)
Returns a string representing this numeric value in hexadecimal.
memcmp
memcpy
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.
void zeromem(void *memory, size_t numBytes) noexcept
Fills a block of memory with zeros.
Definition juce_Memory.h:28