#pragma once 

#include "state_data.h"
#include "xhtml_doc.h"
#include "helper_constructs.h"
#ifdef WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#endif


namespace Xport_report_suite
{
  class us_state_report_generator;
}

class Xport_report_suite::us_state_report_generator
{
public:
  us_state_report_generator();
  ~us_state_report_generator();

  // public interface
  void generate_report(Xport::document&, Xport::stylesheet& ss) const;
  std::string report_path() const;
  void create_directory() const;

protected:
  void get_state_data(std::vector<state_info>& siv, state_sort_field sf, sort_order so = ascending) const;
  void get_divisional_state_data(int dvsn, std::vector<state_info>& siv, state_sort_field sf, sort_order so) const;
  void get_regional_state_data(int rgn, std::vector<state_info>& siv, state_sort_field sf, sort_order so) const;
  std::string get_region_name(int region) const;
  std::string get_division_name(int division) const;
  std::string numeric_format(double num, int dec) const;
  std::string numeric_format(int num) const;

private:
  virtual void create_header(Xport::document& doc) const = 0;
  virtual void create_report_body(Xport::document& doc) const = 0;
  virtual void create_footer(Xport::document& doc) const = 0;
  virtual void create_stylesheet(Xport::document& doc, Xport::stylesheet& ss) const = 0;
  virtual std::string report_dir() const = 0;
  virtual std::string report_name() const = 0;

  // data
  mutable std::vector<state_info> state_info_vec;
  mutable state_sort_field current_sort_field;
  typedef std::pair<std::vector<state_info>::const_iterator, std::vector<state_info>::const_iterator > siv_range;
};