1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/strings/string_number_conversions_win.h"
6
7 #include <string>
8
9 #include "base/strings/string_number_conversions_internal.h"
10 #include "base/strings/string_piece.h"
11
12 namespace base {
13
NumberToWString(int value)14 std::wstring NumberToWString(int value) {
15 return internal::IntToStringT<std::wstring>(value);
16 }
17
NumberToWString(unsigned value)18 std::wstring NumberToWString(unsigned value) {
19 return internal::IntToStringT<std::wstring>(value);
20 }
21
NumberToWString(long value)22 std::wstring NumberToWString(long value) {
23 return internal::IntToStringT<std::wstring>(value);
24 }
25
NumberToWString(unsigned long value)26 std::wstring NumberToWString(unsigned long value) {
27 return internal::IntToStringT<std::wstring>(value);
28 }
29
NumberToWString(long long value)30 std::wstring NumberToWString(long long value) {
31 return internal::IntToStringT<std::wstring>(value);
32 }
33
NumberToWString(unsigned long long value)34 std::wstring NumberToWString(unsigned long long value) {
35 return internal::IntToStringT<std::wstring>(value);
36 }
37
NumberToWString(double value)38 std::wstring NumberToWString(double value) {
39 return internal::DoubleToStringT<std::wstring>(value);
40 }
41
42 namespace internal {
43
44 template <>
45 class WhitespaceHelper<wchar_t> {
46 public:
Invoke(wchar_t c)47 static bool Invoke(wchar_t c) { return 0 != iswspace(c); }
48 };
49
50 } // namespace internal
51
StringToInt(WStringPiece input,int * output)52 bool StringToInt(WStringPiece input, int* output) {
53 return internal::StringToIntImpl(input, *output);
54 }
55
StringToUint(WStringPiece input,unsigned * output)56 bool StringToUint(WStringPiece input, unsigned* output) {
57 return internal::StringToIntImpl(input, *output);
58 }
59
StringToInt64(WStringPiece input,int64_t * output)60 bool StringToInt64(WStringPiece input, int64_t* output) {
61 return internal::StringToIntImpl(input, *output);
62 }
63
StringToUint64(WStringPiece input,uint64_t * output)64 bool StringToUint64(WStringPiece input, uint64_t* output) {
65 return internal::StringToIntImpl(input, *output);
66 }
67
StringToSizeT(WStringPiece input,size_t * output)68 bool StringToSizeT(WStringPiece input, size_t* output) {
69 return internal::StringToIntImpl(input, *output);
70 }
71
StringToDouble(WStringPiece input,double * output)72 bool StringToDouble(WStringPiece input, double* output) {
73 return internal::StringToDoubleImpl(
74 input, reinterpret_cast<const uint16_t*>(input.data()), *output);
75 }
76
77 } // namespace base
78