<commit_before>/*
 * Copyright (C) 2014 <NAME>
 * All rights reserved.
 */
#pragma once
#include "../element.h"

#include "../../common/template_utility.hpp"
#include "../../common/translate.h"

#include "../ifont_renderer.h"
namespace game { namespace ui
{
  namespace detail
  {
    struct String_Args
    {
      virtual std::string translate(std::string name) const noexcept = 0;
    };

    template <class... Args>
    struct Tuple_String_Args : public String_Args
    {
      template <class... NArgs>
      Tuple_String_Args(NArgs&&... args) noexcept
                        : tup{std::forward<NArgs>(args)...} {}

      std::string translate(std::string name) const noexcept override;

      std::tuple<Args...> tup;
    };

    template <class... Args> std::string Tuple_String_Args<Args...>
    ::translate(std::string name) const noexcept
    {
      // Call the function with a first argument equal to name followed by the
      // contents of the tuple.
      return call(&game::translate<const Args&...>, tup, name);
    }

  }
  struct Label : public Element
  {
    Label(IFont_Renderer& font) noexcept : font_(&font) {}

    inline std::string str() const noexcept { return str_; }
    inline void str(std::string str) noexcept
    {
      if(str != str_)
      {
        str_ = str;
        invalidate_cache_();
      }
    }

    inline void str_name(std::string name) noexcept
    {
      // Add the at sign denoting the name of a string loaded from the lang
      // file.
      str("@" + name);<commit_msg>The Label can now be constructed without a font renderer.<commit_after>/*
 * Copyright (C) 2014 <NAME>
 * All rights reserved.
 */
#pragma once
#include "../element.h"

#include "../../common/template_utility.hpp"
#include "../../common/translate.h"

#include "../ifont_renderer.h"
namespace game { namespace ui
{
  namespace detail
  {
    struct String_Args
    {
      virtual std::string translate(std::string name) const noexcept = 0;
    };

    template <class... Args>
    struct Tuple_String_Args : public String_Args
    {
      template <class... NArgs>
      Tuple_String_Args(NArgs&&... args) noexcept
                        : tup{std::forward<NArgs>(args)...} {}

      std::string translate(std::string name) const noexcept override;

      std::tuple<Args...> tup;
    };

    template <class... Args> std::string Tuple_String_Args<Args...>
    ::translate(std::string name) const noexcept
    {
      // Call the function with a first argument equal to name followed by the
      // contents of the tuple.
      return call(&game::translate<const Args&...>, tup, name);
    }

  }
  struct Label : public Element
  {
    // Will crash when rendering if a font renderer hasn't been provided.
    Label() noexcept : font_(nullptr) {}

    Label(IFont_Renderer& font) noexcept : font_(&font) {}

    inline std::string str() const noexcept { return str_; }
    inline void str(std::string str) noexcept
    {
      if(str != str_)
      {
        str_ = str;
        invalidate_cache_();
      }
    }

    inline void str_name(std::string name) noexcept
    {
      // Add the at sign denoting the name of a string loaded from the lang
      // file.
      str("@" + name);
{'fraction_non_alphanumeric': 0.13238036047234308, 'fraction_numerical': 0.003107520198881293, 'mean_word_length': 2.453862660944206, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6055479', 'n_tokens_mistral': 972, 'n_tokens_neox': 954, 'n_words': 288}