| 786 | } |
| 787 | |
| 788 | void StringHasher::Restore(Base::XMLReader& reader) |
| 789 | { |
| 790 | clear(); |
| 791 | reader.readElement("StringHasher"); |
| 792 | _hashes->SaveAll = reader.getAttribute<long>("saveall") != 0L; |
| 793 | _hashes->Threshold = reader.getAttribute<int>("threshold"); |
| 794 | |
| 795 | bool newTag = false; |
| 796 | if (reader.hasAttribute("new") && reader.getAttribute<bool>("new")) { |
| 797 | reader.readElement("StringHasher2"); |
| 798 | newTag = true; |
| 799 | } |
| 800 | |
| 801 | if (reader.hasAttribute("file")) { |
| 802 | const char* file = reader.getAttribute<const char*>("file"); |
| 803 | if (*file != '\0') { |
| 804 | reader.addFile(file, this); |
| 805 | } |
| 806 | return; |
| 807 | } |
| 808 | |
| 809 | std::size_t count = reader.getAttribute<unsigned long>("count"); |
| 810 | if (newTag) { |
| 811 | try { |
| 812 | restoreStreamNew(reader.beginCharStream(), count); |
| 813 | } |
| 814 | catch (const Base::Exception& e) { |
| 815 | e.reportException(); |
| 816 | FC_ERR("Failed to restore string table: full-document recompute strongly recommended."); |
| 817 | } |
| 818 | reader.readEndElement("StringHasher2"); |
| 819 | return; |
| 820 | } |
| 821 | if ((count != 0U) && reader.FileVersion > 1) { |
| 822 | restoreStream(reader.beginCharStream(), count); |
| 823 | } |
| 824 | else { |
| 825 | for (std::size_t i = 0; i < count; ++i) { |
| 826 | reader.readElement("Item"); |
| 827 | StringIDRef sid; |
| 828 | long id = reader.getAttribute<long>("id"); |
| 829 | bool hashed = reader.hasAttribute("hash"); |
| 830 | if (hashed || reader.hasAttribute("data")) { |
| 831 | const char* value = |
| 832 | hashed ? reader.getAttribute<const char*>("hash") : reader.getAttribute<const char*>("data"); |
| 833 | sid = new StringID(id, QByteArray::fromBase64(value), StringID::Flag::Hashed); |
| 834 | } |
| 835 | else { |
| 836 | sid = new StringID(id, QByteArray(reader.getAttribute<const char*>("text"))); |
| 837 | } |
| 838 | insert(sid); |
| 839 | } |
| 840 | } |
| 841 | reader.readEndElement("StringHasher"); |
| 842 | } |
| 843 | |
| 844 | unsigned int StringHasher::getMemSize() const |
| 845 | { |
nothing calls this directly
no test coverage detected