| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 //! A %UUID is a unique 128-bit number specified by RFC 4122. | 29 //! A %UUID is a unique 128-bit number specified by RFC 4122. |
| 30 //! | 30 //! |
| 31 //! This is a standard-layout structure. | 31 //! This is a standard-layout structure. |
| 32 struct UUID { | 32 struct UUID { |
| 33 //! \brief Initializes the %UUID to zero. | 33 //! \brief Initializes the %UUID to zero. |
| 34 UUID(); | 34 UUID(); |
| 35 | 35 |
| 36 //! \copydoc InitializeFromBytes() | 36 //! \copydoc InitializeFromBytes() |
| 37 explicit UUID(const uint8_t* bytes); | 37 explicit UUID(const uint8_t* bytes); |
| 38 | 38 |
| 39 bool operator==(const UUID& that) const; |
| 40 bool operator!=(const UUID& that) const { return !operator==(that); } |
| 41 |
| 39 //! \brief Initializes the %UUID from a sequence of bytes. | 42 //! \brief Initializes the %UUID from a sequence of bytes. |
| 40 //! | 43 //! |
| 41 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On | 44 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On |
| 42 //! little-endian machines, appropriate byte-swapping will be performed to | 45 //! little-endian machines, appropriate byte-swapping will be performed to |
| 43 //! initialize an object’s data members. | 46 //! initialize an object’s data members. |
| 44 //! | 47 //! |
| 45 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the | 48 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the |
| 46 //! %UUID. | 49 //! %UUID. |
| 47 void InitializeFromBytes(const uint8_t* bytes); | 50 void InitializeFromBytes(const uint8_t* bytes); |
| 48 | 51 |
| 49 //! \brief Formats the %UUID per RFC 4122 §3. | 52 //! \brief Formats the %UUID per RFC 4122 §3. |
| 50 //! | 53 //! |
| 51 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. | 54 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. |
| 52 std::string ToString() const; | 55 std::string ToString() const; |
| 53 | 56 |
| 54 // These fields are laid out according to RFC 4122 §4.1.2. | 57 // These fields are laid out according to RFC 4122 §4.1.2. |
| 55 uint32_t data_1; | 58 uint32_t data_1; |
| 56 uint16_t data_2; | 59 uint16_t data_2; |
| 57 uint16_t data_3; | 60 uint16_t data_3; |
| 58 uint8_t data_4[2]; | 61 uint8_t data_4[2]; |
| 59 uint8_t data_5[6]; | 62 uint8_t data_5[6]; |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace crashpad | 65 } // namespace crashpad |
| 63 | 66 |
| 64 #endif // CRASHPAD_UTIL_MISC_UUID_H_ | 67 #endif // CRASHPAD_UTIL_MISC_UUID_H_ |
| OLD | NEW |