chromium/third_party/pdfium/core/fxcrt/widestring.h

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

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXCRT_WIDESTRING_H_
#define CORE_FXCRT_WIDESTRING_H_

#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>

#include <iosfwd>
#include <utility>

#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/string_template.h"

namespace fxcrt {

class ByteString;

// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
// TODO(crbug.com/pdfium/2031): Consider switching to `char16_t` instead.
class WideString : public StringTemplate<wchar_t> {};

inline WideString operator+(WideStringView str1, WideStringView str2) {}
inline WideString operator+(WideStringView str1, const wchar_t* str2) {}
inline WideString operator+(const wchar_t* str1, WideStringView str2) {}
inline WideString operator+(WideStringView str1, wchar_t ch) {}
inline WideString operator+(wchar_t ch, WideStringView str2) {}
inline WideString operator+(const WideString& str1, const WideString& str2) {}
inline WideString operator+(const WideString& str1, wchar_t ch) {}
inline WideString operator+(wchar_t ch, const WideString& str2) {}
inline WideString operator+(const WideString& str1, const wchar_t* str2) {}
inline WideString operator+(const wchar_t* str1, const WideString& str2) {}
inline WideString operator+(const WideString& str1, WideStringView str2) {}
inline WideString operator+(WideStringView str1, const WideString& str2) {}
inline bool operator==(const wchar_t* lhs, const WideString& rhs) {}
inline bool operator==(WideStringView lhs, const WideString& rhs) {}
inline bool operator!=(const wchar_t* lhs, const WideString& rhs) {}
inline bool operator!=(WideStringView lhs, const WideString& rhs) {}
inline bool operator<(const wchar_t* lhs, const WideString& rhs) {}

std::wostream& operator<<(std::wostream& os, const WideString& str);
std::ostream& operator<<(std::ostream& os, const WideString& str);
std::wostream& operator<<(std::wostream& os, WideStringView str);
std::ostream& operator<<(std::ostream& os, WideStringView str);

// This is declared here for use in gtest-based tests but is defined in a test
// support target. This should not be used in production code. Just use
// operator<< from above instead.
// In some cases, gtest will automatically use operator<< as well, but in this
// case, it needs PrintTo() because WideString looks like a container to gtest.
void PrintTo(const WideString& str, std::ostream* os);

}  // namespace fxcrt

WideString;

uint32_t FX_HashCode_GetW(WideStringView str);
uint32_t FX_HashCode_GetLoweredW(WideStringView str);

namespace std {

template <>
struct hash<WideString> {};

}  // namespace std

extern template struct std::hash<WideString>;

#endif  // CORE_FXCRT_WIDESTRING_H_