areas.cpp
/*
  Parse data from an standard input stream, that is of a particular type,
  and with a given column mapping, filtering for specific areas, measures,
  and years, and fill the container will populates the areas contanour with
  the matching data.

  @param is
    The input stream from InputSource

  @param type
    A value from the BethYw::SourceDataType enum which states the underlying
    data file structure

  @param cols
    A map of the enum BethyYw::SourceColumnMapping (see datasets.h) to strings
    that give the column header in the CSV file

  @param areasFilter
    An umodifiable pointer to set of umodifiable strings for areas to import,
    or an empty set if all areas should be imported

  @param measuresFilter
    An umodifiable pointer to set of umodifiable strings for measures to import,
    or an empty set if all measures should be imported

  @param yearsFilter
    An umodifiable pointer to an umodifiable tuple of two unsigned integers,
    where if both values are 0, then all years should be imported, otherwise
    they should be treated as a the range of years to be imported

  @return
    void

  @throws 
    std::runtime_error if a parsing error occurs (e.g. due to a malformed file),
    the stream is not open/valid/has any contents, or an unexpected type
    is passed in.
    std::out_of_range if there are not enough columns in cols

  @see
    See datasets.h for details of the values variable type can have

  @see
    See datasets.h for details of how the variable cols is organised

  @see
    See bethyw.cpp for details of how the variables areasFilter, measuresFilter,
    and yearsFilter are created

  @example
    InputFile input("data/popu1009.json");
    auto is = input.open();

    auto cols = InputFiles::DATASETS["popden"].COLS;

    auto areasFilter = BethYw::parseAreasArg();
    auto measuresFilter = BethYw::parseMeasuresArg();
    auto yearsFilter = BethYw::parseMeasuresArg();

    Areas data = Areas();
    areas.populate(
      is,
      DataType::WelshStatsJSON,
      cols,
      &areasFilter,
      &measuresFilter,
      &yearsFilter);
*/
Parse data from an standard input stream, that is of a particular type,
and with a given column mapping, filtering for specific areas, measures,
and years, and fill the container will populates the areas contanour with
the matching data.
Parse data from an standard input stream that is of a particular type and with a given column mapping filtering for specific areas measures and years and fill the container will populates the areas contanour with the matching data .
void Areas::populate(
    std::istream &is,
    const BethYw::SourceDataType &type,
    const BethYw::SourceColumnMapping &cols,
    const StringFilterSet * const areasFilter,
    const StringFilterSet * const measuresFilter,
    const YearFilterTuple * const yearsFilter){
  if (type == BethYw::AuthorityCodeCSV && !(cols.size() < 3)) {
      populateFromAuthorityCodeCSV(is, cols, areasFilter);
  } else if(type == BethYw::AuthorityByYearCSV && !(cols.size() < 3)){
      populateFromAuthorityByYearCSV(is, cols, areasFilter, measuresFilter, yearsFilter);
  } else if(type == BethYw::WelshStatsJSON && !(cols.size() < 6 )) {
      populateFromWelshStatsJSON(is, cols, areasFilter, measuresFilter, yearsFilter);
  }else{
    throw std::runtime_error("Areas::populate: Unexpected data type");
  }
}
void Areas :: populate ( std :: istream & is , const BethYw :: SourceDataType & type , const BethYw :: SourceColumnMapping & cols , const StringFilterSet * const areasFilter , const StringFilterSet * const measuresFilter , const YearFilterTuple * const yearsFilter ) { if ( type == BethYw :: AuthorityCodeCSV && ! ( cols . size ( ) < 3 ) ) { populateFromAuthorityCodeCSV ( is , cols , areasFilter ) ; } else if ( type == BethYw :: AuthorityByYearCSV && ! ( cols . size ( ) < 3 ) ) { populateFromAuthorityByYearCSV ( is , cols , areasFilter , measuresFilter , yearsFilter ) ; } else if ( type == BethYw :: WelshStatsJSON && ! ( cols . size ( ) < 6 ) ) { populateFromWelshStatsJSON ( is , cols , areasFilter , measuresFilter , yearsFilter ) ; } else { throw std :: runtime_error ( " " ) ; } }
Parse data from an standard input stream, that is of a particular type,
and with a given column mapping, filtering for specific areas, measures,
and years, and fill the container will populates the areas contanour with
the matching data.
Parse data from an standard input stream that is of a particular type and with a given column mapping filtering for specific areas measures and years and fill the container will populates the areas contanour with the matching data .