code format
This commit is contained in:
@@ -1,33 +1,32 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Resources subsystem
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Resources subsystem
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piresourcesstorage.h"
|
||||
|
||||
#include "pichunkstream.h"
|
||||
#include "piset.h"
|
||||
|
||||
|
||||
PIResourcesStorage::Section::Section() {
|
||||
}
|
||||
PIResourcesStorage::Section::Section() {}
|
||||
|
||||
|
||||
PIResourcesStorage::Section::~Section() {
|
||||
}
|
||||
PIResourcesStorage::Section::~Section() {}
|
||||
|
||||
|
||||
void PIResourcesStorage::Section::add(const PIResourcesStorage::Section & s) {
|
||||
@@ -41,22 +40,19 @@ void PIResourcesStorage::Section::add(const PIResourcesStorage::Section & s) {
|
||||
|
||||
|
||||
void PIResourcesStorage::Section::purge() {
|
||||
PIVector<PIByteArray * > bav = entries.values();
|
||||
PISet<PIByteArray * > bas;
|
||||
piForeach (PIByteArray * i, bav) {
|
||||
if (i)
|
||||
bas << i;
|
||||
PIVector<PIByteArray *> bav = entries.values();
|
||||
PISet<PIByteArray *> bas;
|
||||
piForeach(PIByteArray * i, bav) {
|
||||
if (i) bas << i;
|
||||
}
|
||||
bav = bas.toVector();
|
||||
piForeach (PIByteArray * i, bav)
|
||||
piForeach(PIByteArray * i, bav)
|
||||
delete i;
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
|
||||
PIResourcesStorage::PIResourcesStorage() {
|
||||
|
||||
}
|
||||
PIResourcesStorage::PIResourcesStorage() {}
|
||||
|
||||
|
||||
PIResourcesStorage::~PIResourcesStorage() {
|
||||
@@ -67,7 +63,7 @@ PIResourcesStorage::~PIResourcesStorage() {
|
||||
void PIResourcesStorage::registerSection(const PIString & section_name, const PIResourcesStorage::Section & data) {
|
||||
Section * s = sections.value(section_name, 0);
|
||||
if (!s) {
|
||||
s = new Section();
|
||||
s = new Section();
|
||||
sections[section_name] = s;
|
||||
}
|
||||
s->add(data);
|
||||
@@ -75,24 +71,23 @@ void PIResourcesStorage::registerSection(const PIString & section_name, const PI
|
||||
|
||||
|
||||
void PIResourcesStorage::registerSection(const uchar * rc_data, const uchar * rc_desc, int rc_desc_size) {
|
||||
//piCout << "registerSection" << this;
|
||||
// piCout << "registerSection" << this;
|
||||
PIByteArray dba(rc_desc, rc_desc_size);
|
||||
PIVector<PIResourcesStorage::__RCEntry> el;
|
||||
dba >> el;
|
||||
PIMap<PIString, PIVector<PIResourcesStorage::__RCEntry> > ebs;
|
||||
piForeachC (PIResourcesStorage::__RCEntry & e, el) {
|
||||
PIMap<PIString, PIVector<PIResourcesStorage::__RCEntry>> ebs;
|
||||
piForeachC(PIResourcesStorage::__RCEntry & e, el) {
|
||||
ebs[e.section] << e;
|
||||
}
|
||||
auto it = ebs.makeIterator();
|
||||
while (it.next()) {
|
||||
PIResourcesStorage::Section s;
|
||||
const PIVector<PIResourcesStorage::__RCEntry> & itv(it.value());
|
||||
piForeachC (PIResourcesStorage::__RCEntry & e, itv) {
|
||||
//piCout << "add" << e.name << e.alias << PIString::readableSize(e.size);
|
||||
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);
|
||||
s.entries[e.name] = eba;
|
||||
if (!e.alias.isEmpty() && e.alias != e.name)
|
||||
s.entries[e.alias] = eba;
|
||||
if (!e.alias.isEmpty() && e.alias != e.name) s.entries[e.alias] = eba;
|
||||
}
|
||||
registerSection(it.key(), s);
|
||||
}
|
||||
@@ -126,11 +121,10 @@ PIByteArray PIResourcesStorage::get(const PIString & entry_name) const {
|
||||
|
||||
|
||||
void PIResourcesStorage::clear() {
|
||||
//piCout << "PIResourcesStorage clear";
|
||||
PIVector<Section * > sv = sections.values();
|
||||
piForeach (Section * i, sv) {
|
||||
if (i)
|
||||
i->purge();
|
||||
// piCout << "PIResourcesStorage clear";
|
||||
PIVector<Section *> sv = sections.values();
|
||||
piForeach(Section * i, sv) {
|
||||
if (i) i->purge();
|
||||
}
|
||||
sections.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user