translation for russian starts

This commit is contained in:
2022-03-14 12:11:46 +03:00
parent 2a877fbb6b
commit ae29b4514c
3 changed files with 501 additions and 160 deletions

View File

@@ -1,8 +1,15 @@
/*! @file pibase.h /*! @file pibase.h
* @brief Base types and functions * \brief
* \~english Base types and functions
* \~russian Базовые типы и методы
* *
* \details
* \~english
* This file implements first layer above the system and * This file implements first layer above the system and
* declares some basic useful functions * declares some basic useful functions
* \~russian
* Этот файл реализует первый слой после системы и объявляет
* несколько базовых полезных методов
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
@@ -33,87 +40,143 @@
#include "string.h" #include "string.h"
#include <limits> #include <limits>
//! \~english
//! Meta-information section for any entity. //! Meta-information section for any entity.
//! Parsing by \a pip_cmg and can be accessed by \a PICodeInfo. //! Parsing by \a pip_cmg and can be accessed by \a PICodeInfo.
//! Contains sequence of key=value pairs, e.g. //! Contains sequence of key=value pairs, e.g.
//! \~russian
//! Секция метаинформации для любой сущности.
//! Парсится \a pip_cmg и доступна с помощью \a PICodeInfo.
//! Содержит набор пар ключ=значение, например
//! \~
//! PIMETA(id=12345,tag="my string") //! PIMETA(id=12345,tag="my string")
#define PIMETA(...) #define PIMETA(...)
#ifdef DOXYGEN #ifdef DOXYGEN
//! Major value of PIP version //! \brief
//! \~english Major value of PIP version
//! \~russian Мажорная версия PIP
# define PIP_VERSION_MAJOR # define PIP_VERSION_MAJOR
//! Minor value of PIP version //! \brief
//! \~english Minor value of PIP version
//! \~russian Минорная версия PIP
# define PIP_VERSION_MINOR # define PIP_VERSION_MINOR
//! Revision value of PIP version //! \brief
//! \~english Revision value of PIP version
//! \~russian Ревизия версии PIP
# define PIP_VERSION_REVISION # define PIP_VERSION_REVISION
//! Suffix of PIP version //! \brief
//! \~english Suffix of PIP version
//! \~russian Суффикс версии PIP
# define PIP_VERSION_SUFFIX # define PIP_VERSION_SUFFIX
//! Version of PIP in hex - 0x##(Major)##(Minor)##(Revision) //! \brief
//! \~english Version of PIP in hex - 0x##(Major)##(Minor)##(Revision)
//! \~russian Версия PIP в hex - 0x##(Major)##(Minor)##(Revision)
# define PIP_VERSION # define PIP_VERSION
//! Macro is defined when compile-time debug is enabled //! \brief
//! \~english Macro is defined when compile-time debug is enabled
//! \~russian Макрос объявлен когда включена compile-time отладка
# define PIP_DEBUG # define PIP_DEBUG
//! Macro is defined when host is any Windows //! \brief
//! \~english Macro is defined when host is any Windows
//! \~russian Макрос объявлен когда система Windows
# define WINDOWS # define WINDOWS
//! Macro is defined when host is QNX or Blackberry //! \brief
//! \~english Macro is defined when host is QNX or Blackberry
//! \~russian Макрос объявлен когда система QNX или Blackberry
# define QNX # define QNX
//! Macro is defined when host is Blackberry //! \brief
//! \~english Macro is defined when host is Blackberry
//! \~russian Макрос объявлен когда система Blackberry
# define BLACKBERRY # define BLACKBERRY
//! Macro is defined when host is FreeBSD //! \brief
//! \~english Macro is defined when host is FreeBSD
//! \~russian Макрос объявлен когда система FreeBSD
# define FREE_BSD # define FREE_BSD
//! Macro is defined when host is Mac OS //! \brief
//! \~english Macro is defined when host is Mac OS
//! \~russian Макрос объявлен когда система Mac OS
# define MAC_OS # define MAC_OS
//! Macro is defined when host is Android //! \brief
//! \~english Macro is defined when host is Android
//! \~russian Макрос объявлен когда система Android
# define ANDROID # define ANDROID
//! Macro is defined when host is any Linux //! \brief
//! \~english Macro is defined when host is any Linux
//! \~russian Макрос объявлен когда система Linux
# define LINUX # define LINUX
//! Macro is defined when compiler is GCC or MinGW //! \brief
//! \~english Macro is defined when compiler is GCC or MinGW
//! \~russian Макрос объявлен когда компилятор GCC или MinGW
# define CC_GCC # define CC_GCC
//! Macro is defined when PIP is decided that host is support language //! \brief
//! \~english Macro is defined when PIP is decided that host is support language
//! \~russian Макрос объявлен когда PIP решил что система поддерживает локализацию
# define HAS_LOCALE # define HAS_LOCALE
//! Macro is defined when compiler is Visual Studio //! \brief
//! \~english Macro is defined when compiler is Visual Studio
//! \~russian Макрос объявлен когда компилятор Visual Studio
# define CC_VC # define CC_VC
//! Macro is defined when compiler is unknown //! \brief
//! \~english Macro is defined when compiler is unknown
//! \~russian Макрос объявлен когда компилятор неизвестен
# define CC_OTHER # define CC_OTHER
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation //! \brief
//! \~english Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
//! \~russian Макрос объявлен когда PIP может использовать библиотеку "rt" для "PITimer::ThreadRT" реализации таймера
# define PIP_TIMER_RT # define PIP_TIMER_RT
//! Macro to declare private section, export is optional //! \brief
//! \~english Macro to declare private section, "export" is optional
//! \~russian Макрос для объявления частной секции, "export" необязателен
# define PRIVATE_DECLARATION(export) # define PRIVATE_DECLARATION(export)
//! Macro to start definition of private section //! \brief
//! \~english Macro to start definition of private section
//! \~russian Макрос для начала реализации частной секции
# define PRIVATE_DEFINITION_START(Class) # define PRIVATE_DEFINITION_START(Class)
//! Macro to end definition of private section //! \brief
//! \~english Macro to end definition of private section
//! \~russian Макрос для окончания реализации частной секции
# define PRIVATE_DEFINITION_END(Class) # define PRIVATE_DEFINITION_END(Class)
//! Macro to access private section by pointer //! \brief
//! \~english Macro to access private section by pointer
//! \~russian Макрос для доступа к частной секции
# define PRIVATE # define PRIVATE
//! Macro to access private section by pointer without brakes () //! \brief
//! \~english Macro to access private section by pointer without brakes ()
//! \~russian Макрос для доступа к частной секции без обрамляющих скобок ()
# define PRIVATEWB # define PRIVATEWB
//! Macro to start static initializer //! \brief
//! \~english Macro to start static initializer
//! \~russian Макрос для начала статической инициализации
# define STATIC_INITIALIZER_BEGIN # define STATIC_INITIALIZER_BEGIN
//! Macro to end static initializer //! \brief
//! \~english Macro to end static initializer
//! \~russian Макрос для окончания статической инициализации
# define STATIC_INITIALIZER_END # define STATIC_INITIALIZER_END
@@ -140,6 +203,8 @@
extern long long __pi_perf_freq; extern long long __pi_perf_freq;
#endif #endif
#ifndef DOXYGEN
#ifdef ANDROID #ifdef ANDROID
///# define tcdrain(fd) ioctl(fd, TCSBRK, 1) ///# define tcdrain(fd) ioctl(fd, TCSBRK, 1)
//inline int wctomb(char * c, wchar_t w) {*c = ((char * )&w)[0]; return 1;} //inline int wctomb(char * c, wchar_t w) {*c = ((char * )&w)[0]; return 1;}
@@ -222,7 +287,7 @@
# define DEPRECATED # define DEPRECATED
#endif #endif
#endif //DOXYGEN
// Private data macros // Private data macros
#ifndef DOXYGEN #ifndef DOXYGEN
@@ -282,21 +347,32 @@
#endif #endif
//! Macro used for infinite loop //! \brief
//! \~english Macro used for infinite loop
//! \~russian Макрос для бесконечного цикла
#define FOREVER for (;;) #define FOREVER for (;;)
//! Macro used for infinite wait //! \brief
//! \~english Macro used for infinite wait
//! \~russian Макрос для бесконечного ожидания
#define FOREVER_WAIT FOREVER piMinSleep; #define FOREVER_WAIT FOREVER piMinSleep;
//! Macro used for infinite wait //! \brief
//! \~english Macro used for infinite wait
//! \~russian Макрос для бесконечного ожидания
#define WAIT_FOREVER FOREVER piMinSleep; #define WAIT_FOREVER FOREVER piMinSleep;
//! global variable enabling output to piCout, default is true //! \brief
//! \~english Global variable enabling output to piCout, default is true
//! \~russian Глобальная переменная, включающая вывод в piCout, при старте true
extern PIP_EXPORT bool piDebug; extern PIP_EXPORT bool piDebug;
//! global variable that set minimum real update interval //! \brief
//! \~english Global variable that set minimum real update interval
//! for function PIInit::mountInfo(), default is 10000 ms //! for function PIInit::mountInfo(), default is 10000 ms
//! \~russian Глобальная переменная минимального ожидания между реальным обновлением
//! в методе PIInit::mountInfo(), по умолчанию 10000 мс
extern PIP_EXPORT double piMountInfoRefreshIntervalMs; extern PIP_EXPORT double piMountInfoRefreshIntervalMs;
typedef unsigned char uchar; typedef unsigned char uchar;
@@ -307,12 +383,20 @@ typedef unsigned long long ullong;
typedef long long llong; typedef long long llong;
typedef long double ldouble; typedef long double ldouble;
/*! @brief Templated function for swap two values //! \brief
* \details Example:\n \snippet piincludes.cpp swap */ //! \~english Templated function for swap two values
//! \~russian Шаблонный метод для перестановки двух значений
//! \details
//! \~english Example:\n \snippet piincludes.cpp swap
//! \~russian Пример:\n \snippet piincludes.cpp swap
template<typename T> inline void piSwap(T & f, T & s) {T t(std::move(f)); f = std::move(s); s = std::move(t);} template<typename T> inline void piSwap(T & f, T & s) {T t(std::move(f)); f = std::move(s); s = std::move(t);}
/*! @brief Templated function for swap two values without "=" //! \brief
* \details Example:\n \snippet piincludes.cpp swapBinary */ //! \~english Templated function for swap two values without "="
//! \~russian Шаблонный метод для перестановки двух значений без использования "="
//! \details
//! \~english Example:\n \snippet piincludes.cpp swapBinary
//! \~russian Пример:\n \snippet piincludes.cpp swapBinary
template<typename T> inline void piSwapBinary(T & f, T & s) { template<typename T> inline void piSwapBinary(T & f, T & s) {
if ((size_t*)&f == (size_t*)&s) return; if ((size_t*)&f == (size_t*)&s) return;
size_t j = (sizeof(T) / sizeof(size_t)), bs = j * sizeof(size_t), bf = sizeof(T); size_t j = (sizeof(T) / sizeof(size_t)), bs = j * sizeof(size_t), bf = sizeof(T);
@@ -347,8 +431,12 @@ template<> inline void piSwapBinary(const void *& f, const void *& s) {
} }
/*! @brief Function for compare two values without "=" by raw content //! \brief
* \details Example:\n \snippet piincludes.cpp compareBinary */ //! \~english Function for compare two values without "==" by raw content
//! \~russian Метод для сравнения двух значений без использования "==" (по сырому содержимому)
//! \details
//! \~english Example:\n \snippet piincludes.cpp compareBinary
//! \~russian Пример:\n \snippet piincludes.cpp compareBinary
inline bool piCompareBinary(const void * f, const void * s, size_t size) { inline bool piCompareBinary(const void * f, const void * s, size_t size) {
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
if (((const uchar*)f)[i] != ((const uchar*)s)[i]) if (((const uchar*)f)[i] != ((const uchar*)s)[i])
@@ -356,146 +444,304 @@ inline bool piCompareBinary(const void * f, const void * s, size_t size) {
return true; return true;
} }
/*! @brief Templated function return round of float falue //! \brief
* \details Round is the nearest integer value \n //! \~english Templated function return round of float falue
* There are some macros: //! \~russian Шаблонный метод, возвращающий округленное значение
* - \c piRoundf for "float" //! \details
* - \c piRoundd for "double" //! \~english
* //! Round is the nearest integer value \n
* Example: //! There are some macros:
* \snippet piincludes.cpp round */ //! - \c piRoundf for "float"
//! - \c piRoundd for "double"
//!
//! Example:
//! \snippet piincludes.cpp round
//! \~russian
//! Округленное значение - это ближайшее целое число\n
//! Есть несколько макросов:
//! - \c piRoundf для "float"
//! - \c piRoundd для "double"
//!
//! Пример:
//! \snippet piincludes.cpp round
template<typename T> inline constexpr int piRound(const T & v) {return int(v >= T(0.) ? v + T(0.5) : v - T(0.5));} template<typename T> inline constexpr int piRound(const T & v) {return int(v >= T(0.) ? v + T(0.5) : v - T(0.5));}
/*! @brief Templated function return floor of float falue //! \brief
* \details Floor is the largest integer that is not greater than value \n //! \~english Templated function return floor of float falue
* There are some macros: //! \~russian Шаблонный метод, возвращающий floor значение
* - \c piFloorf for "float" //! \details
* - \c piFloord for "double" //! \~english
* //! Floor is the largest integer that is not greater than "v" \n
* Example: //! There are some macros:
* \snippet piincludes.cpp floor */ //! - \c piFloorf for "float"
//! - \c piFloord for "double"
//!
//! Example:
//! \snippet piincludes.cpp floor
//! \~russian
//! Floor значение - это наибольшее целое, не большее чем "v"\n
//! Есть несколько макросов:
//! - \c piFloorf для "float"
//! - \c piFloord для "double"
//!
//! Пример:
//! \snippet piincludes.cpp floor
template<typename T> inline constexpr int piFloor(const T & v) {return v < T(0) ? int(v) - 1 : int(v);} template<typename T> inline constexpr int piFloor(const T & v) {return v < T(0) ? int(v) - 1 : int(v);}
/*! @brief Templated function return ceil of float falue //! \brief
* \details Ceil is the smallest integer that is not less than value \n //! \~english Templated function return ceil of float falue
* There are some macros: //! \~russian Шаблонный метод, возвращающий ceil значение
* - \c piCeilf for "float" //! \details
* - \c piCeild for "double" //! \~english
* //! Ceil is the smallest integer that is not less than "v" \n
* Example: //! There are some macros:
* \snippet piincludes.cpp ceil */ //! - \c piCeilf for "float"
//! - \c piCeild for "double"
//!
//! Example:
//! \snippet piincludes.cpp ceil
//! \~russian
//! Ceil значение - это наименьшее целое, не меньшее чем "v" \n
//! Есть несколько макросов:
//! - \c piCeilf для "float"
//! - \c piCeild для "double"
//!
//! Пример:
//! \snippet piincludes.cpp ceil
template<typename T> inline constexpr int piCeil(const T & v) {return v < T(0) ? int(v) : int(v) + 1;} template<typename T> inline constexpr int piCeil(const T & v) {return v < T(0) ? int(v) : int(v) + 1;}
/*! @brief Templated function return absolute of numeric falue //! \brief
* \details Absolute is the positive or equal 0 value \n //! \~english Templated function return absolute of numeric falue
* There are some macros: //! \~russian Шаблонный метод, возвращающий модуль числового значения
* - \c piAbss for "short" //! \details
* - \c piAbsi for "int" //! \~english
* - \c piAbsl for "long" //! Absolute is the positive or equal 0 value \n
* - \c piAbsll for "llong" //! There are some macros:
* - \c piAbsf for "float" //! - \c piAbss for "short"
* - \c piAbsd for "double" //! - \c piAbsi for "int"
* //! - \c piAbsl for "long"
* Example: //! - \c piAbsll for "llong"
* \snippet piincludes.cpp abs */ //! - \c piAbsf for "float"
//! - \c piAbsd for "double"
//!
//! Example:
//! \snippet piincludes.cpp abs
//! \~russian
//! Модуль числового значения всегда >= 0 \n
//! Есть несколько макросов:
//! - \c piAbss для "short"
//! - \c piAbsi для "int"
//! - \c piAbsl для "long"
//! - \c piAbsll для "llong"
//! - \c piAbsf для "float"
//! - \c piAbsd для "double"
//!
//! Пример:
//! \snippet piincludes.cpp abs
template<typename T> inline constexpr T piAbs(const T & v) {return (v >= T(0) ? v : -v);} template<typename T> inline constexpr T piAbs(const T & v) {return (v >= T(0) ? v : -v);}
/*! @brief Templated function return minimum of two values //! \brief
* \details There are some macros: //! \~english Templated function return minimum of two values
* - \c piMins for "short" //! \~russian Шаблонный метод, возвращающий минимум из двух значений
* - \c piMini for "int" //! \details
* - \c piMinl for "long" //! \~english
* - \c piMinll for "llong" //! There are some macros:
* - \c piMinf for "float" //! - \c piMins for "short"
* - \c piMind for "double" //! - \c piMini for "int"
* //! - \c piMinl for "long"
* Example: //! - \c piMinll for "llong"
* \snippet piincludes.cpp min2 */ //! - \c piMinf for "float"
//! - \c piMind for "double"
//!
//! Example:
//! \snippet piincludes.cpp min2
//! \~russian
//! Есть несколько макросов:
//! - \c piMins для "short"
//! - \c piMini для "int"
//! - \c piMinl для "long"
//! - \c piMinll для "llong"
//! - \c piMinf для "float"
//! - \c piMind для "double"
//!
//! Пример:
//! \snippet piincludes.cpp min2
template<typename T> inline constexpr T piMin(const T & f, const T & s) {return ((f > s) ? s : f);} template<typename T> inline constexpr T piMin(const T & f, const T & s) {return ((f > s) ? s : f);}
/*! @brief Templated function return minimum of tree values //! \brief
* \details There are some macros: //! \~english Templated function return minimum of tree values
* - \c piMins for "short" //! \~russian Шаблонный метод, возвращающий минимум из трех значений
* - \c piMini for "int" //! \details
* - \c piMinl for "long" //! \~english
* - \c piMinll for "llong" //! There are some macros:
* - \c piMinf for "float" //! - \c piMins for "short"
* - \c piMind for "double" //! - \c piMini for "int"
* //! - \c piMinl for "long"
* Example: //! - \c piMinll for "llong"
* \snippet piincludes.cpp min3 */ //! - \c piMinf for "float"
//! - \c piMind for "double"
//!
//! Example:
//! \snippet piincludes.cpp min3
//! \~russian
//! Есть несколько макросов:
//! - \c piMins для "short"
//! - \c piMini для "int"
//! - \c piMinl для "long"
//! - \c piMinll для "llong"
//! - \c piMinf для "float"
//! - \c piMind для "double"
//!
//! Пример:
//! \snippet piincludes.cpp min3
template<typename T> inline constexpr T piMin(const T & f, const T & s, const T & t) {return ((f < s && f < t) ? f : ((s < t) ? s : t));} template<typename T> inline constexpr T piMin(const T & f, const T & s, const T & t) {return ((f < s && f < t) ? f : ((s < t) ? s : t));}
/*! @brief Templated function return maximum of two values //! \brief
* \details There are some macros: //! \~english Templated function return maximum of two values
* - \c piMaxs for "short" //! \~russian Шаблонный метод, возвращающий максимум из двух значений
* - \c piMaxi for "int" //! \details
* - \c piMaxl for "long" //! \~english
* - \c piMaxll for "llong" //! There are some macros:
* - \c piMaxf for "float" //! - \c piMaxs for "short"
* - \c piMaxd for "double" //! - \c piMaxi for "int"
* //! - \c piMaxl for "long"
* Example: //! - \c piMaxll for "llong"
* \snippet piincludes.cpp max2 */ //! - \c piMaxf for "float"
//! - \c piMaxd for "double"
//!
//! Example:
//! \snippet piincludes.cpp max2
//! \~russian
//! Есть несколько макросов:
//! - \c piMaxs для "short"
//! - \c piMaxi для "int"
//! - \c piMaxl для "long"
//! - \c piMaxll для "llong"
//! - \c piMaxf для "float"
//! - \c piMaxd для "double"
//!
//! Пример:
//! \snippet piincludes.cpp max2
template<typename T> inline constexpr T piMax(const T & f, const T & s) {return ((f < s) ? s : f);} template<typename T> inline constexpr T piMax(const T & f, const T & s) {return ((f < s) ? s : f);}
/*! @brief Templated function return maximum of tree values //! \brief
* \details There are some macros: //! \~english Templated function return maximum of tree values
* - \c piMaxs for "short" //! \~russian Шаблонный метод, возвращающий максимум из трех значений
* - \c piMaxi for "int" //! \details
* - \c piMaxl for "long" //! \~english
* - \c piMaxll for "llong" //! There are some macros:
* - \c piMaxf for "float" //! - \c piMaxs for "short"
* - \c piMaxd for "double" //! - \c piMaxi for "int"
* //! - \c piMaxl for "long"
* Example: //! - \c piMaxll for "llong"
* \snippet piincludes.cpp max3 */ //! - \c piMaxf for "float"
//! - \c piMaxd for "double"
//!
//! Example:
//! \snippet piincludes.cpp max3
//! \~russian
//! Есть несколько макросов:
//! - \c piMaxs для "short"
//! - \c piMaxi для "int"
//! - \c piMaxl для "long"
//! - \c piMaxll для "llong"
//! - \c piMaxf для "float"
//! - \c piMaxd для "double"
//!
//! Пример:
//! \snippet piincludes.cpp max3
template<typename T> inline constexpr T piMax(const T & f, const T & s, const T & t) {return ((f > s && f > t) ? f : ((s > t) ? s : t));} template<typename T> inline constexpr T piMax(const T & f, const T & s, const T & t) {return ((f > s && f > t) ? f : ((s > t) ? s : t));}
/*! @brief Templated function return clamped value //! \brief
* \details Clamped is the not greater than "max" and not lesser than "min" value \n //! \~english Templated function return clamped value
* There are some macros: //! \~russian Шаблонный метод, возвращающий ограниченное значение
* - \c piClamps for "short" //! \details
* - \c piClampi for "int" //! \~english
* - \c piClampl for "long" //! Clamped is the not greater than "max" and not lesser than "min" value \n
* - \c piClampll for "llong" //! There are some macros:
* - \c piClampf for "float" //! - \c piClamps for "short"
* - \c piClampd for "double" //! - \c piClampi for "int"
* //! - \c piClampl for "long"
* Example: //! - \c piClampll for "llong"
* \snippet piincludes.cpp clamp */ //! - \c piClampf for "float"
//! - \c piClampd for "double"
//!
//! Example:
//! \snippet piincludes.cpp clamp
//! \~russian
//! Ограниченное значение - не больше чем "max" и не меньше чем "min"
//! Есть несколько макросов:
//! - \c piClamps для "short"
//! - \c piClampi для "int"
//! - \c piClampl для "long"
//! - \c piClampll для "llong"
//! - \c piClampf для "float"
//! - \c piClampd для "double"
//!
//! Пример:
//! \snippet piincludes.cpp clamp
template<typename T> inline constexpr T piClamp(const T & v, const T & min, const T & max) {return (v > max ? max : (v < min ? min : v));} template<typename T> inline constexpr T piClamp(const T & v, const T & min, const T & max) {return (v > max ? max : (v < min ? min : v));}
/// Function inverse byte order in memory block //! \brief
//! \~english Function inverse byte order in memory block ([1..N] -> [N..1])
//! \~russian Метод для смены порядка байт в блоке памяти ([1..N] -> [N..1])
inline void piLetobe(void * data, int size) { inline void piLetobe(void * data, int size) {
for (int i = 0; i < size / 2; i++) for (int i = 0; i < size / 2; i++)
piSwap<uchar>(((uchar*)data)[size - i - 1], ((uchar*)data)[i]); piSwap<uchar>(((uchar*)data)[size - i - 1], ((uchar*)data)[i]);
} }
/*! @brief Function for compare two numeric values with epsilon //! \brief
* \details Example:\n \snippet piincludes.cpp compare //! \~english Function for compare two numeric values with epsilon
* There are some macros: //! \~russian Метод для сравнения двух чисел с порогом
* - \c piComparef for "float" //! \details
* - \c piCompared for "double" //! \~english
*/ //! There are some macros:
//! - \c piComparef for "float"
//! - \c piCompared for "double"
//!
//! Example:
//! \snippet piincludes.cpp compare
//! \~russian
//! Есть несколько макросов:
//! - \c piComparef для "float"
//! - \c piCompared для "double"
//!
//! Пример:
//! \snippet piincludes.cpp compare
template<typename T> template<typename T>
inline bool piCompare(const T & a, const T & b, const T & epsilon = std::numeric_limits<T>::epsilon()) { inline bool piCompare(const T & a, const T & b, const T & epsilon = std::numeric_limits<T>::epsilon()) {
return piAbs(a - b) <= epsilon; return piAbs(a - b) <= epsilon;
} }
/// @brief Templated function that inverse byte order of value "v" //! \brief
//! \~english Templated function that inverse byte order of value "v"
//! \~russian Шаблонный метод, меняющий порядок байт в переменной "v"
template<typename T> inline void piLetobe(T * v) {piLetobe(v, sizeof(T));} template<typename T> inline void piLetobe(T * v) {piLetobe(v, sizeof(T));}
/*! @brief Templated function that returns "v" with inversed byte order //! \brief
* \details This function used to convert values between little and big endian \n //! \~english Templated function that returns "v" with inversed byte order
* There are some macros: //! \~russian Шаблонный метод, возвращающий переменную "v" с измененным порядком байт
* - \c piLetobes for "ushort" //! \details
* - \c piLetobei for "uint" //! \~english
* - \c piLetobel for "ulong" //! This function used to convert values between little and big endian \n
* - \c piLetobell for "ullong" //! There are some macros:
* //! - \c piLetobes for "ushort"
* Example: //! - \c piLetobei for "uint"
* \snippet piincludes.cpp letobe */ //! - \c piLetobel for "ulong"
//! - \c piLetobell for "ullong"
//!
//! Example:
//! \snippet piincludes.cpp letobe
//! \~russian
//! Этот метод используется для изменения порядка байт между little и big endian
//! Есть несколько макросов:
//! - \c piLetobes для "ushort"
//! - \c piLetobei для "uint"
//! - \c piLetobel для "ulong"
//! - \c piLetobell для "ullong"
//!
//! Пример:
//! \snippet piincludes.cpp letobe
template<typename T> inline T piLetobe(const T & v) {T tv(v); piLetobe(&tv, sizeof(T)); return tv;} template<typename T> inline T piLetobe(const T & v) {T tv(v); piLetobe(&tv, sizeof(T)); return tv;}
// specialization // specialization
@@ -512,7 +758,9 @@ template<> inline float piLetobe(const float & v) {
return a.f; return a.f;
} }
/// @brief Generic hash function, implements murmur3/32 algorithm //! \brief
//! \~english Generic hash function, implements murmur3/32 algorithm
//! \~russian Хэш-функция общего назначения, по алгоритму murmur3/32
inline uint piHashData(const uchar * data, uint len, uint seed = 0) { inline uint piHashData(const uchar * data, uint len, uint seed = 0) {
if (!data || len <= 0) return 0u; if (!data || len <= 0) return 0u;
uint h = seed; uint h = seed;

View File

@@ -95,7 +95,10 @@ int randomi() {
} }
/*! \mainpage What is PIP /*! \~english \mainpage What is PIP
* \~russian \mainpage Что такое PIP
*
* \~english
* PIP - Platform-Independent Primitives - is crossplatform library for C++ developers. * PIP - Platform-Independent Primitives - is crossplatform library for C++ developers.
* It is wrap around STL and pure C++. This library can help developers write non-GUI * It is wrap around STL and pure C++. This library can help developers write non-GUI
* projects much more quickly, efficiently and customizable than on pure C++. * projects much more quickly, efficiently and customizable than on pure C++.
@@ -112,10 +115,16 @@ int randomi() {
* * executor (\a PIThreadPoolExecutor) * * executor (\a PIThreadPoolExecutor)
* * blocking dequeue (\a PIBlockingDequeue) * * blocking dequeue (\a PIBlockingDequeue)
* * timer (\a PITimer) * * timer (\a PITimer)
* * console (information output) (\a PIConsole) * * tiling console (with widgets) (\a PIScreen)
* * stand-alone * * simple text rows
* * server * * scroll bar
* * client * * list
* * button
* * buttons group
* * check box
* * progress bar
* * PICout output
* * text input
* * I/O devices * * I/O devices
* * base class (\a PIIODevice) * * base class (\a PIIODevice)
* * file (\a PIFile) * * file (\a PIFile)
@@ -134,15 +143,72 @@ int randomi() {
* * peering net node (\a PIPeer) * * peering net node (\a PIPeer)
* * process (\a PIProcess) * * process (\a PIProcess)
* * state machine (\a PIStateMachine) * * state machine (\a PIStateMachine)
* \n \n Basic using of PIP described at page \ref using_basic */ * \n \n Basic using of PIP described at page \ref using_basic
*
* \~russian
* PIP - Platform-Independent Primitives - кроссплатформенная библиотека для разработчиков на C++.
* It is wrap around STL and pure C++. This library can help developers write non-GUI
* projects much more quickly, efficiently and customizable than on pure C++.
* PIP предоставляет следующие классы:
* * общение с консолью (\a PICout)
* * контейнеры (\a PIVector, \a PIList, \a PIMap, \a PIStack)
* * байтовый массив (\a PIByteArray)
* * строка (\a PIString, \a PIStringList)
* * базовый объект (события и обработчики) (\a PIObject)
* * многопоточность
* * поток (\a PIThread)
* * исполнитель (\a PIThreadPoolExecutor)
* * блокирующая очередь (\a PIBlockingDequeue)
* * таймер (\a PITimer)
* * тайлинговая консоль (с виджетами) (\a PIScreen)
* * простой вывод строк
* * скроллбар
* * лист
* * кнопка
* * группа кнопок
* * галочка
* * прогрессбар
* * вывод PICout
* * текстовый ввод
* * устройства ввода/вывода
* * базовый класс (\a PIIODevice)
* * файл (\a PIFile)
* * последовательный порт (\a PISerial)
* * ethernet (\a PIEthernet)
* * USB (\a PIUSB)
* * packets extractor (\a PIPacketExtractor)
* * бинарный логфайл (\a PIBinaryLog)
* * сложное составное устройство (\a PIConnection)
* * поддержка библиотек времени выполнения
* * базовая функциональность (\a PILibrary)
* * плагин (\a PIPluginLoader)
* * диагностика качества связи (\a PIDiagnostics)
* * парсер аргументов командной строки (\a PICLI)
* * вычислитель (\a PIEvaluator)
* * пиринговая сеть (\a PIPeer)
* * процесс (\a PIProcess)
* * машина состояний (\a PIStateMachine)
* \n \n Базовое использование PIP описано на странице \ref using_basic
*/
/*! \page using_basic Getting started /*! \~english \page using_basic Getting started
* \~russian \page using_basic Простые начала
*
* \~english
* Many novice programmers are solved many common task with system integrity: output to console, * Many novice programmers are solved many common task with system integrity: output to console,
* keyboard buttons press detecting, working with serial ports, ethernet or files, and many other. * keyboard buttons press detecting, working with serial ports, ethernet or files, and many other.
* These tasks can solve this library, and code, based only on PIP will be compile and work * These tasks can solve this library, and code, based only on PIP will be compile and work
* similar on many systems: Windows, any Linux, Red Hat, FreeBSD, MacOS X and QNX. * similar on many systems: Windows, any Linux, Red Hat, FreeBSD, MacOS X and QNX.
* Typical application on PIP looks like this: \n * Typical application on PIP looks like this: \n
*
* \~russian
* Многие начинающие программисты решают общие задачи взаимодействия с операционной системой:
* вывод в консоль, определение нажатия клавиш, работа с последовательными портами, сетью или файлами,
* и многое другое. Эти задачи решены в библиотеке, и код, основанный на PIP будет компилироваться
* и работать одинаково на многих системах: Windows, любой Linux, Red Hat, FreeBSD, MacOS X и QNX.
* Типовое приложение на PIP выглядит примерно так: \n
*
\code{.cpp} \code{.cpp}
#include <pip.h> #include <pip.h>
@@ -232,15 +298,32 @@ int main(int argc, char * argv[]) {
return 0; return 0;
}; };
\endcode \endcode
*
* \~english
* This code demonstrates simple interactive configurable program, which can be started with console * This code demonstrates simple interactive configurable program, which can be started with console
* display or not, and with debug or not. \b MainClass is central class that also can be inherited from * display or not, and with debug or not. \b MainClass is central class that also can be inherited from
* \a PIThread and reimplement \a run() function. * \a PIThread and reimplement \a run() function.
* \n Many PIP classes has events and event handlers, which can be connected one to another. * \n Many PIP classes has events and event handlers, which can be connected one to another.
* Details you can see at \a PIObject reference page (\ref PIObject_sec0). * Details you can see at \a PIObject reference page (\ref PIObject_sec0).
* \n To configure your program from file use \a PIConfig. * \n To configure your program from file use \a PIConfig.
* \n If you want more information see \ref using_advanced */ * \n If you want more information see \ref using_advanced
*
* \~russian
* Этот код демонстрирует простую конфигурируемую программу, которая может быть запущена с
* This code demonstrates simple interactive configurable program, which can be started with console
* display or not, and with debug or not. \b MainClass is central class that also can be inherited from
* \a PIThread and reimplement \a run() function.
* \n Many PIP classes has events and event handlers, which can be connected one to another.
* Details you can see at \a PIObject reference page (\ref PIObject_sec0).
* \n To configure your program from file use \a PIConfig.
*/
/*! \page using_advanced Advanced using /*! \page using_advanced Advanced using
* Sorry, creativity crysis xD * Sorry, creativity crysis xD
*/ */
/*
* \~english
* \~russian
*/

View File

@@ -42,10 +42,18 @@ struct lconv;
extern PIP_EXPORT lconv * currentLocale; extern PIP_EXPORT lconv * currentLocale;
/*! \fn errorString() //! \brief
* @brief Return readable error description in format "code <number> - <description>" */ //! \~english
//! Return readable error description in format "code <number> - <description>"
//! \~russian
//! Возвращает читаемое описание ошибки в формате "code <номер> - <описание>"
PIP_EXPORT PIString errorString(); PIP_EXPORT PIString errorString();
//! \brief
//! \~english
//! Reset last error
//! \~russian
//! Сброс последней ошибки
PIP_EXPORT void errorClear(); PIP_EXPORT void errorClear();
PIP_EXPORT void piqsort(void* base, size_t num, size_t size, int (*compar)(const void*,const void*)); PIP_EXPORT void piqsort(void* base, size_t num, size_t size, int (*compar)(const void*,const void*));
@@ -53,7 +61,9 @@ PIP_EXPORT void piqsort(void* base, size_t num, size_t size, int (*compar)(const
PIP_EXPORT void randomize(); PIP_EXPORT void randomize();
PIP_EXPORT int randomi(); PIP_EXPORT int randomi();
/// Return readable version of PIP //! \brief
//! \~english Return readable version of PIP
//! \~russian Возвращает читаемую версию PIP
PIP_EXPORT PIString PIPVersion(); PIP_EXPORT PIString PIPVersion();
#endif // PIINCLUDES_H #endif // PIINCLUDES_H