OpenShot Library | OpenShotAudio  0.2.1
juce_MACAddress.h
1 
2 /** @weakgroup juce_core-network
3  * @{
4  */
5 /*
6  ==============================================================================
7 
8  This file is part of the JUCE library.
9  Copyright (c) 2017 - ROLI Ltd.
10 
11  JUCE is an open source library subject to commercial or open-source
12  licensing.
13 
14  The code included in this file is provided under the terms of the ISC license
15  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16  To use, copy, modify, and/or distribute this software for any purpose with or
17  without fee is hereby granted provided that the above copyright notice and
18  this permission notice appear in all copies.
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 
30 //==============================================================================
31 /**
32  Represents a MAC network card adapter address ID.
33 
34  @tags{Core}
35 */
36 class JUCE_API MACAddress final
37 {
38 public:
39  //==============================================================================
40  /** Returns a list of the MAC addresses of all the available network cards. */
41  static Array<MACAddress> getAllAddresses();
42 
43  /** Populates a list of the MAC addresses of all the available network cards. */
44  static void findAllAddresses (Array<MACAddress>& results);
45 
46  //==============================================================================
47  /** Creates a null address (00-00-00-00-00-00). */
48  MACAddress() noexcept;
49 
50  /** Creates a copy of another address. */
51  MACAddress (const MACAddress&) noexcept;
52 
53  /** Creates a copy of another address. */
54  MACAddress& operator= (const MACAddress&) noexcept;
55 
56  /** Creates an address from 6 bytes. */
57  explicit MACAddress (const uint8 bytes[6]) noexcept;
58 
59  /** Creates an address from a hex string.
60  If the string isn't a 6-byte hex value, this will just default-initialise
61  the object.
62  */
63  explicit MACAddress (StringRef address);
64 
65  /** Returns a pointer to the 6 bytes that make up this address. */
66  const uint8* getBytes() const noexcept { return address; }
67 
68  /** Returns a dash-separated string in the form "11-22-33-44-55-66" */
69  String toString() const;
70 
71  /** Returns a hex string of this address, using a custom separator between each byte. */
72  String toString (StringRef separator) const;
73 
74  /** Returns the address in the lower 6 bytes of an int64.
75 
76  This uses a little-endian arrangement, with the first byte of the address being
77  stored in the least-significant byte of the result value.
78  */
79  int64 toInt64() const noexcept;
80 
81  /** Returns true if this address is null (00-00-00-00-00-00). */
82  bool isNull() const noexcept;
83 
84  bool operator== (const MACAddress&) const noexcept;
85  bool operator!= (const MACAddress&) const noexcept;
86 
87  //==============================================================================
88 private:
89  uint8 address[6];
90 };
91 
92 } // namespace juce
93 
94 /** @}*/
#define JUCE_API
This macro is added to all JUCE public class declarations.
A simple class for holding temporary references to a string literal or String.
Represents a MAC network card adapter address ID.
The JUCE String class!
Definition: juce_String.h:42
const uint8 * getBytes() const noexcept
Returns a pointer to the 6 bytes that make up this address.
Holds a resizable array of primitive or copy-by-value objects.
Definition: juce_Array.h:59