| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/win/scoped_bstr.h" | 5 #include "base/win/scoped_bstr.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 | 10 |
| 9 namespace base { | 11 namespace base { |
| 10 namespace win { | 12 namespace win { |
| 11 | 13 |
| 12 ScopedBstr::ScopedBstr(const char16* non_bstr) | 14 ScopedBstr::ScopedBstr(const char16* non_bstr) |
| 13 : bstr_(SysAllocString(non_bstr)) { | 15 : bstr_(SysAllocString(non_bstr)) { |
| 14 } | 16 } |
| 15 | 17 |
| 16 ScopedBstr::~ScopedBstr() { | 18 ScopedBstr::~ScopedBstr() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return bstr_; | 50 return bstr_; |
| 49 } | 51 } |
| 50 | 52 |
| 51 BSTR ScopedBstr::AllocateBytes(size_t bytes) { | 53 BSTR ScopedBstr::AllocateBytes(size_t bytes) { |
| 52 Reset(SysAllocStringByteLen(NULL, static_cast<UINT>(bytes))); | 54 Reset(SysAllocStringByteLen(NULL, static_cast<UINT>(bytes))); |
| 53 return bstr_; | 55 return bstr_; |
| 54 } | 56 } |
| 55 | 57 |
| 56 void ScopedBstr::SetByteLen(size_t bytes) { | 58 void ScopedBstr::SetByteLen(size_t bytes) { |
| 57 DCHECK(bstr_ != NULL) << "attempting to modify a NULL bstr"; | 59 DCHECK(bstr_ != NULL) << "attempting to modify a NULL bstr"; |
| 58 uint32* data = reinterpret_cast<uint32*>(bstr_); | 60 uint32_t* data = reinterpret_cast<uint32_t*>(bstr_); |
| 59 data[-1] = static_cast<uint32>(bytes); | 61 data[-1] = static_cast<uint32_t>(bytes); |
| 60 } | 62 } |
| 61 | 63 |
| 62 size_t ScopedBstr::Length() const { | 64 size_t ScopedBstr::Length() const { |
| 63 return SysStringLen(bstr_); | 65 return SysStringLen(bstr_); |
| 64 } | 66 } |
| 65 | 67 |
| 66 size_t ScopedBstr::ByteLength() const { | 68 size_t ScopedBstr::ByteLength() const { |
| 67 return SysStringByteLen(bstr_); | 69 return SysStringByteLen(bstr_); |
| 68 } | 70 } |
| 69 | 71 |
| 70 } // namespace win | 72 } // namespace win |
| 71 } // namespace base | 73 } // namespace base |
| OLD | NEW |