# Copyright 2010-2021, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#     * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Custom containers for Mozc.

load(
    "//:build_defs.bzl",
    "mozc_cc_library",
    "mozc_cc_test",
)

package(default_visibility = ["//:__subpackages__"])

mozc_cc_library(
    name = "arena",
    hdrs = ["arena.h"],
    deps = [
        "@com_google_absl//absl/base:nullability",
        "@com_google_absl//absl/log:check",
    ],
)

mozc_cc_test(
    name = "arena_test",
    srcs = ["arena_test.cc"],
    deps = [
        ":arena",
        "//testing:gunit_main",
    ],
)

mozc_cc_library(
    name = "bitarray",
    hdrs = ["bitarray.h"],
)

mozc_cc_test(
    name = "bitarray_test",
    size = "small",
    srcs = ["bitarray_test.cc"],
    deps = [
        ":bitarray",
        "//testing:gunit_main",
        "@com_google_absl//absl/random",
    ],
)

mozc_cc_library(
    name = "flat_internal",
    hdrs = ["flat_internal.h"],
    deps = [
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_library(
    name = "flat_map",
    hdrs = ["flat_map.h"],
    deps = [
        ":flat_internal",
        "@com_google_absl//absl/base:nullability",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_test(
    name = "flat_map_test",
    srcs = ["flat_map_test.cc"],
    deps = [
        ":flat_map",
        "//testing:gunit_main",
        "@com_google_absl//absl/strings",
    ],
)

mozc_cc_library(
    name = "flat_multimap",
    hdrs = ["flat_multimap.h"],
    deps = [
        ":flat_internal",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_test(
    name = "flat_multimap_test",
    srcs = ["flat_multimap_test.cc"],
    deps = [
        ":flat_multimap",
        "//testing:gunit_main",
        "@com_google_absl//absl/strings",
    ],
)

mozc_cc_library(
    name = "flat_set",
    hdrs = ["flat_set.h"],
    deps = [
        ":flat_internal",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_test(
    name = "flat_set_test",
    srcs = ["flat_set_test.cc"],
    deps = [
        ":flat_set",
        "//testing:gunit_main",
        "@com_google_absl//absl/strings",
    ],
)

mozc_cc_library(
    name = "serialized_string_array",
    srcs = ["serialized_string_array.cc"],
    hdrs = ["serialized_string_array.h"],
    deps = [
        "//base:file_util",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_test(
    name = "serialized_string_array_test",
    size = "small",
    srcs = ["serialized_string_array_test.cc"],
    deps = [
        ":serialized_string_array",
        "//testing:gunit_main",
        "@com_google_absl//absl/strings",
    ],
)

mozc_cc_library(
    name = "trie",
    hdrs = ["trie.h"],
    visibility = ["//:__subpackages__"],
    deps = [
        "//base:util",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/strings",
    ],
)

mozc_cc_test(
    name = "trie_test",
    size = "small",
    srcs = ["trie_test.cc"],
    deps = [
        ":trie",
        "//testing:gunit_main",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

mozc_cc_library(
    name = "flat_concurrent_cache",
    hdrs = ["flat_concurrent_cache.h"],
    visibility = ["//:__subpackages__"],
    deps = [
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/hash",
        "@com_google_absl//absl/log:check",
    ],
)

mozc_cc_test(
    name = "flat_concurrent_cache_test",
    size = "small",
    srcs = ["flat_concurrent_cache_test.cc"],
    deps = [
        ":flat_concurrent_cache",
        "//base:thread",
        "//testing:gunit_main",
        "@com_google_absl//absl/hash",
        "@com_google_absl//absl/strings",
    ],
)
