Skip to content

Commit

Permalink
clean up src ref #2 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot authored Mar 15, 2024
1 parent de9cd7d commit 4e5422f
Show file tree
Hide file tree
Showing 18 changed files with 0 additions and 3,691 deletions.
4 changes: 0 additions & 4 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ utctime_ <- function(year, month, day, hour, min, sec, psec) {
.Call(`_minty_utctime_`, year, month, day, hour, min, sec, psec)
}

guess_header_ <- function(sourceSpec, tokenizerSpec, locale_) {
.Call(`_minty_guess_header_`, sourceSpec, tokenizerSpec, locale_)
}

parse_vector_ <- function(x, collectorSpec, locale_, na, trim_ws) {
.Call(`_minty_parse_vector_`, x, collectorSpec, locale_, na, trim_ws)
}
Expand Down
6 changes: 0 additions & 6 deletions src/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "cpp11/strings.hpp"

#include "Source.h"
#include "SourceFile.h"
#include "SourceRaw.h"
#include "SourceString.h"

Expand All @@ -24,11 +23,6 @@ SourcePtr Source::create(const cpp11::list& spec) {
new SourceString(spec[0], skip, skipEmptyRows, comment, skipQuote));
}

if (subclass == "source_file") {
cpp11::strings path(spec[0]);
return SourcePtr(new SourceFile(Rf_translateCharUTF8(path[0]), skip, skipEmptyRows, comment, skipQuote));
}

cpp11::stop("Unknown source type");
return SourcePtr();
}
Expand Down
45 changes: 0 additions & 45 deletions src/SourceFile.h

This file was deleted.

54 changes: 0 additions & 54 deletions src/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,18 @@
#include "cpp11/list.hpp"

#include "Tokenizer.h"
#include "TokenizerDelim.h"
#include "TokenizerFwf.h"
#include "TokenizerLine.h"
#include "TokenizerLog.h"
#include "TokenizerWs.h"

TokenizerPtr Tokenizer::create(const cpp11::list& spec) {
std::string subclass(cpp11::strings(spec.attr("class"))[0]);

if (subclass == "tokenizer_delim") {
char delim = cpp11::as_cpp<char>(spec["delim"]);
char quote = cpp11::as_cpp<char>(spec["quote"]);
std::vector<std::string> na =
cpp11::as_cpp<std::vector<std::string>>(spec["na"]);
std::string comment = cpp11::as_cpp<std::string>(spec["comment"]);
bool trimWs = cpp11::as_cpp<bool>(spec["trim_ws"]);
bool escapeDouble = cpp11::as_cpp<bool>(spec["escape_double"]);
bool escapeBackslash = cpp11::as_cpp<bool>(spec["escape_backslash"]);
bool quotedNA = cpp11::as_cpp<bool>(spec["quoted_na"]);
bool skipEmptyRows = cpp11::as_cpp<bool>(spec["skip_empty_rows"]);

return TokenizerPtr(new TokenizerDelim(
delim,
quote,
na,
comment,
trimWs,
escapeBackslash,
escapeDouble,
quotedNA,
skipEmptyRows));
}

if (subclass == "tokenizer_fwf") {
std::vector<int> begin = cpp11::as_cpp<std::vector<int>>(spec["begin"]);
std::vector<int> end = cpp11::as_cpp<std::vector<int>>(spec["end"]);
std::vector<std::string> na =
cpp11::as_cpp<std::vector<std::string>>(spec["na"]);
std::string comment = cpp11::as_cpp<std::string>(spec["comment"]);
bool trimWs = cpp11::as_cpp<bool>(spec["trim_ws"]);
bool skipEmptyRows = cpp11::as_cpp<bool>(spec["skip_empty_rows"]);
return TokenizerPtr(
new TokenizerFwf(begin, end, na, comment, trimWs, skipEmptyRows));
}

if (subclass == "tokenizer_line") {
std::vector<std::string> na =
cpp11::as_cpp<std::vector<std::string>>(spec["na"]);
bool skipEmptyRows = cpp11::as_cpp<bool>(spec["skip_empty_rows"]);
return TokenizerPtr(new TokenizerLine(na, skipEmptyRows));
}

if (subclass == "tokenizer_log") {
bool trimWs = cpp11::as_cpp<bool>(spec["trim_ws"]);

return TokenizerPtr(new TokenizerLog(trimWs));
}

if (subclass == "tokenizer_ws") {
std::vector<std::string> na =
cpp11::as_cpp<std::vector<std::string>>(spec["na"]);
std::string comment = cpp11::as_cpp<std::string>(spec["comment"]);
bool skipEmptyRows = cpp11::as_cpp<bool>(spec["skip_empty_rows"]);
return TokenizerPtr(new TokenizerWs(na, comment, skipEmptyRows));
}

cpp11::stop("Unknown tokenizer type");
return TokenizerPtr();
}
Loading

0 comments on commit 4e5422f

Please sign in to comment.