<commit_before>#ifndef EXELL_XLSXWORKBOOK_
#define EXELL_XLSXWORKBOOK_

#include <Rcpp.h>
#include "rapidxml.h"
#include "CellType.h"

// Simple parser: does not check that order of numbers and letters is correct
std::pair<int, int> parseRef(std::string ref) {
  int col = 0, row = 0;

  for (std::string::iterator cur = ref.begin(); cur != ref.end(); ++cur) {
    if (*cur >= '0' && *cur <= '9') {
      row = row * 10 + (*cur - '0');
    } else if (*cur >= 'A' && *cur <= 'Z') {
      col = 26 * col + (*cur - 'A' + 1);
    } else {
      Rcpp::stop("Invalid character ('%s') in cell ref", *cur);
    }
  }

  return std::make_pair(row, col);
}

inline std::string zip_buffer(std::string zip_path, std::string file_path) {
  Rcpp::Environment exellEnv = Rcpp::Environment("package:exell");
  Rcpp::Function zip_buffer = exellEnv["zip_buffer"];

  RawVector xml = Rcpp::as<RawVector>(zip_buffer(zip_path, file_path));
  std::string buffer(RAW(xml), RAW(xml) + xml.size());
  buffer.push_back('\0');

  return buffer;
}

class XlsxWorkBook {
  std::string path_;
  std::set<int> dateStyles_;


public:

  XlsxWorkBook(std::string path): path_(path) {
    cacheDateStyles();
  }

  std::vector<std::string> sheets() {<commit_msg>Add misssing Rcpp::<commit_after>#ifndef EXELL_XLSXWORKBOOK_
#define EXELL_XLSXWORKBOOK_

#include <Rcpp.h>
#include "rapidxml.h"
#include "CellType.h"

// Simple parser: does not check that order of numbers and letters is correct
std::pair<int, int> parseRef(std::string ref) {
  int col = 0, row = 0;

  for (std::string::iterator cur = ref.begin(); cur != ref.end(); ++cur) {
    if (*cur >= '0' && *cur <= '9') {
      row = row * 10 + (*cur - '0');
    } else if (*cur >= 'A' && *cur <= 'Z') {
      col = 26 * col + (*cur - 'A' + 1);
    } else {
      Rcpp::stop("Invalid character ('%s') in cell ref", *cur);
    }
  }

  return std::make_pair(row, col);
}

inline std::string zip_buffer(std::string zip_path, std::string file_path) {
  Rcpp::Environment exellEnv = Rcpp::Environment("package:exell");
  Rcpp::Function zip_buffer = exellEnv["zip_buffer"];

  Rcpp::RawVector xml = Rcpp::as<Rcpp::RawVector>(zip_buffer(zip_path, file_path));
  std::string buffer(RAW(xml), RAW(xml) + xml.size());
  buffer.push_back('\0');

  return buffer;
}

class XlsxWorkBook {
  std::string path_;
  std::set<int> dateStyles_;


public:

  XlsxWorkBook(std::string path): path_(path) {
    cacheDateStyles();
  }

  std::vector<std::string> sheets() {
{'fraction_non_alphanumeric': 0.18431689571544058, 'fraction_numerical': 0.00889248181083266, 'mean_word_length': 4.145530145530145, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '1259642', 'n_tokens_mistral': 929, 'n_tokens_neox': 907, 'n_words': 218}