code format

This commit is contained in:
2022-12-14 14:13:52 +03:00
parent 430a41fefc
commit c2b8a8d6da
297 changed files with 27331 additions and 24162 deletions

View File

@@ -1,28 +1,28 @@
/*
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 "piresources.h"
#include "piresourcesstorage.h"
PIResources::PIResources() {
}
PIResources::PIResources() {}
PIByteArray PIResources::get(const PIString & section, const PIString & name) {

View File

@@ -5,22 +5,22 @@
* \~russian Подсистема ресурсов
*/
/*
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/>.
*/
//! \defgroup Resources Resources
//! \~\brief
@@ -59,11 +59,14 @@
#include "pistring.h"
#define INIT_RESOURCE(name) {extern void _pirc_##name##_init_(); _pirc_##name##_init_();}
#define INIT_RESOURCE(name) \
{ \
extern void _pirc_##name##_init_(); \
_pirc_##name##_init_(); \
}
class PIP_EXPORT PIResources {
public:
//!
static PIByteArray get(const PIString & section, const PIString & name);
static PIByteArray get(const PIString & name);
@@ -72,7 +75,6 @@ public:
private:
PIResources();
};
#endif // PIRESOURCES_H

View File

@@ -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();
}

View File

@@ -1,35 +1,35 @@
/*
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/>.
*/
#ifndef PIRESOURCES_P_H
#define PIRESOURCES_P_H
#include "pistring.h"
#include "pimap.h"
#include "pichunkstream.h"
#include "pimap.h"
#include "pistring.h"
class PIResources;
class PIP_EXPORT PIResourcesStorage {
friend class PIResources;
public:
public:
static PIResourcesStorage * instance();
struct PIP_EXPORT Section {
@@ -37,19 +37,24 @@ public:
~Section();
void add(const Section & s);
void purge();
PIMap<PIString, PIByteArray * > entries;
PIMap<PIString, PIByteArray *> entries;
};
struct PIP_EXPORT __RCEntry {
__RCEntry(const PIString & s = PIString(), const PIString & n = PIString(), const PIString & a = PIString(),
const PIString & f = PIString(), llong o = 0, llong si = 0, int fl = 0) {
__RCEntry(const PIString & s = PIString(),
const PIString & n = PIString(),
const PIString & a = PIString(),
const PIString & f = PIString(),
llong o = 0,
llong si = 0,
int fl = 0) {
section = s;
name = n;
alias = a;
file = f;
offset = o;
size = si;
flags = fl;
name = n;
alias = a;
file = f;
offset = o;
size = si;
flags = fl;
}
PIString section;
PIString name;
@@ -72,19 +77,19 @@ private:
PIResourcesStorage();
~PIResourcesStorage();
PIMap<PIString, Section * > sections;
PIMap<PIString, Section *> sections;
};
BINARY_STREAM_WRITE(PIResourcesStorage::__RCEntry) {
PIChunkStream cs;
cs.add(1, v.section).add(2, v.name).add(3, v.file).add(4, v.size)
.add(5, v.offset).add(6, v.flags).add(7, v.alias);
cs.add(1, v.section).add(2, v.name).add(3, v.file).add(4, v.size).add(5, v.offset).add(6, v.flags).add(7, v.alias);
s << cs.data();
return s;
}
BINARY_STREAM_READ (PIResourcesStorage::__RCEntry) {
PIByteArray ba; s >> ba;
BINARY_STREAM_READ(PIResourcesStorage::__RCEntry) {
PIByteArray ba;
s >> ba;
PIChunkStream cs(ba);
while (!cs.atEnd()) {
switch (cs.read()) {