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

// Copyright 2016 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_STRING_VIEW_TEMPLATE_H_
#define CORE_FXCRT_STRING_VIEW_TEMPLATE_H_

#include <ctype.h>

#include <algorithm>
#include <iterator>
#include <optional>
#include <string>
#include <type_traits>

#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/span_util.h"

namespace fxcrt {

// An immutable string with caller-provided storage which must outlive the
// string itself. These are not necessarily nul-terminated, so that substring
// extraction (via the Substr(), First(), and Last() methods) is copy-free.
//
// String view arguments should be passed by value, since they are small,
// rather than const-ref, even if they are not modified.
//
// Front() and Back() tolerate empty strings and must return NUL in those
// cases. Substr(), First(), and Last() tolerate out-of-range indices and
// must return an empty string view in those cases. The aim here is allowing
// callers to avoid range-checking first.
template <typename T>
class StringViewTemplate {};

template <typename T>
inline bool operator==(const T* lhs, const StringViewTemplate<T>& rhs) {}
template <typename T>
inline bool operator!=(const T* lhs, const StringViewTemplate<T>& rhs) {}
template <typename T>
inline bool operator<(const T* lhs, const StringViewTemplate<T>& rhs) {}

extern template class StringViewTemplate<char>;
extern template class StringViewTemplate<wchar_t>;

ByteStringView;
WideStringView;

}  // namespace fxcrt

ByteStringView;
WideStringView;

#endif  // CORE_FXCRT_STRING_VIEW_TEMPLATE_H_