const string Package::FullTitle(bool localized) const { string expanded = ExpandedTitle(localized); if ( !expanded.empty() ) return expanded; auto items = PropertiesMatching(DCType::Title); if ( items.size() == 1 ) return items[0]->Value(); IRI displaySeqIRI(MakePropertyIRI("display-seq")); // http://idpf.org/epub/vocab/package/#display-seq std::vector<string> titles(items.size()); auto sequencedItems = PropertiesMatching(displaySeqIRI); if ( !sequencedItems.empty() ) { // all these have a 1-based sequence number for ( auto item : sequencedItems ) { PropertyExtensionPtr extension = item->ExtensionWithIdentifier(displaySeqIRI); size_t sz = strtoul(extension->Value().c_str(), nullptr, 10) - 1; titles[sz] = (localized ? item->LocalizedValue() : item->Value()); } } else { titles.clear(); // insert any non-sequenced items at the head of the list, in order for ( auto item : items ) { titles.emplace_back((localized ? item->LocalizedValue() : item->Value())); } } // put them all together now auto pos = titles.begin(); // TODO: this ought to be localized based on the value of Language(). std::stringstream ss; ss << *(pos++) << ": " << *(pos++); while ( pos != titles.end() ) { ss << ", " << *(pos++); } return string(ss.str()); }
const string Package::FullTitle() const { MetadataMap items = MetadataItemsWithDCType(Metadata::DCType::Title); if ( items.size() == 1 ) return items[0]->Value(); IRI displaySeqIRI(MakePropertyIRI("display-seq")); // http://idpf.org/epub/vocab/package/#display-seq std::vector<string> titles(items.size()); MetadataMap sequencedItems = MetadataItemsWithProperty(displaySeqIRI); if ( !sequencedItems.empty() ) { // all these have a 1-based sequence number for ( auto item : sequencedItems ) { const Metadata::Extension* extension = item->ExtensionWithProperty(displaySeqIRI); size_t sz = strtoul(extension->Value().c_str(), nullptr, 10) - 1; titles[sz] = item->Value(); } } else { titles.clear(); // insert any non-sequenced items at the head of the list, in order for ( auto item : items ) { titles.emplace_back(item->Value()); } } // put them all together now auto pos = titles.begin(); // TODO: this ought to be localized based on the value of Language(). std::stringstream ss; ss << *(pos++) << ": " << *(pos++); while ( pos != titles.end() ) { ss << ", " << *(pos++); } return string(ss.str()); }