chromium/base/i18n/break_iterator.cc

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

#include "base/i18n/break_iterator.h"

#include <stdint.h>
#include <ostream>
#include <string_view>

#include "base/check.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/synchronization/lock.h"
#include "third_party/icu/source/common/unicode/ubrk.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "third_party/icu/source/common/unicode/ustring.h"

namespace base {
namespace i18n {

namespace {

// We found the usage pattern of break iterator is to create, use and destroy.
// The following cache support multiple break iterator in the same thread and
// also optimize to not create break iterator many time. For each kind of break
// iterator (character, word, line and sentence, but NOT rule), we keep one of
// them in the main_ and lease it out. If some other code request a lease
// before |main_| is returned, we create a new instance of the iterator.
// This will keep at most 4 break iterators (one for each kind) unreleased until
// the program destruction time.
template <UBreakIteratorType break_type>
class DefaultLocaleBreakIteratorCache {};

static LazyInstance<DefaultLocaleBreakIteratorCache<UBRK_CHARACTER>>::Leaky
    char_break_cache =;
static LazyInstance<DefaultLocaleBreakIteratorCache<UBRK_WORD>>::Leaky
    word_break_cache =;
static LazyInstance<DefaultLocaleBreakIteratorCache<UBRK_SENTENCE>>::Leaky
    sentence_break_cache =;
static LazyInstance<DefaultLocaleBreakIteratorCache<UBRK_LINE>>::Leaky
    line_break_cache =;

}  // namespace

void UBreakIteratorDeleter::operator()(UBreakIterator* ptr) {}

BreakIterator::BreakIterator(std::u16string_view str, BreakType break_type)
    :{}

BreakIterator::BreakIterator(std::u16string_view str,
                             const std::u16string& rules)
    :{}

BreakIterator::~BreakIterator() {}

bool BreakIterator::Init() {}

bool BreakIterator::Advance() {}

bool BreakIterator::SetText(std::u16string_view text) {}

bool BreakIterator::IsWord() const {}

BreakIterator::WordBreakStatus BreakIterator::GetWordBreakStatus() const {}

bool BreakIterator::IsEndOfWord(size_t position) const {}

bool BreakIterator::IsStartOfWord(size_t position) const {}

bool BreakIterator::IsSentenceBoundary(size_t position) const {}

bool BreakIterator::IsGraphemeBoundary(size_t position) const {}

std::u16string BreakIterator::GetString() const {}

std::u16string_view BreakIterator::GetStringView() const {}

}  // namespace i18n
}  // namespace base