<commit_before>#pragma once

/*
 * Factories for variable names. The key feature of a variable name is
 * that it can be indexed in a datastructure such as patricia trees by
 * providing the method index().
 */

#include <crab/support/debug.hpp>
#include <crab/support/os.hpp>
#include <crab/types/indexable.hpp>

#include <boost/optional.hpp>
#include <boost/range/iterator_range.hpp>

#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <unordered_map>
#include <vector>

namespace crab {

/* T is the template parameter of var_factory_impl::variable_factory */
template <typename T> class variable_name_traits {
public:
  static std::string to_string(T varname);
};

namespace var_factory_impl {

template <typename T> class variable_factory;

template <class T> class indexed_varname : public indexable {
  template <typename Any> friend class variable_factory;

  using this_type = indexed_varname<T>;
  using variable_factory_t = variable_factory<T>;

  boost::optional<T> m_s;
  ikos::index_t m_id;
  // optional string name associated with m_id if m_s is boost::none
  std::shared_ptr<std::string> m_name;
  variable_factory_t *m_vfac;

  indexed_varname() = delete;
  // first constructor
  indexed_varname(ikos::index_t id, variable_factory_t *vfac,
                  std::string name = "")
      : m_s(boost::none), m_id(id),
        m_name(name == "" ? nullptr : std::make_shared<std::string>(name)),
        m_vfac(vfac) {}
  // second constructor
  indexed_varname(T s, ikos::index_t id, variable_factory_t *vfac)
      : m_s(s), m_id(id), m_name(nullptr), m_vfac(vfac) {}

  std::string rename(const std::string &s) const {
    auto it = m_vfac->get_renaming_map().find(s);
    if (it != m_vfac->get_renaming_map().end()) {
      return it->second;
    } else {
      return s;
    }
  }

public:<commit_msg>fix: expose typedef<commit_after>#pragma once

/*
 * Factories for variable names. The key feature of a variable name is
 * that it can be indexed in a datastructure such as patricia trees by
 * providing the method index().
 */

#include <crab/support/debug.hpp>
#include <crab/support/os.hpp>
#include <crab/types/indexable.hpp>

#include <boost/optional.hpp>
#include <boost/range/iterator_range.hpp>

#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <unordered_map>
#include <vector>

namespace crab {

/* T is the template parameter of var_factory_impl::variable_factory */
template <typename T> class variable_name_traits {
public:
  static std::string to_string(T varname);
};

namespace var_factory_impl {

template <typename T> class variable_factory;

template <class T> class indexed_varname : public indexable {
  template <typename Any> friend class variable_factory;
public:  
  using variable_factory_t = variable_factory<T>;
  
private:
  using this_type = indexed_varname<T>;
  
  boost::optional<T> m_s;
  ikos::index_t m_id;
  // optional string name associated with m_id if m_s is boost::none
  std::shared_ptr<std::string> m_name;
  variable_factory_t *m_vfac;

  indexed_varname() = delete;
  // first constructor
  indexed_varname(ikos::index_t id, variable_factory_t *vfac,
                  std::string name = "")
      : m_s(boost::none), m_id(id),
        m_name(name == "" ? nullptr : std::make_shared<std::string>(name)),
        m_vfac(vfac) {}
  // second constructor
  indexed_varname(T s, ikos::index_t id, variable_factory_t *vfac)
      : m_s(s), m_id(id), m_name(nullptr), m_vfac(vfac) {}

  std::string rename(const std::string &s) const {
    auto it = m_vfac->get_renaming_map().find(s);
    if (it != m_vfac->get_renaming_map().end()) {
      return it->second;
    } else {
      return s;
    }
  }

public:
{'fraction_non_alphanumeric': 0.12342704149933066, 'fraction_numerical': 0.0, 'mean_word_length': 4.225174825174825, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 49, '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': '3209303', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1256, 'n_words': 325}