Mercurial > minori
view dep/anitomy/anitomy/keyword.h @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 5c0397762b53 |
children |
line wrap: on
line source
/* ** Copyright (c) 2014-2017, Eren Okka ** ** This Source Code Form is subject to the terms of the Mozilla Public ** License, v. 2.0. If a copy of the MPL was not distributed with this ** file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include <initializer_list> #include <map> #include <vector> #include "element.h" #include "string.h" namespace anitomy { struct TokenRange; struct KeywordOptions { bool identifiable = true; bool searchable = true; bool valid = true; }; struct Keyword { ElementCategory category; KeywordOptions options; }; class KeywordManager { public: KeywordManager(); void Add(ElementCategory category, const KeywordOptions& options, const std::initializer_list<string_t>& keywords); bool Find(ElementCategory category, const string_t& str) const; bool Find(const string_t& str, ElementCategory& category, KeywordOptions& options) const; void Peek(const string_t& filename, const TokenRange& range, Elements& elements, std::vector<TokenRange>& preidentified_tokens) const; string_t Normalize(const string_t& str) const; private: using keyword_container_t = std::map<string_t, Keyword>; keyword_container_t& GetKeywordContainer(ElementCategory category) const; keyword_container_t file_extensions_; keyword_container_t keys_; }; extern KeywordManager keyword_manager; } // namespace anitomy