move most old PIMap iterators to new

Documentation of PIVector, PIMap and PIMapIterator
This commit is contained in:
2020-08-03 01:43:23 +03:00
parent df457a1602
commit 427e7411c1
8 changed files with 280 additions and 70 deletions

View File

@@ -36,13 +36,12 @@ PIByteArray PIResources::get(const PIString & name) {
void PIResources::dump() {
PIMap<PIString, PIResourcesStorage::Section * > & sm(PIResourcesStorage::instance()->sections);
PIMap<PIString, PIResourcesStorage::Section * >::iterator si;
for (si = sm.begin(); si != sm.end(); ++si) {
auto si = PIResourcesStorage::instance()->sections.makeIterator();
while (si.next()) {
piCout << "Section [" << si.key() << "]";
if (!si.value()) continue;
PIMap<PIString, PIByteArray * >::iterator fi;
for (fi = si.value()->entries.begin(); fi != si.value()->entries.end(); ++fi) {
auto fi = si.value()->entries.makeIterator();
while (fi.next()) {
PIString s = fi.key() + ": ";
s << (fi.value() ? fi.value()->size_s() : 0) << " b";
piCout << " " << s;

View File

@@ -31,8 +31,8 @@ PIResourcesStorage::Section::~Section() {
void PIResourcesStorage::Section::add(const PIResourcesStorage::Section & s) {
PIMap<PIString, PIByteArray * >::const_iterator i;
for (i = s.entries.begin(); i != s.entries.end(); ++i) {
auto i = s.entries.makeIterator();
while (i.next()) {
if (!i.value()) continue;
if (entries.value(i.key(), 0)) continue;
entries[i.key()] = i.value();
@@ -83,10 +83,10 @@ void PIResourcesStorage::registerSection(const uchar * rc_data, const uchar * rc
piForeachC (PIResourcesStorage::__RCEntry & e, el) {
ebs[e.section] << e;
}
PIMap<PIString, PIVector<PIResourcesStorage::__RCEntry> >::iterator it;
for (it = ebs.begin(); it != ebs.end(); ++it) {
auto it = ebs.makeIterator();
while (it.next()) {
PIResourcesStorage::Section s;
PIVector<PIResourcesStorage::__RCEntry> & itv(it.value());
const PIVector<PIResourcesStorage::__RCEntry> & itv(it.value());
piForeachC (PIResourcesStorage::__RCEntry & e, itv) {
//piCout << "add" << e.name << e.alias << PIString::readableSize(e.size);
PIByteArray * eba = new PIByteArray(&(rc_data[e.offset]), e.size);
@@ -114,8 +114,8 @@ PIByteArray PIResourcesStorage::get(const PIString & section_name, const PIStrin
PIByteArray PIResourcesStorage::get(const PIString & entry_name) const {
PIMap<PIString, Section * >::const_iterator i;
for (i = sections.begin(); i != sections.end(); ++i) {
auto i = sections.makeIterator();
while (i.next()) {
if (!i.value()) continue;
PIByteArray * ba = i.value()->entries.value(entry_name, 0);
if (!ba) continue;