8#include "dcon_generated.hpp"
10#include "unordered_dense.h"
449 return ankerl::unordered_dense::detail::wyhash::hash(sv.data(), sv.size());
454 return std::string_view();
457 auto end_position = start_position;
458 for(; end_position <
text_data.data() + data_size; ++end_position) {
459 if(*end_position == 0)
462 return std::string_view(
text_data.data() +
tag.index(),
size_t(end_position - start_position));
464 return ankerl::unordered_dense::detail::wyhash::hash(sv.data(), sv.size());
474 bool operator()(dcon::text_key l, dcon::text_key r)
const noexcept {
477 bool operator()(dcon::text_key l, std::string_view r)
const noexcept {
480 return std::string_view();
481 auto start_position =
text_data.data() + l.index();
483 auto end_position = start_position;
484 for(; end_position <
text_data.data() + data_size; ++end_position) {
485 if(*end_position == 0)
488 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
492 bool operator()(std::string_view r, dcon::text_key l)
const noexcept {
495 return std::string_view();
496 auto start_position =
text_data.data() + l.index();
498 auto end_position = start_position;
499 for(; end_position <
text_data.data() + data_size; ++end_position) {
500 if(*end_position == 0)
503 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
507 bool operator()(dcon::text_key l, std::string
const& r)
const noexcept {
510 return std::string_view();
511 auto start_position =
text_data.data() + l.index();
513 auto end_position = start_position;
514 for(; end_position <
text_data.data() + data_size; ++end_position) {
515 if(*end_position == 0)
518 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
522 bool operator()(std::string
const& r, dcon::text_key l)
const noexcept {
525 return std::string_view();
526 auto start_position =
text_data.data() + l.index();
528 auto end_position = start_position;
529 for(; end_position <
text_data.data() + data_size; ++end_position) {
530 if(*end_position == 0)
533 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
541# if defined(__SIZEOF_INT128__)
545 *b =
static_cast<uint64_t>(r >> 64U);
546# elif defined(_MSC_VER) && defined(_M_X64)
547 *a = _umul128(*a, *b, b);
560 auto c =
static_cast<uint64_t>(t < rl);
561 lo = t + (rm1 << 32U);
563 hi = rh + (rm0 >> 32U) + (rm1 >> 32U) + c;
578 std::memcpy(&v, p, 8U);
579 return v | 0x2020202020202020;
584 std::memcpy(&v, p, 4);
585 return v | 0x20202020;
590 return (
static_cast<uint64_t>(p[0] | 0x20) << 16U) | (
static_cast<uint64_t>(p[k >> 1U] | 0x20) << 8U) | p[k - 1] | 0x20;
594 static constexpr auto secret = std::array{
UINT64_C(0xa0761d6478bd642f),
599 auto const* p =
static_cast<uint8_t const*
>(key);
603 if(ANKERL_UNORDERED_DENSE_LIKELY(len <= 16)) {
604 if(ANKERL_UNORDERED_DENSE_LIKELY(len >= 4)) {
605 a = (
r4(p) << 32U) |
r4(p + ((len >> 3U) << 2U));
606 b = (
r4(p + len - 4) << 32U) |
r4(p + len - 4 - ((len >> 3U) << 2U));
607 }
else if(ANKERL_UNORDERED_DENSE_LIKELY(len > 0)) {
616 if(ANKERL_UNORDERED_DENSE_UNLIKELY(i > 48)) {
620 seed =
mix(
r8(p) ^ secret[1],
r8(p + 8) ^ seed);
621 see1 =
mix(
r8(p + 16) ^ secret[2],
r8(p + 24) ^ see1);
622 see2 =
mix(
r8(p + 32) ^ secret[3],
r8(p + 40) ^ see2);
625 }
while(ANKERL_UNORDERED_DENSE_LIKELY(i > 48));
628 while(ANKERL_UNORDERED_DENSE_UNLIKELY(i > 16)) {
629 seed =
mix(
r8(p) ^ secret[1],
r8(p + 8) ^ seed);
637 return mix(secret[1] ^ len,
mix(a ^ secret[1], b ^ seed));
640inline bool lazy_ci_eq(std::string_view a, std::string_view b) {
641 if(a.length() != b.length())
643 for(
uint32_t i = 0; i < a.length(); ++i) {
644 if((a[i] | 0x20) != (b[i] | 0x20))
666 return std::string_view();
669 auto end_position = start_position;
670 for(; end_position <
text_data.data() + data_size; ++end_position) {
671 if(*end_position == 0)
674 return std::string_view(
text_data.data() +
tag.index(),
size_t(end_position - start_position));
686 bool operator()(dcon::text_key l, dcon::text_key r)
const noexcept {
689 bool operator()(dcon::text_key l, std::string_view r)
const noexcept {
692 return std::string_view();
693 auto start_position =
text_data.data() + l.index();
695 auto end_position = start_position;
696 for(; end_position <
text_data.data() + data_size; ++end_position) {
697 if(*end_position == 0)
700 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
704 bool operator()(std::string_view r, dcon::text_key l)
const noexcept {
707 return std::string_view();
708 auto start_position =
text_data.data() + l.index();
710 auto end_position = start_position;
711 for(; end_position <
text_data.data() + data_size; ++end_position) {
712 if(*end_position == 0)
715 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
719 bool operator()(dcon::text_key l, std::string
const& r)
const noexcept {
722 return std::string_view();
723 auto start_position =
text_data.data() + l.index();
725 auto end_position = start_position;
726 for(; end_position <
text_data.data() + data_size; ++end_position) {
727 if(*end_position == 0)
730 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
734 bool operator()(std::string
const& r, dcon::text_key l)
const noexcept {
737 return std::string_view();
738 auto start_position =
text_data.data() + l.index();
740 auto end_position = start_position;
741 for(; end_position <
text_data.data() + data_size; ++end_position) {
742 if(*end_position == 0)
745 return std::string_view(
text_data.data() + l.index(),
size_t(end_position - start_position));
788 dcon::national_identity_id
tag;
790using substitution = std::variant<std::string_view, dcon::text_key, dcon::province_id, dcon::state_instance_id, dcon::nation_id,
1001 int32_t indent = 0);
1012void add_line_with_condition(
sys::state&
state, layout_base&
dest, std::string_view key,
bool condition_met,
variable_type subkey,
substitution value,
variable_type subkeyb,
substitution valueb,
variable_type subkeyc,
substitution valuec, int32_t indent = 0);
auto r3(const uint8_t *p, size_t k) -> uint64_t
void mum(uint64_t *a, uint64_t *b)
bool lazy_ci_eq(std::string_view a, std::string_view b)
auto ci_wyhash(void const *key, size_t len) -> uint64_t
auto r4(const uint8_t *p) -> uint64_t
auto mix(uint64_t a, uint64_t b) -> uint64_t
auto r8(const uint8_t *p) -> uint64_t
@ crisisdefender_continent
@ error_no_matching_value
@ crisisattacker_continent
void add_line_break_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
std::string format_money(float num)
std::string get_focus_category_name(sys::state const &state, nations::focus_type category)
std::string get_name_as_string(sys::state &state, T t)
std::string format_ratio(int32_t left, int32_t right)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void add_unparsed_text_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view sv, substitution_map const &mp)
columnar_layout create_columnar_layout(sys::state &state, layout &dest, layout_parameters const ¶ms, int32_t column_width)
std::string date_to_string(sys::state &state, sys::date date)
void localised_single_sub_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, variable_type subkey, substitution value)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
std::string prettify(int64_t num)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
std::string format_float(float num, size_t digits)
dcon::text_key get_ruler_title(sys::state &state, dcon::nation_id n)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
std::string get_short_state_name(sys::state &state, dcon::state_instance_id state_id)
uint32_t codepoint_from_utf8(char const *start, char const *end)
void add_line_with_condition(sys::state &state, layout_base &dest, std::string_view key, bool condition_met, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
text::alignment to_text_alignment(ui::alignment in)
text_color char_to_color(char in)
char16_t win1250toUTF16(char in)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
void add_divider_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
dcon::text_key get_adjective(sys::state &state, dcon::nation_id id)
std::string get_dynamic_state_name(sys::state &state, dcon::state_instance_id state_id)
std::string format_wholenum(int32_t num)
size_t size_from_utf8(char const *start, char const *)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
std::string get_adjective_as_string(sys::state &state, T t)
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
std::string format_percentage(float num, size_t digits)
void consume_csv_file(sys::state &state, char const *file_content, uint32_t file_size, int32_t target_column, bool as_unicode)
text::alignment localized_alignment(sys::state &state, text::alignment in)
std::string get_influence_level_name(sys::state const &state, uint8_t v)
variable_type variable_type_from_name(std::string_view v)
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void nation_name_and_flag(sys::state &state, dcon::nation_id n, layout_base &dest, int32_t indent)
std::string get_province_state_name(sys::state &state, dcon::province_id prov_id)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
std::string prettify_currency(float num)
void close_layout_box(columnar_layout &dest, layout_box &box)
std::variant< std::string_view, dcon::text_key, dcon::province_id, dcon::state_instance_id, dcon::nation_id, dcon::national_identity_id, int64_t, fp_one_place, sys::date, std::monostate, fp_two_places, fp_three_places, fp_four_places, fp_currency, pretty_integer, fp_percentage, fp_percentage_one_place, int_percentage, int_wholenum, dcon::state_definition_id, embedded_icon, embedded_flag, embedded_unit_icon > substitution
columnar_layout(layout &base_layout, layout_parameters const &fixed_parameters, layout_base::rtl_status native_rtl, int32_t used_height=0, int32_t used_width=0, int32_t y_cursor=0, int32_t column_width=0)
void internal_close_box(layout_box &box) final
dcon::national_identity_id tag
dcon::unit_type_id unit_type
void internal_close_box(layout_box &box) final
endless_layout(layout &base_layout, layout_parameters const &fixed_parameters, layout_base::rtl_status native_rtl, int32_t y_cursor=0)
virtual void internal_close_box(layout_box &box)=0
layout_parameters fixed_parameters
layout_base(layout &base_layout, layout_parameters const &fixed_parameters, rtl_status native_rtl)
text_chunk const * get_chunk_from_position(int32_t x, int32_t y) const
std::vector< text_chunk > contents
single_line_layout(layout &base_layout, layout_parameters const &fixed_parameters, layout_base::rtl_status native_rtl)
void internal_close_box(layout_box &box) final
void add_text(sys::state &state, std::string_view v)
text::stored_glyphs unicodechars
std::vector< char > & text_data
bool operator()(dcon::text_key l, std::string_view r) const noexcept
bool operator()(std::string const &r, dcon::text_key l) const noexcept
vector_backed_ci_eq(std::vector< char > &text_data)
bool operator()(dcon::text_key l, std::string const &r) const noexcept
bool operator()(std::string_view r, dcon::text_key l) const noexcept
bool operator()(dcon::text_key l, dcon::text_key r) const noexcept
std::vector< char > & text_data
auto operator()(dcon::text_key tag) const noexcept -> uint64_t
auto operator()(std::string_view sv) const noexcept -> uint64_t
vector_backed_ci_hash(std::vector< char > &text_data)
vector_backed_eq(std::vector< char > &text_data)
bool operator()(std::string_view r, dcon::text_key l) const noexcept
bool operator()(dcon::text_key l, std::string const &r) const noexcept
std::vector< char > & text_data
bool operator()(dcon::text_key l, dcon::text_key r) const noexcept
bool operator()(std::string const &r, dcon::text_key l) const noexcept
bool operator()(dcon::text_key l, std::string_view r) const noexcept
auto operator()(dcon::text_key tag) const noexcept -> uint64_t
vector_backed_hash(std::vector< char > &text_data)
std::vector< char > & text_data
auto operator()(std::string_view sv) const noexcept -> uint64_t