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

@@ -3,24 +3,24 @@
* \~\brief
* \~english Base types and functions
* \~russian Базовые типы и методы
*/
*/
/*
PIP - Platform Independent Primitives
Base types and functions
Ivan Pelipenko peri4ko@yandex.ru
PIP - Platform Independent Primitives
Base types and functions
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 PIMEMORYBLOCK_H
@@ -34,40 +34,53 @@
//! \~russian Вспомогательная структура для сохранения/извлечения произвольного блока данных в/из PIBinaryStream
struct PIMemoryBlock {
public:
//! \~english Constructs data block
//! \~russian Создает блок данных
PIMemoryBlock(void * data_ = 0, int size_ = 0) {
d = data_;
s = size_;
}
//! \~english Constructs data block
//! \~russian Создает блок данных
PIMemoryBlock(void * data_ = 0, int size_ = 0) {d = data_; s = size_;}
PIMemoryBlock(const void * data_, const int size_) {
d = const_cast<void *>(data_);
s = size_;
}
//! \~english Constructs data block
//! \~russian Создает блок данных
PIMemoryBlock(const void * data_, const int size_) {d = const_cast<void * >(data_); s = size_;}
PIMemoryBlock(const PIMemoryBlock & o) {
d = o.d;
s = o.s;
}
PIMemoryBlock(const PIMemoryBlock & o) {d = o.d; s = o.s;}
PIMemoryBlock & operator =(const PIMemoryBlock & o) {d = o.d; s = o.s; return *this;}
PIMemoryBlock & operator=(const PIMemoryBlock & o) {
d = o.d;
s = o.s;
return *this;
}
//! \~english Pointer to data
//! \~russian Указатель на данные
void * data() {return d;}
void * data() { return d; }
//! \~english Pointer to data
//! \~russian Указатель на данные
const void * data() const {return d;}
const void * data() const { return d; }
//! \~english Size of data in bytes
//! \~russian Размер данных в байтах
int size() const {return s;}
int size() const { return s; }
private:
void * d;
int s;
};
//! \~english Returns PIMemoryBlock from pointer to variable "ptr" with type "T"
//! \~russian Возвращает PIMemoryBlock из указателя "ptr" типа "T"
template<typename T>
PIMemoryBlock createMemoryBlock(const T * ptr) {return PIMemoryBlock(ptr, sizeof(T));}
PIMemoryBlock createMemoryBlock(const T * ptr) {
return PIMemoryBlock(ptr, sizeof(T));
}
#endif // PIMEMORYBLOCK_H