Commit ac8723ea authored by Paul Asmuth's avatar Paul Asmuth
Browse files

InputStream#readNextByte

parent 239812ad
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ void CSVInputStream::readNextRow(std::vector<std::string>* target) {
// FIXPAUL optimize?
std::string CSVInputStream::readNextColumn() {
  std::string column;
  char byte;

  while (input_->readNextByte(&byte)) {
    printf("byte: %c\n", byte);
  }

  return column;
}
+15 −12
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 * Licensed under the MIT license (see LICENSE).
 */
#include <string>
#include <unistd.h>
#include <fcntl.h>
#include "inputstream.h"
#include "runtimeexception.h"
@@ -28,23 +29,25 @@ std::unique_ptr<FileInputStream> FileInputStream::openFile(
FileInputStream::FileInputStream(int fd) : fd_(fd) {}

bool FileInputStream::readNextByte(char* target) {

}

/*
bool CSVInputStream::readNextChunk() {
  if (buf_pos_ >= buf_len_) {
    int bytes_read = read(fd_, buf_, sizeof(buf_));

    if (bytes_read < 0) {
    throw RUNTIME_EXCEPTION_ERRNO(
        &typeid(CSVInputStream),
        ERR_CSV_READ_ERROR,
        "read() failed");
      RAISE_ERRNO(RuntimeException, "read() failed");
    }

  return bytes_read == 0;
    buf_pos_ = 0;
    buf_len_ = bytes_read;
  }


  if (buf_pos_ < buf_len_) {
    *target = buf_[buf_pos_++];
    return true;
  } else {
    return false;
  }
}
*/

}
}
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public:

protected:

  char buf_[4];
  char buf_[8192]; // FIXPAUL make configurable
  size_t buf_len_;
  size_t buf_pos_;
  int fd_;
+4 −4
Original line number Diff line number Diff line
@@ -13,13 +13,13 @@
#define RAISE_EXCEPTION(E) \
    throw (E).setSource(__FILE__, __LINE__, __PRETTY_FUNCTION__); while(0) {}

#define RAISE(E, M, ...) \
    RAISE_EXCEPTION(E((M), __VA_ARGS__).setTypeName(#E)); while(0) {}
#define RAISE(E, ...) \
    RAISE_EXCEPTION(E( __VA_ARGS__).setTypeName(#E)); while(0) {}

#define RAISE_ERRNO(E, M, ...) \
#define RAISE_ERRNO(E, ...) \
    { \
      int e = errno; \
      RAISE_EXCEPTION(E((M), __VA_ARGS__).setTypeName(#E).setErrno(e)); \
      RAISE_EXCEPTION(E(__VA_ARGS__).setTypeName(#E).setErrno(e)); \
    }

namespace fnordmetric {