string_number_conversions_win.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_STRINGS_STRING_NUMBER_CONVERSIONS_WIN_H_
  5. #define BASE_STRINGS_STRING_NUMBER_CONVERSIONS_WIN_H_
  6. #include <string>
  7. #include "base/base_export.h"
  8. #include "base/strings/string_piece.h"
  9. namespace base {
  10. BASE_EXPORT std::wstring NumberToWString(int value);
  11. BASE_EXPORT std::wstring NumberToWString(unsigned int value);
  12. BASE_EXPORT std::wstring NumberToWString(long value);
  13. BASE_EXPORT std::wstring NumberToWString(unsigned long value);
  14. BASE_EXPORT std::wstring NumberToWString(long long value);
  15. BASE_EXPORT std::wstring NumberToWString(unsigned long long value);
  16. BASE_EXPORT std::wstring NumberToWString(double value);
  17. // The following section contains overloads of the cross-platform APIs for
  18. // std::wstring and base::WStringPiece. These are only enabled if std::wstring
  19. // and base::string16 are distinct types, as otherwise this would result in an
  20. // ODR violation.
  21. // TODO(crbug.com/911896): Remove those guards once base::string16 is
  22. // std::u16string.
  23. #if defined(BASE_STRING16_IS_STD_U16STRING)
  24. BASE_EXPORT bool StringToInt(WStringPiece input, int* output);
  25. BASE_EXPORT bool StringToUint(WStringPiece input, unsigned* output);
  26. BASE_EXPORT bool StringToInt64(WStringPiece input, int64_t* output);
  27. BASE_EXPORT bool StringToUint64(WStringPiece input, uint64_t* output);
  28. BASE_EXPORT bool StringToSizeT(WStringPiece input, size_t* output);
  29. BASE_EXPORT bool StringToDouble(WStringPiece input, double* output);
  30. #endif // defined(BASE_STRING16_IS_STD_U16STRING)
  31. } // namespace base
  32. #endif // BASE_STRINGS_STRING_NUMBER_CONVERSIONS_WIN_H_