@@ -78,7 +78,7 @@ auto is_issue_xml_file(fs::directory_entry const & e) {
7878 return false ;
7979}
8080
81- auto read_issues (fs::path const & issues_path, lwg::section_map & section_db ) -> std::vector<lwg::issue> {
81+ auto read_issues (fs::path const & issues_path, lwg::metadata & meta ) -> std::vector<lwg::issue> {
8282 // Open the specified directory, 'issues_path', and iterate all the '.xml' files
8383 // it contains, parsing each such file as an LWG issue document. Return the set
8484 // of issues as a vector.
@@ -87,7 +87,7 @@ auto read_issues(fs::path const & issues_path, lwg::section_map & section_db) ->
8787 for (auto ent : fs::directory_iterator (issues_path)) {
8888 if (is_issue_xml_file (ent)) {
8989 fs::path const issue_file = ent.path ();
90- issues.emplace_back (parse_issue_from_file (read_file_into_string (issue_file), issue_file.string (), section_db ));
90+ issues.emplace_back (parse_issue_from_file (read_file_into_string (issue_file), issue_file.string (), meta ));
9191 }
9292 }
9393
@@ -218,18 +218,9 @@ namespace
218218 };
219219}
220220
221- std::unordered_map<std::string, std::string> paper_titles = [] {
222- std::unordered_map<std::string, std::string> titles;
223- std::ifstream in{" meta-data/paper_titles.txt" };
224- std::string paper_number, title;
225- while (in >> paper_number && std::getline (in, title))
226- titles[paper_number] = title;
227- return titles;
228- }();
229-
230221// The title of the specified paper, formatted as an HTML title="..." attribute.
231- std::string paper_title_attr (std::string paper_number) {
232- auto title = paper_titles[paper_number];
222+ std::string paper_title_attr (std::string paper_number, lwg::metadata& meta ) {
223+ auto title = meta. paper_titles [paper_number];
233224 if (!title.empty ())
234225 {
235226 title = lwg::replace_reserved_char (std::move (title), ' &' , " &" );
@@ -242,8 +233,9 @@ std::string paper_title_attr(std::string paper_number) {
242233void format_issue_as_html (lwg::issue & is,
243234 std::vector<lwg::issue>::iterator first_issue,
244235 std::vector<lwg::issue>::iterator last_issue,
245- lwg::section_map & section_db ) {
236+ lwg::metadata & meta ) {
246237
238+ auto & section_db = meta.section_db ;
247239 std::vector<std::string> tag_stack; // stack of open XML tags as we parse
248240
249241 // Used by fix_tags to report errors.
@@ -453,7 +445,7 @@ void format_issue_as_html(lwg::issue & is,
453445 std::transform (paper_number.begin (), paper_number.end (), paper_number.begin (),
454446 [] (unsigned char c) { return std::toupper (c); });
455447
456- auto title = paper_title_attr (paper_number);
448+ auto title = paper_title_attr (paper_number, meta );
457449
458450 j -= i - 1 ;
459451 std::string r = " <a href=\" https://wg21.link/" + paper_number + " \" " + title + " >" + paper_number + " </a>" ;
@@ -497,7 +489,7 @@ void format_issue_as_html(lwg::issue & is,
497489}
498490
499491
500- void prepare_issues (std::vector<lwg::issue> & issues, lwg::section_map & section_db ) {
492+ void prepare_issues (std::vector<lwg::issue> & issues, lwg::metadata & meta ) {
501493 // Initially sort the issues by issue number, so each issue can be correctly 'format'ted
502494 sort (issues.begin (), issues.end (), lwg::order_by_issue_number{});
503495
@@ -507,7 +499,7 @@ void prepare_issues(std::vector<lwg::issue> & issues, lwg::section_map & section
507499 // Currently, the 'format' function takes a reference-to-non-const-vector-of-issues purely to
508500 // mark up information related to duplicates, so processing duplicates in a separate pass may
509501 // clarify the code.
510- for (auto & i : issues) { format_issue_as_html (i, issues.begin (), issues.end (), section_db ); }
502+ for (auto & i : issues) { format_issue_as_html (i, issues.begin (), issues.end (), meta ); }
511503
512504 // Issues will be routinely re-sorted in later code, but contents should be fixed after formatting.
513505 // This suggests we may want to be storing some kind of issue handle in the functions that keep
@@ -754,20 +746,10 @@ int main(int argc, char* argv[]) {
754746 const fs::path target_path{path / " mailing" };
755747 check_is_directory (target_path);
756748
757-
758- lwg::section_map section_db =[&path]() {
759- auto filename = path / " meta-data" / " section.data" ;
760- std::ifstream infile{filename};
761- if (!infile.is_open ()) {
762- throw std::runtime_error{" Can't open section.data at " + path.string () + " meta-data" };
763- }
764- std::cout << " Reading section-tag index from: " << filename << std::endl;
765-
766- return lwg::read_section_db (infile);
767- }();
749+ auto metadata = lwg::metadata::read_from_path (path);
768750#if defined (DEBUG_LOGGING)
769751 // dump the contents of the section index
770- for (auto const & elem : section_db ) {
752+ for (auto const & elem : metadata. section_db ) {
771753 std::string temp = elem.first ;
772754 temp.erase (temp.end ()-1 );
773755 temp.erase (temp.begin ());
@@ -793,11 +775,11 @@ int main(int argc, char* argv[]) {
793775
794776
795777 std::cout << " Reading issues from: " << issues_path << std::endl;
796- auto issues = read_issues (issues_path, section_db );
797- prepare_issues (issues, section_db );
778+ auto issues = read_issues (issues_path, metadata );
779+ prepare_issues (issues, metadata );
798780
799781
800- lwg::report_generator generator{lwg_issues_xml, section_db};
782+ lwg::report_generator generator{lwg_issues_xml, metadata. section_db };
801783
802784
803785 // issues must be sorted by number before making the mailing list documents
0 commit comments