Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: util/misc/uuid.cc

Issue 535343004: Add MachOImageReader and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/misc/uuid.h ('k') | util/misc/uuid_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 UUID_must_be_standard_layout); 34 UUID_must_be_standard_layout);
35 #endif 35 #endif
36 36
37 UUID::UUID() : data_1(0), data_2(0), data_3(0), data_4(), data_5() { 37 UUID::UUID() : data_1(0), data_2(0), data_3(0), data_4(), data_5() {
38 } 38 }
39 39
40 UUID::UUID(const uint8_t* bytes) { 40 UUID::UUID(const uint8_t* bytes) {
41 InitializeFromBytes(bytes); 41 InitializeFromBytes(bytes);
42 } 42 }
43 43
44 bool UUID::operator==(const UUID& that) const {
45 return memcmp(this, &that, sizeof(UUID)) == 0;
46 }
47
44 void UUID::InitializeFromBytes(const uint8_t* bytes) { 48 void UUID::InitializeFromBytes(const uint8_t* bytes) {
45 memcpy(this, bytes, sizeof(*this)); 49 memcpy(this, bytes, sizeof(*this));
46 data_1 = base::NetToHost32(data_1); 50 data_1 = base::NetToHost32(data_1);
47 data_2 = base::NetToHost16(data_2); 51 data_2 = base::NetToHost16(data_2);
48 data_3 = base::NetToHost16(data_3); 52 data_3 = base::NetToHost16(data_3);
49 } 53 }
50 54
51 std::string UUID::ToString() const { 55 std::string UUID::ToString() const {
52 return base::StringPrintf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 56 return base::StringPrintf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
53 data_1, 57 data_1,
54 data_2, 58 data_2,
55 data_3, 59 data_3,
56 data_4[0], 60 data_4[0],
57 data_4[1], 61 data_4[1],
58 data_5[0], 62 data_5[0],
59 data_5[1], 63 data_5[1],
60 data_5[2], 64 data_5[2],
61 data_5[3], 65 data_5[3],
62 data_5[4], 66 data_5[4],
63 data_5[5]); 67 data_5[5]);
64 } 68 }
65 69
66 } // namespace crashpad 70 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/misc/uuid.h ('k') | util/misc/uuid_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698