#ifndef _TABVIEWER_H
#define _TABVIEWER_H

#include <iostream>
#include <string>
#include <fstream>
#include <vector>

#define SPACE_CHAR 32

enum PHASES { START, FIRST_ROW, INSIDE, DONE };

static const std::string START_TAG = "<table>";
static const std::string END_TAG = "</table>";
static const std::string ROW_START = "<tr>";
static const std::string ROW_END = "</tr>";
static const std::string COL_START = "<td>";
static const std::string COL_END = "</td>";

class TabViewer {

public:

  TabViewer(std::string fileName, int rowWidth) {
    this->rowWidth = rowWidth;
    this->fileName = fileName;
    loadDataFromFile();
    writeOutput();
  }

protected:

  std::string fileName;
  std::vector<std::vector<std::string>> tableData;
  std::ifstream inputF;
  char lastc;
  PHASES phs;
  int colCount, rowWidth;
  size_t *colLengths;

  char myGetChar();
  void loadRow(bool first);
  void loadDataFromFile();
  void writeOutput();
  void writeDivider();
};

#endif