strcat_win.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_STRCAT_WIN_H_
  5. #define BASE_STRINGS_STRCAT_WIN_H_
  6. #include <initializer_list>
  7. #include <string>
  8. #include "base/base_export.h"
  9. #include "base/compiler_specific.h"
  10. #include "base/containers/span.h"
  11. #include "base/strings/string_piece.h"
  12. namespace base {
  13. // The following section contains overloads of the cross-platform APIs for
  14. // std::wstring and base::WStringPiece. These are only enabled if std::wstring
  15. // and base::string16 are distinct types, as otherwise this would result in an
  16. // ODR violation.
  17. // TODO(crbug.com/911896): Remove those guards once base::string16 is
  18. // std::u16string.
  19. #if defined(BASE_STRING16_IS_STD_U16STRING)
  20. BASE_EXPORT void StrAppend(std::wstring* dest, span<const WStringPiece> pieces);
  21. BASE_EXPORT void StrAppend(std::wstring* dest, span<const std::wstring> pieces);
  22. inline void StrAppend(std::wstring* dest,
  23. std::initializer_list<WStringPiece> pieces) {
  24. StrAppend(dest, make_span(pieces));
  25. }
  26. BASE_EXPORT std::wstring StrCat(span<const WStringPiece> pieces)
  27. WARN_UNUSED_RESULT;
  28. BASE_EXPORT std::wstring StrCat(span<const std::wstring> pieces)
  29. WARN_UNUSED_RESULT;
  30. inline std::wstring StrCat(std::initializer_list<WStringPiece> pieces) {
  31. return StrCat(make_span(pieces));
  32. }
  33. #endif // defined(BASE_STRING16_IS_STD_U16STRING)
  34. } // namespace base
  35. #endif // BASE_STRINGS_STRCAT_WIN_H_