Boost logo

Boost Users :

Subject: [Boost-users] Boost.Date_Time Enhancement - Load of Time Zone Database via istream
From: Sönke Schau (schaus_at_[hidden])
Date: 2008-10-29 08:15:04


Hello,
in Boost.Date_Time there is a function to load the Time Zone Database
from a File.
The function load_from_file takes a string as parameter which contains a
local filename to load the Database from.

It is sometimes desirable to load the Database from another source than
a local file.

To support this i suppose to add a function load and alter the existing
load_from_file in the following sense

      void load( std::istream& ifs )
      {
        string_type in_str;
        std::string buff;
        
        if(!ifs){
          throw data_not_accessible();
        }
        std::getline(ifs, buff); // first line is column headings

        while( std::getline(ifs, buff)) {
          parse_string(buff);
        }
      }

      void load_from_file(const std::string& pathspec)
      {
        std::ifstream ifs(pathspec.c_str());
        if(!ifs){
          throw data_not_accessible(pathspec);
        }
        load( ifs );
      }

BTW: The documentation local_time.html incorrectly states that
load_from_file returns a boolean.

Best regards
Sönke Schau


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net