Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
gettext_plural_form.h
Go to the documentation of this file.
1// Minetest
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5#include <string_view>
6#include <memory>
7
8// Note that this only implements a subset of C expressions. See:
9// https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y
11{
12public:
13 using NumT = unsigned long;
14 using Ptr = std::shared_ptr<GettextPluralForm>;
15
16 size_t size() const
17 {
18 return nplurals;
19 };
20 virtual NumT operator()(const NumT) const = 0;
21 virtual operator bool() const
22 {
23 return size() > 0;
24 }
25 virtual ~GettextPluralForm() {};
26
27 static GettextPluralForm::Ptr parse(const size_t nplurals, const std::wstring_view &str);
28 static GettextPluralForm::Ptr parseHeaderLine(const std::wstring_view &str);
29protected:
31private:
32 const size_t nplurals;
33};
Definition gettext_plural_form.h:11
virtual NumT operator()(const NumT) const =0
size_t size() const
Definition gettext_plural_form.h:16
static GettextPluralForm::Ptr parseHeaderLine(const std::wstring_view &str)
Definition gettext_plural_form.cpp:247
GettextPluralForm(size_t nplurals)
Definition gettext_plural_form.h:30
virtual ~GettextPluralForm()
Definition gettext_plural_form.h:25
unsigned long NumT
Definition gettext_plural_form.h:13
std::shared_ptr< GettextPluralForm > Ptr
Definition gettext_plural_form.h:14
const size_t nplurals
Definition gettext_plural_form.h:32
static GettextPluralForm::Ptr parse(const size_t nplurals, const std::wstring_view &str)
Definition gettext_plural_form.cpp:237