chromium/device/bluetooth/public/cpp/bluetooth_uuid.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "device/bluetooth/public/cpp/bluetooth_uuid.h"

#include <stddef.h>

#include <ostream>
#include <string>

#include "base/check_op.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_WIN)
#include <objbase.h>

#include "base/win/win_util.h"
#endif  // BUILDFLAG(IS_WIN)

namespace device {

namespace {

const char kCommonUuidPostfix[] =;
const char kCommonUuidPrefix[] =;

// Returns the canonical, 128-bit canonical, and the format of the UUID
// in |canonical|, |canonical_128|, and |format| based on |uuid|.
void GetCanonicalUuid(std::string uuid,
                      std::string* canonical,
                      std::string* canonical_128,
                      BluetoothUUID::Format* format) {}

}  // namespace

BluetoothUUID::BluetoothUUID(const std::string& uuid) {}

BluetoothUUID::BluetoothUUID(base::span<const uint8_t> uuid_in_bytes) {}

#if BUILDFLAG(IS_WIN)
BluetoothUUID::BluetoothUUID(GUID uuid) {
  auto buffer = base::win::WStringFromGUID(uuid);
  DCHECK_EQ('{', buffer[0]);
  DCHECK_EQ('}', buffer[37]);

  GetCanonicalUuid(base::WideToUTF8(buffer.substr(1, 36)), &value_,
                   &canonical_value_, &format_);
  DCHECK_EQ(kFormat128Bit, format_);
}
#endif  // BUILDFLAG(IS_WIN)

BluetoothUUID::BluetoothUUID() :{}

BluetoothUUID::~BluetoothUUID() = default;

#if BUILDFLAG(IS_WIN)
// static
GUID BluetoothUUID::GetCanonicalValueAsGUID(std::string_view uuid) {
  DCHECK_EQ(36u, uuid.size());
  std::u16string braced_uuid = u'{' + base::UTF8ToUTF16(uuid) + u'}';
  GUID guid;
  CHECK_EQ(NOERROR, ::CLSIDFromString(base::as_wcstr(braced_uuid), &guid));
  return guid;
}
#endif  // BUILDFLAG(IS_WIN)

bool BluetoothUUID::IsValid() const {}

std::vector<uint8_t> BluetoothUUID::GetBytes() const {}

bool BluetoothUUID::operator<(const BluetoothUUID& uuid) const {}

bool BluetoothUUID::operator==(const BluetoothUUID& uuid) const {}

bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const {}

std::ostream& operator<<(std::ostream& os, BluetoothUUID uuid) {}

}  // namespace device