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/string16.h" | 22 #include "base/strings/string16.h" |
23 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 | 25 |
| 26 #if defined(OS_WIN) |
| 27 #include <rpc.h> |
| 28 #endif |
| 29 |
26 namespace crashpad { | 30 namespace crashpad { |
27 | 31 |
28 //! \brief A universally unique identifier (%UUID). | 32 //! \brief A universally unique identifier (%UUID). |
29 //! | 33 //! |
30 //! An alternate term for %UUID is “globally unique identifier” (GUID), used | 34 //! An alternate term for %UUID is “globally unique identifier” (GUID), used |
31 //! primarily by Microsoft. | 35 //! primarily by Microsoft. |
32 //! | 36 //! |
33 //! A %UUID is a unique 128-bit number specified by RFC 4122. | 37 //! A %UUID is a unique 128-bit number specified by RFC 4122. |
34 //! | 38 //! |
35 //! This is a standard-layout structure. | 39 //! This is a standard-layout structure. |
(...skipping 20 matching lines...) Expand all Loading... |
56 //! \brief Initializes the %UUID from a RFC 4122 §3 formatted string. | 60 //! \brief Initializes the %UUID from a RFC 4122 §3 formatted string. |
57 //! | 61 //! |
58 //! \param[in] string A string of the form | 62 //! \param[in] string A string of the form |
59 //! `"00112233-4455-6677-8899-aabbccddeeff"`. | 63 //! `"00112233-4455-6677-8899-aabbccddeeff"`. |
60 //! | 64 //! |
61 //! \return `true` if the string was formatted correctly and the object has | 65 //! \return `true` if the string was formatted correctly and the object has |
62 //! been initialized with the data. `false` if the string could not be | 66 //! been initialized with the data. `false` if the string could not be |
63 //! parsed, with the object state untouched. | 67 //! parsed, with the object state untouched. |
64 bool InitializeFromString(const base::StringPiece& string); | 68 bool InitializeFromString(const base::StringPiece& string); |
65 | 69 |
| 70 #if defined(OS_WIN) || DOXYGEN |
| 71 //! \brief Initializes the %UUID from a system `UUID` or `GUID` structure. |
| 72 //! |
| 73 //! \param[in] system_uuid A system `UUID` or `GUID` structure. |
| 74 void InitializeFromSystemUUID(const ::UUID* system_uuid); |
| 75 #endif // OS_WIN |
| 76 |
66 //! \brief Formats the %UUID per RFC 4122 §3. | 77 //! \brief Formats the %UUID per RFC 4122 §3. |
67 //! | 78 //! |
68 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. | 79 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. |
69 std::string ToString() const; | 80 std::string ToString() const; |
70 | 81 |
71 #if defined(OS_WIN) | 82 #if defined(OS_WIN) || DOXYGEN |
72 //! \brief The same as ToString, but returned as a string16. | 83 //! \brief The same as ToString, but returned as a string16. |
73 base::string16 ToString16() const; | 84 base::string16 ToString16() const; |
74 #endif // OS_WIN | 85 #endif // OS_WIN |
75 | 86 |
76 // These fields are laid out according to RFC 4122 §4.1.2. | 87 // These fields are laid out according to RFC 4122 §4.1.2. |
77 uint32_t data_1; | 88 uint32_t data_1; |
78 uint16_t data_2; | 89 uint16_t data_2; |
79 uint16_t data_3; | 90 uint16_t data_3; |
80 uint8_t data_4[2]; | 91 uint8_t data_4[2]; |
81 uint8_t data_5[6]; | 92 uint8_t data_5[6]; |
82 }; | 93 }; |
83 | 94 |
84 } // namespace crashpad | 95 } // namespace crashpad |
85 | 96 |
86 #endif // CRASHPAD_UTIL_MISC_UUID_H_ | 97 #endif // CRASHPAD_UTIL_MISC_UUID_H_ |
OLD | NEW |