<commit_before>#ifndef STAN__COMMON__CONTEXT_FACTORY_HPP
#define STAN__COMMON__CONTEXT_FACTORY_HPP

#include <fstream>
#include <stan/io/dump.hpp>

namespace stan {
  namespace common {

    class var_context_factory {
    public:
      var_context_factory() {}
      virtual stan::io::var_context* operator()(const std::string source) = 0;
    };

    // FIXME: Move to CmdStan
    class dump_factory: public var_context_factory {
    public:
      stan::io::var_context* operator()(const std::string source) {
        std::fstream source_stream(source.c_str(),
                                   std::fstream::in);
        if (source_stream.fail()) {
          std::string message("ERROR: specified initialization file does not exist: ");
          message += source;
          throw std::runtime_error(message);
        }

        stan::io::var_context* dump = new stan::io::dump(source_stream);
        source_stream.close();

        return dump;
      }
    };<commit_msg>adding virtual destructor<commit_after>#ifndef STAN__COMMON__CONTEXT_FACTORY_HPP
#define STAN__COMMON__CONTEXT_FACTORY_HPP

#include <fstream>
#include <stan/io/dump.hpp>

namespace stan {
  namespace common {

    class var_context_factory {
    public:
      var_context_factory() {}
      virtual ~var_context_factory() {}
      virtual stan::io::var_context* operator()(const std::string source) = 0;
    };

    // FIXME: Move to CmdStan
    class dump_factory: public var_context_factory {
    public:
      stan::io::var_context* operator()(const std::string source) {
        std::fstream source_stream(source.c_str(),
                                   std::fstream::in);
        if (source_stream.fail()) {
          std::string message("ERROR: specified initialization file does not exist: ");
          message += source;
          throw std::runtime_error(message);
        }

        stan::io::var_context* dump = new stan::io::dump(source_stream);
        source_stream.close();

        return dump;
      }
    };
{'fraction_non_alphanumeric': 0.1150398406374502, 'fraction_numerical': 0.00099601593625498, 'mean_word_length': 2.8486590038314175, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5307053', 'n_tokens_mistral': 595, 'n_tokens_neox': 588, 'n_words': 122}