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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_UTIL_MISC_UUID_H_ | 15 #ifndef CRASHPAD_UTIL_MISC_UUID_H_ |
16 #define CRASHPAD_UTIL_MISC_UUID_H_ | 16 #define CRASHPAD_UTIL_MISC_UUID_H_ |
17 | 17 |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 | 19 |
20 #include <string> | 20 #include <string> |
21 | 21 |
| 22 #include "base/strings/string_piece.h" |
| 23 |
22 namespace crashpad { | 24 namespace crashpad { |
23 | 25 |
24 //! \brief A universally unique identifier (%UUID). | 26 //! \brief A universally unique identifier (%UUID). |
25 //! | 27 //! |
26 //! An alternate term for %UUID is “globally unique identifier” (GUID), used | 28 //! An alternate term for %UUID is “globally unique identifier” (GUID), used |
27 //! primarily by Microsoft. | 29 //! primarily by Microsoft. |
28 //! | 30 //! |
29 //! A %UUID is a unique 128-bit number specified by RFC 4122. | 31 //! A %UUID is a unique 128-bit number specified by RFC 4122. |
30 //! | 32 //! |
31 //! This is a standard-layout structure. | 33 //! This is a standard-layout structure. |
(...skipping 10 matching lines...) Expand all Loading... |
42 //! \brief Initializes the %UUID from a sequence of bytes. | 44 //! \brief Initializes the %UUID from a sequence of bytes. |
43 //! | 45 //! |
44 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On | 46 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On |
45 //! little-endian machines, appropriate byte-swapping will be performed to | 47 //! little-endian machines, appropriate byte-swapping will be performed to |
46 //! initialize an object’s data members. | 48 //! initialize an object’s data members. |
47 //! | 49 //! |
48 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the | 50 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the |
49 //! %UUID. | 51 //! %UUID. |
50 void InitializeFromBytes(const uint8_t* bytes); | 52 void InitializeFromBytes(const uint8_t* bytes); |
51 | 53 |
| 54 //! \brief Initializes the %UUID from a RFC 4122 §3 formatted string. |
| 55 //! |
| 56 //! \param[in] string A string of the form |
| 57 //! `"00112233-4455-6677-8899-aabbccddeeff"`. |
| 58 //! |
| 59 //! \return `true` if the string was formatted correctly and the object has |
| 60 //! been initialized with the data. `false` if the string could not be |
| 61 //! parsed, with the object state untouched. |
| 62 bool InitializeFromString(const base::StringPiece& string); |
| 63 |
52 //! \brief Formats the %UUID per RFC 4122 §3. | 64 //! \brief Formats the %UUID per RFC 4122 §3. |
53 //! | 65 //! |
54 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. | 66 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. |
55 std::string ToString() const; | 67 std::string ToString() const; |
56 | 68 |
57 // These fields are laid out according to RFC 4122 §4.1.2. | 69 // These fields are laid out according to RFC 4122 §4.1.2. |
58 uint32_t data_1; | 70 uint32_t data_1; |
59 uint16_t data_2; | 71 uint16_t data_2; |
60 uint16_t data_3; | 72 uint16_t data_3; |
61 uint8_t data_4[2]; | 73 uint8_t data_4[2]; |
62 uint8_t data_5[6]; | 74 uint8_t data_5[6]; |
63 }; | 75 }; |
64 | 76 |
65 } // namespace crashpad | 77 } // namespace crashpad |
66 | 78 |
67 #endif // CRASHPAD_UTIL_MISC_UUID_H_ | 79 #endif // CRASHPAD_UTIL_MISC_UUID_H_ |
OLD | NEW |