more literals, use some in PIP, small refactor PIThread::start (clang-format mistakes)
This commit is contained in:
40
libs/main/literals/piliterals.h
Normal file
40
libs/main/literals/piliterals.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*! \file piliterals.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english C++11 literals
|
||||
* \~russian C++11 суффиксы
|
||||
*
|
||||
* \~\details
|
||||
* \~english
|
||||
* Include all literals_*.h files
|
||||
* \~russian
|
||||
* Включает все файлы literals_*.h
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
C++11 literals
|
||||
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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PILITERALS_H
|
||||
#define PILITERALS_H
|
||||
|
||||
#include "piliterals_bytearray.h"
|
||||
#include "piliterals_bytes.h"
|
||||
#include "piliterals_string.h"
|
||||
#include "piliterals_time.h"
|
||||
|
||||
#endif
|
||||
46
libs/main/literals/piliterals_bytearray.h
Normal file
46
libs/main/literals/piliterals_bytearray.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*! \file piliterals_bytearray.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english PIByteArray C++11 literals
|
||||
* \~russian C++11 суффиксы PIByteArray
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIByteArray C++11 literals
|
||||
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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PILITERALS_BYTEARRAY_H
|
||||
#define PILITERALS_BYTEARRAY_H
|
||||
|
||||
#include "pibytearray.h"
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PIByteArray from hex string (e.g. "1a2e3f")
|
||||
//! \~russian PIByteArray из hex строки (например "1a2e3f")
|
||||
inline PIByteArray operator""_hex(const char * v, size_t sz) {
|
||||
return PIByteArray::fromHex(PIStringAscii(v, sz));
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PIByteArray from base64 string (e.g. "aGVsbG8=")
|
||||
//! \~russian PIByteArray из base64 строки (например "aGVsbG8=")
|
||||
inline PIByteArray operator""_base64(const char * v, size_t sz) {
|
||||
return PIByteArray::fromBase64(PIStringAscii(v, sz));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
185
libs/main/literals/piliterals_bytes.h
Normal file
185
libs/main/literals/piliterals_bytes.h
Normal file
@@ -0,0 +1,185 @@
|
||||
/*! \file piliterals_bytes.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Bytes C++11 literals for bytes
|
||||
* \~russian C++11 байтовые суффиксы
|
||||
*
|
||||
* \~\details
|
||||
* \~english
|
||||
* Declare suffixes:
|
||||
* * _KB, _MB, _GB, _TB, _PB - power of 10
|
||||
* * _KiB, _MiB, _GiB, _TiB, _PiB - power of 2
|
||||
* \~russian
|
||||
* Объявляет суффиксы:
|
||||
* * _KB, _MB, _GB, _TB, _PB - степени 10
|
||||
* * _KiB, _MiB, _GiB, _TiB, _PiB - степени 2
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Bytes C++11 literals for bytes
|
||||
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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PILITERALS_BYTES_H
|
||||
#define PILITERALS_BYTES_H
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Kilobytes, x1000
|
||||
//! \~russian Килобайт, x1000
|
||||
constexpr unsigned long long operator""_KB(long double v) {
|
||||
return v * 1000.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Kilobytes, x1000
|
||||
//! \~russian Килобайт, x1000
|
||||
constexpr unsigned long long operator""_KB(unsigned long long v) {
|
||||
return v * 1000;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Kibibytes, x1024 (2^10)
|
||||
//! \~russian Кибибайт, x1024 (2^10)
|
||||
constexpr unsigned long long operator""_KiB(long double v) {
|
||||
return v * 1024.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Kibibytes, x1024 (2^10)
|
||||
//! \~russian Кибибайт, x1024 (2^10)
|
||||
constexpr unsigned long long operator""_KiB(unsigned long long v) {
|
||||
return v * 1024;
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Megabytes, x1000.000
|
||||
//! \~russian Мегабайт, x1000.000
|
||||
constexpr unsigned long long operator""_MB(long double v) {
|
||||
return v * 1000. * 1000.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Megabytes, x1000.000
|
||||
//! \~russian Мегабайт, x1000.000
|
||||
constexpr unsigned long long operator""_MB(unsigned long long v) {
|
||||
return v * 1000 * 1000;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Mebibytes, x1.048.576 (2^20)
|
||||
//! \~russian Мебибайт, x1.048.576 (2^20)
|
||||
constexpr unsigned long long operator""_MiB(long double v) {
|
||||
return v * 1024. * 1024.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Mebibytes, x1.048.576 (2^20)
|
||||
//! \~russian Мебибайт, x1.048.576 (2^20)
|
||||
constexpr unsigned long long operator""_MiB(unsigned long long v) {
|
||||
return v * 1024 * 1024;
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Gigabytes, x1000.000.000
|
||||
//! \~russian Гигабайт, x1000.000.000
|
||||
constexpr unsigned long long operator""_GB(long double v) {
|
||||
return v * 1000. * 1000. * 1000.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Gigabytes, x1000.000.000
|
||||
//! \~russian Гигабайт, x1000.000.000
|
||||
constexpr unsigned long long operator""_GB(unsigned long long v) {
|
||||
return v * 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Gibibytes, x1.073.741.824 (2^30)
|
||||
//! \~russian Гибибайт, x1.073.741.824 (2^30)
|
||||
constexpr unsigned long long operator""_GiB(long double v) {
|
||||
return v * 1024. * 1024. * 1024.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Gibibytes, x1.073.741.824 (2^30)
|
||||
//! \~russian Гибибайт, x1.073.741.824 (2^30)
|
||||
constexpr unsigned long long operator""_GiB(unsigned long long v) {
|
||||
return v * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Terabytes, x1000.000.000.000
|
||||
//! \~russian Терабайт, x1000.000.000.000
|
||||
constexpr unsigned long long operator""_TB(long double v) {
|
||||
return v * 1000. * 1000. * 1000. * 1000.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Terabytes, x1000.000.000.000
|
||||
//! \~russian Терабайт, x1000.000.000.000
|
||||
constexpr unsigned long long operator""_TB(unsigned long long v) {
|
||||
return v * 1000 * 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Tebibytes, x1.099.511.627.776 (2^40)
|
||||
//! \~russian Тебибайт, x1.099.511.627.776 (2^40)
|
||||
constexpr unsigned long long operator""_TiB(long double v) {
|
||||
return v * 1024. * 1024. * 1024. * 1024.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Tebibytes, x1.099.511.627.776 (2^40)
|
||||
//! \~russian Тебибайт, x1.099.511.627.776 (2^40)
|
||||
constexpr unsigned long long operator""_TiB(unsigned long long v) {
|
||||
return v * 1024 * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Petabytes, x1000.000.000.000.000
|
||||
//! \~russian Петабайт, x1000.000.000.000.000
|
||||
constexpr unsigned long long operator""_PB(long double v) {
|
||||
return v * 1000. * 1000. * 1000. * 1000. * 1000.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Petabytes, x1000.000.000.000.000
|
||||
//! \~russian Петабайт, x1000.000.000.000.000
|
||||
constexpr unsigned long long operator""_PB(unsigned long long v) {
|
||||
return v * 1000 * 1000 * 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Pebibytes, x1.125.899.906.842.624 (2^50)
|
||||
//! \~russian Пебибайт, x1.125.899.906.842.624 (2^50)
|
||||
constexpr unsigned long long operator""_PiB(long double v) {
|
||||
return v * 1024. * 1024. * 1024. * 1024. * 1024.;
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Pebibytes, x1.125.899.906.842.624 (2^50)
|
||||
//! \~russian Пебибайт, x1.125.899.906.842.624 (2^50)
|
||||
constexpr unsigned long long operator""_PiB(unsigned long long v) {
|
||||
return v * 1024 * 1024 * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
46
libs/main/literals/piliterals_string.h
Normal file
46
libs/main/literals/piliterals_string.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*! \file piliterals_string.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english PIString C++11 literals
|
||||
* \~russian C++11 суффиксы PIString
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIString C++11 literals
|
||||
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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PILITERALS_STRING_H
|
||||
#define PILITERALS_STRING_H
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PIString from ASCII
|
||||
//! \~russian PIString из ASCII
|
||||
inline PIString operator""_a(const char * v, size_t sz) {
|
||||
return PIString::fromAscii(v, sz);
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PIString from UTF-8
|
||||
//! \~russian PIString из UTF-8
|
||||
inline PIString operator""_u8(const char * v, size_t sz) {
|
||||
return PIString::fromUTF8(v, sz);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
85
libs/main/literals/piliterals_time.h
Normal file
85
libs/main/literals/piliterals_time.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*! \file piliterals_time.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english PISystemTime C++11 literals
|
||||
* \~russian C++11 суффиксы PISystemTime
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PISystemTime C++11 literals
|
||||
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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PILITERALS_TIME_H
|
||||
#define PILITERALS_TIME_H
|
||||
|
||||
#include "pisystemtime.h"
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from seconds
|
||||
//! \~russian PISystemTime из секунд
|
||||
inline PISystemTime operator""_s(long double v) {
|
||||
return PISystemTime::fromSeconds(v);
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from seconds
|
||||
//! \~russian PISystemTime из секунд
|
||||
inline PISystemTime operator""_s(unsigned long long v) {
|
||||
return PISystemTime::fromSeconds(v);
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from milliseconds
|
||||
//! \~russian PISystemTime из милисекунд
|
||||
inline PISystemTime operator""_ms(long double v) {
|
||||
return PISystemTime::fromMilliseconds(v);
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from milliseconds
|
||||
//! \~russian PISystemTime из милисекунд
|
||||
inline PISystemTime operator""_ms(unsigned long long v) {
|
||||
return PISystemTime::fromMilliseconds(v);
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from microseconds
|
||||
//! \~russian PISystemTime из микросекунд
|
||||
inline PISystemTime operator""_us(long double v) {
|
||||
return PISystemTime::fromMicroseconds(v);
|
||||
}
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from microseconds
|
||||
//! \~russian PISystemTime из микросекунд
|
||||
inline PISystemTime operator""_us(unsigned long long v) {
|
||||
return PISystemTime::fromMicroseconds(v);
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english PISystemTime from nanoseconds
|
||||
//! \~russian PISystemTime из наносекунд
|
||||
inline PISystemTime operator""_ns(unsigned long long v) {
|
||||
return PISystemTime::fromNanoseconds(v);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user