OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/bluetooth_uuid.h" | 5 #include "device/bluetooth/bluetooth_uuid.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 uuid = uuid.substr(2); | 33 uuid = uuid.substr(2); |
34 | 34 |
35 if (!(uuid.size() == 4 || uuid.size() == 8 || uuid.size() == 36)) | 35 if (!(uuid.size() == 4 || uuid.size() == 8 || uuid.size() == 36)) |
36 return; | 36 return; |
37 | 37 |
38 for (size_t i = 0; i < uuid.size(); ++i) { | 38 for (size_t i = 0; i < uuid.size(); ++i) { |
39 if (i == 8 || i == 13 || i == 18 || i == 23) { | 39 if (i == 8 || i == 13 || i == 18 || i == 23) { |
40 if (uuid[i] != '-') | 40 if (uuid[i] != '-') |
41 return; | 41 return; |
42 } else { | 42 } else { |
43 if (!IsHexDigit(uuid[i])) | 43 if (!base::IsHexDigit(uuid[i])) |
44 return; | 44 return; |
45 uuid[i] = base::ToLowerASCII(uuid[i]); | 45 uuid[i] = base::ToLowerASCII(uuid[i]); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 canonical->assign(uuid); | 49 canonical->assign(uuid); |
50 if (uuid.size() == 4) { | 50 if (uuid.size() == 4) { |
51 canonical_128->assign(kCommonUuidPrefix + uuid + kCommonUuidPostfix); | 51 canonical_128->assign(kCommonUuidPrefix + uuid + kCommonUuidPostfix); |
52 *format = BluetoothUUID::kFormat16Bit; | 52 *format = BluetoothUUID::kFormat16Bit; |
53 } else if (uuid.size() == 8) { | 53 } else if (uuid.size() == 8) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const { | 87 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const { |
88 return canonical_value_ != uuid.canonical_value_; | 88 return canonical_value_ != uuid.canonical_value_; |
89 } | 89 } |
90 | 90 |
91 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { | 91 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { |
92 *out << uuid.canonical_value(); | 92 *out << uuid.canonical_value(); |
93 } | 93 } |
94 | 94 |
95 } // namespace device | 95 } // namespace device |
OLD | NEW |