diff --git a/libs/console/piscreen.cpp b/libs/console/piscreen.cpp index 232ad3e5..448f87b2 100644 --- a/libs/console/piscreen.cpp +++ b/libs/console/piscreen.cpp @@ -142,7 +142,7 @@ void PIScreen::SystemConsole::resize(int w, int h) { pcells.resize(height); for (int i = 0; i < height; ++i) { cells[i].resize(width); - pcells[i].resize(width, Cell(0)); + pcells[i].resize(width, Cell(PIChar())); } #ifdef WINDOWS PRIVATE->sbi.srWindow = PRIVATE->csbi.srWindow; diff --git a/libs/console/piscreentiles.cpp b/libs/console/piscreentiles.cpp index 1fea2e93..0e579636 100644 --- a/libs/console/piscreentiles.cpp +++ b/libs/console/piscreentiles.cpp @@ -691,7 +691,7 @@ bool TileInput::keyEvent(PIKbdListener::KeyEvent key) { default: PIChar tc #ifdef WINDOWS - = PIChar(key.key); + = PIChar((ushort)key.key); #else = PIChar::fromUTF8((char *)&(key.key)); #endif diff --git a/libs/console/piterminal.cpp b/libs/console/piterminal.cpp index d63fca89..292a393b 100644 --- a/libs/console/piterminal.cpp +++ b/libs/console/piterminal.cpp @@ -239,9 +239,9 @@ void PITerminal::write(PIKbdListener::KeyEvent ke) { else { PIByteArray ba; #ifdef WINDOWS - ba << uchar(PIChar(ke.key).toConsole1Byte()); + ba << uchar(PIChar((ushort)ke.key).toConsole1Byte()); #else - ba = PIString(PIChar(ke.key)).toUTF8(); + ba = PIString(PIChar((ushort)ke.key)).toUTF8(); #endif write(ba); } diff --git a/libs/crypt/piauth.cpp b/libs/crypt/piauth.cpp index d3858355..223e3ad5 100644 --- a/libs/crypt/piauth.cpp +++ b/libs/crypt/piauth.cpp @@ -128,7 +128,7 @@ PIAuth::State PIAuth::receive(PIByteArray & ba) { passwordRequest(&ps); if (ps.isEmpty()) return disconnect(ba, "Canceled by user"); ph = crypt.passwordHash(ps, PIString("PIAuth").toByteArray()); - ps.fill(PIChar(0)); + ps.fill(PIChar()); tba.clear(); tba << ph << auth_sign << sign_pk; tba = crypt.crypt(tba, box_pk, box_sk); diff --git a/libs/main/code/picodeparser.cpp b/libs/main/code/picodeparser.cpp index 79cd8c8f..f3fcc53f 100644 --- a/libs/main/code/picodeparser.cpp +++ b/libs/main/code/picodeparser.cpp @@ -51,7 +51,7 @@ PIString PICodeParser::Macro::expand(PIString args_, bool * ok) const { const PIString & an(args[i]), av(arg_vals[i]); int ind(-1); while ((ind = ret.find(an, ind + 1)) >= 0) { - PIChar ppc(0), pc(0), nc(0); + PIChar ppc, pc, nc; if (ind > 1) ppc = ret[ind - 2]; if (ind > 0) pc = ret[ind - 1]; if (ind + an.size_s() < ret.size_s()) nc = ret.mid(ind + an.size_s(),1)[0]; @@ -279,7 +279,7 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) { piForeachC (Define & d, defines) { int ind(-1); while ((ind = pfc.find(d.first, ind + 1)) >= 0) { - PIChar pc(0), nc(0); + PIChar pc, nc; if (ind > 0) pc = pfc[ind - 1]; if (ind + d.first.size_s() < pfc.size_s()) nc = pfc.mid(ind + d.first.size_s(),1)[0]; if (_isCChar(pc) || _isCChar(nc) || nc.isDigit()) continue; @@ -291,7 +291,7 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) { piForeachC (Macro & m, macros) { int ind(-1); while ((ind = pfc.find(m.name, ind + 1)) >= 0) { - PIChar pc(0), nc(0); + PIChar pc, nc; if (ind > 0) pc = pfc[ind - 1]; if (ind + m.name.size_s() < pfc.size_s()) nc = pfc.mid(ind + m.name.size_s(),1)[0]; if (_isCChar(pc) || _isCChar(nc) || nc.isDigit()) continue; diff --git a/libs/main/containers/picontainersmodule.h b/libs/main/containers/picontainersmodule.h index e69e5d62..32e19e48 100644 --- a/libs/main/containers/picontainersmodule.h +++ b/libs/main/containers/picontainersmodule.h @@ -20,11 +20,18 @@ * \~\brief * \~english This module contains various standart containers realization. * \~russian Модуль содержит основные классы контейнеров. + * * \~\details + * Scope | Use + * ----- | ------- + * C++ | #include + * CMake | PIP + * * \~english This includes * \~russian В него входят * \~ \a PIVector, \a PIDeque, \a PIMap, \a PISet, * \a PIStack, \a PIQueue, \a PIPair, \a PIVector2D. + * * \authors * \~english * Ivan Pelipenko peri4ko@yandex.ru; @@ -33,6 +40,7 @@ * Иван Пелипенко peri4ko@yandex.ru; * Андрей Бычков work.a.b@yandex.ru; */ + #ifndef PICONTAINERSMODULE_H #define PICONTAINERSMODULE_H diff --git a/libs/main/core/pibytearray.cpp b/libs/main/core/pibytearray.cpp index 9cb8f8fe..08076420 100644 --- a/libs/main/core/pibytearray.cpp +++ b/libs/main/core/pibytearray.cpp @@ -21,11 +21,14 @@ #include "pistringlist.h" #include -//! \class PIByteArray +//! \addtogroup Core +//! \{ +//! \class PIByteArray pibytearray.h //! //! \~\brief -//! \~english The PIByteArray class provides an array of bytes -//! \~russian Класс PIByteArray представляет собой массив байтов +//! \~english The %PIByteArray class provides an array of bytes +//! \~russian Класс %PIByteArray представляет собой массив байтов +//! \} //! //! \~\details //! \~english diff --git a/libs/main/core/pibytearray.h b/libs/main/core/pibytearray.h index f0a61e77..dedfc15c 100644 --- a/libs/main/core/pibytearray.h +++ b/libs/main/core/pibytearray.h @@ -231,8 +231,8 @@ inline std::ostream & operator <<(std::ostream & s, const PIByteArray & ba); #endif //! \relatesalso PIByteArray -//! \~english Output to PICout operator -//! \~russian Оператор вывода в PICout +//! \~english Output operator to \a PICout +//! \~russian Оператор вывода в \a PICout PIP_EXPORT PICout operator <<(PICout s, const PIByteArray & ba); diff --git a/libs/main/core/pichar.cpp b/libs/main/core/pichar.cpp index c51417b1..0e06334a 100644 --- a/libs/main/core/pichar.cpp +++ b/libs/main/core/pichar.cpp @@ -1,6 +1,3 @@ -/*! \file pichar.h - * \brief Unicode char -*/ /* PIP - Platform Independent Primitives Unicode char @@ -45,11 +42,24 @@ char * __utf8name__ = 0; # endif #endif -/*! \class PIChar - * \brief Unicode char - * \details This class is wrapper around \c "uint". - * There are many contructors and information functions - */ +//! \addtogroup Core +//! \{ +//! \class PIChar pichar.h +//! +//! \~\brief +//! \~english %PIChar represents a single character +//! \~russian %PIChar представляет собой один символ строки +//! +//! \~\details +//! \~english +//! This class is wrapper around UTF16. +//! There are many contructors and information functions +//! +//! \~russian +//! %PIChar хранит один сивол в UTF16. Имеет много контрукторов, геттеров в различные +//! кодировки (системную, консольную, UTF8) и информационных функций. +//! +//! \} ushort charFromCodepage(const char * c, int size, const char * codepage, int * taken = 0) { @@ -324,7 +334,7 @@ char PIChar::toSystem() const { PIChar PIChar::toUpper() const { - if (isAscii()) return PIChar(toupper(ch)); + if (isAscii()) return PIChar((ushort)toupper(ch)); #ifdef PIP_ICU UChar c(0); UErrorCode e((UErrorCode)0); @@ -342,7 +352,7 @@ PIChar PIChar::toUpper() const { PIChar PIChar::toLower() const { - if (isAscii()) return PIChar(tolower(ch)); + if (isAscii()) return PIChar((ushort)tolower(ch)); #ifdef PIP_ICU UChar c(0); UErrorCode e((UErrorCode)0); diff --git a/libs/main/core/pichar.h b/libs/main/core/pichar.h index a2b5dad2..6eacd170 100644 --- a/libs/main/core/pichar.h +++ b/libs/main/core/pichar.h @@ -1,5 +1,7 @@ /*! \file pichar.h - * \brief Unicode char + * \~\brief + * \~english Single string character + * \~russian Один символ строки */ /* PIP - Platform Independent Primitives @@ -34,97 +36,134 @@ class PIP_EXPORT PIChar friend class PIString; friend PICout PIP_EXPORT operator <<(PICout s, const PIChar & v); public: - //! Contructs ascii symbol + //! \~english Contructs Ascii symbol + //! \~russian Создает символ Ascii PIChar(const char c) {ch = c; ch &= 0xFF;} - //! Contructs 2-bytes symbol + //! \~english Contructs 2-bytes symbol + //! \~russian Создает 2-байтный символ PIChar(const short c) {ch = c;} - //! Contructs 4-bytes symbol - PIChar(const int c) {ch = c;} + //! \~english Contructs ascii symbol + //! \~russian Создает символ Ascii + PIChar(const uchar c) {ch = c;} - //! Contructs ascii symbol - PIChar(const uchar c) {ch = c; ch &= 0xFF;} + //! \~english Contructs 2-bytes symbol + //! \~russian Создает 2-байтный символ + PIChar(const ushort c = 0) {ch = c;} - //! Contructs 2-bytes symbol - PIChar(const ushort c) {ch = c;} - - //! Default constructor. Contructs 4-bytes symbol - PIChar(const uint c = 0) {ch = c;} - - //! Contructs symbol from no more than 4 bytes of string + //! \~english Contructs symbol from system locale and no more than 4 bytes of string + //! \~russian Создает символ из системной локали не более 4 байт длины PIChar(const char * c, int * bytes = 0); - //! Copy operator + //! \~english Copy operator + //! \~russian Оператор присваивания PIChar & operator =(const char v) {ch = v; return *this;} - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator ==(const PIChar & o) const; - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator !=(const PIChar & o) const {return !(o == *this);} - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator >(const PIChar & o) const; - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator <(const PIChar & o) const; - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator >=(const PIChar & o) const; - //! Compare operator + //! \~english Compare operator + //! \~russian Оператор сравнения bool operator <=(const PIChar & o) const; - //! Return \b true if symbol is digit ('0' to '9') + //! \~english Returns \b true if symbol is digit ('0' to '9') + //! \~russian Возвращает \b true если символ является bool isDigit() const; - //! Return \b true if symbol is HEX digit ('0' to '9', 'a' to 'f', 'A' to 'F') + //! \~english Returns \b true if symbol is HEX digit ('0' to '9', 'a' to 'f', 'A' to 'F') + //! \~russian Возвращает \b true если символ является HEX цифрой ('0' до '9', 'a' до 'f', 'A' до 'F') bool isHex() const; - //! Return \b true if symbol is drawable (without space) + //! \~english Returns \b true if symbol is drawable (without space) + //! \~russian Возвращает \b true если символ является графическим (исключая пробельные) bool isGraphical() const; - //! Return \b true if symbol is control byte (< 32 or 127) + //! \~english Returns \b true if symbol is control byte (< 32 or 127) + //! \~russian Возвращает \b true если символ является контрольным (< 32 or 127) bool isControl() const; - //! Return \b true if symbol is in lower case + //! \~english Returns \b true if symbol is in lower case + //! \~russian Возвращает \b true если символ в нижнем регистре bool isLower() const; - - //! Return \b true if symbol is in upper case + + //! \~english Returns \b true if symbol is in upper case + //! \~russian Возвращает \b true если символ в верхнем регистре bool isUpper() const; - //! Return \b true if symbol is printable (with space) + //! \~english Returns \b true if symbol is printable (with space) + //! \~russian Возвращает \b true если символ является печатным (включая пробельные) bool isPrint() const; - //! Return \b true if symbol is space or tab + //! \~english Returns \b true if symbol is space or tab + //! \~russian Возвращает \b true если символ является пробельным или табуляцией bool isSpace() const; - //! Return \b true if symbol is alphabetical letter + //! \~english Returns \b true if symbol is alphabetical letter + //! \~russian Возвращает \b true если символ является алфавитной буквой bool isAlpha() const; - //! Return \b true if symbol is ascii (< 128) + //! \~english Returns \b true if symbol is Ascii (< 128) + //! \~russian Возвращает \b true если символ является Ascii (< 128) bool isAscii() const; const wchar_t * toWCharPtr() const; - //! Return as "char * " string + //! \~english Returns as "char * " string + //! \~russian Возвращает символ как указатель на "char * " const char * toCharPtr() const; wchar_t toWChar() const; + + //! \~english Returns symbol as Ascii + //! \~russian Возвращает символ в Ascii char toAscii() const {return ch % 256;} + + //! \~english Returns symbol as console codepage + //! \~russian Возвращает символ в консольной кодировке char toConsole1Byte() const; + + //! \~english Returns symbol as system codepage + //! \~russian Возвращает символ в системной кодировке char toSystem() const; + ushort unicode16Code() const {return ch;} - //! Return symbol in upper case + //! \~english Returns symbol in upper case + //! \~russian Возвращает символ в нижнем регистре PIChar toUpper() const; - //! Return symbol in lower case + //! \~english Returns symbol in lower case + //! \~russian Возвращает символ в верхнем регистре PIChar toLower() const; + //! \~english Returns symbol from console codepage + //! \~russian Возвращает символ из консольной кодировки static PIChar fromConsole(char c); + + //! \~english Returns symbol from system codepage + //! \~russian Возвращает символ из системной кодировки static PIChar fromSystem(char c); + + //! \~english Returns symbol from UTF8 codepage + //! \~russian Возвращает символ из UTF8 кодировки static PIChar fromUTF8(const char * c); private: @@ -132,54 +171,86 @@ private: }; -//! Output operator to \a PICout +//! \relatesalso PIChar +//! \~english Output operator to \a PICout +//! \~russian Оператор вывода в \a PICout PICout PIP_EXPORT operator <<(PICout s, const PIChar & v); -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator ==(const char v, const PIChar & c) {return (PIChar(v) == c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator >(const char v, const PIChar & c) {return (PIChar(v) > c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator <(const char v, const PIChar & c) {return (PIChar(v) < c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator >=(const char v, const PIChar & c) {return (PIChar(v) >= c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator <=(const char v, const PIChar & c) {return (PIChar(v) <= c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator ==(const char * v, const PIChar & c) {return (PIChar(v) == c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator >(const char * v, const PIChar & c) {return (PIChar(v) > c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator <(const char * v, const PIChar & c) {return (PIChar(v) < c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator >=(const char * v, const PIChar & c) {return (PIChar(v) >= c);} -//! Compare operator +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения inline bool operator <=(const char * v, const PIChar & c) {return (PIChar(v) <= c);} -//! Compare operator -inline bool operator ==(const int v, const PIChar & c) {return (PIChar(v) == c);} +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения +inline bool operator ==(const int v, const PIChar & c) {return (PIChar((ushort)v) == c);} -//! Compare operator -inline bool operator >(const int v, const PIChar & c) {return (PIChar(v) > c);} +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения +inline bool operator >(const int v, const PIChar & c) {return (PIChar((ushort)v) > c);} -//! Compare operator -inline bool operator <(const int v, const PIChar & c) {return (PIChar(v) < c);} +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения +inline bool operator <(const int v, const PIChar & c) {return (PIChar((ushort)v) < c);} -//! Compare operator -inline bool operator >=(const int v, const PIChar & c) {return (PIChar(v) >= c);} +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения +inline bool operator >=(const int v, const PIChar & c) {return (PIChar((ushort)v) >= c);} -//! Compare operator -inline bool operator <=(const int v, const PIChar & c) {return (PIChar(v) <= c);} +//! \relatesalso PIChar +//! \~english Compare operator +//! \~russian Оператор сравнения +inline bool operator <=(const int v, const PIChar & c) {return (PIChar((ushort)v) <= c);} #endif // PICHAR_H diff --git a/libs/main/core/pichunkstream.cpp b/libs/main/core/pichunkstream.cpp index c5a69664..95eaa232 100644 --- a/libs/main/core/pichunkstream.cpp +++ b/libs/main/core/pichunkstream.cpp @@ -19,45 +19,77 @@ #include "pichunkstream.h" -/*! \class PIChunkStream - * \brief Class for binary serialization - * - * \section PIChunkStream_sec0 Synopsis - * This class provides very handly mechanism to store and restore values to and from - * \a PIByteArray. The main advantage of using this class is that your binary data - * become independent from order and collection of your values. - * - * \section PIChunkStream_sec1 Mechanism - * %PIChunkStream works with items called "chunk". Chunk is an ID and any value that - * can be stored and restored to \a PIByteArray with stream operators << and >>. - * You can place chunks to stream and read chunks from stream. - * - * To construct %PIChunkStream for writing data use any constructor. Empty constructor - * creates internal empty buffer that can be accessed by function \a data(). - * Non-empty constructor works with given byte array. - * - * To read chunks from byte array use function \a read() that returns ID of - * next chunk. Then you can get value of this chunk with function \a getData(), - * but you should definitely know type of this value. You can read from byte array - * while \a atEnd() if false. - * - * \section PIChunkStream_sec2 Examples - * - * Using simple operator and cascade serialization: - * - * Prepare your structs to work with %PIChunkStream: - * \snippet pichunkstream.cpp struct - * Old-style writing to %PIChunkStream: - * \snippet pichunkstream.cpp write - * Fastest reading from %PIChunkStream: - * \snippet pichunkstream.cpp read - * - * And next code show how to serialize your struct with %PIChunkStream: - * \snippet pichunkstream.cpp write_new - * - * ... and deserialize: - * \snippet pichunkstream.cpp read_new - */ +//! \addtogroup Core +//! \{ +//! \class PIChunkStream pichunkstream.h +//! \brief +//! \~english Class for binary de/serialization +//! \~russian Класс для бинарной де/сериализации +//! +//! \~english \section PIChunkStream_sec0 Synopsis +//! \~russian \section PIChunkStream_sec0 Краткий обзор +//! \~english +//! This class provides very handly mechanism to store and restore values to and from +//! \a PIByteArray. The main advantage of using this class is that your binary data +//! become independent from order and collection of your values. +//! +//! \~russian +//! Этот класс предоставляет очень удобный механизм для сохранения и извлечения значений +//! в/из \a PIByteArray. Главным плюсом является то, что данные не будут зависеть от порядка +//! и наличия значений. +//! +//! \~english \section PIChunkStream_sec1 Mechanism +//! \~russian \section PIChunkStream_sec1 Механизм +//! \~english +//! %PIChunkStream works with items called "chunk". Chunk is an ID, size and any value that +//! can be stored and restored to/from %PIChunkStream with stream operators << and >>. +//! +//! To construct %PIChunkStream for writing data use any non-default constructor. Empty constructor +//! creates internal buffer that can be accessed by function \a data(). +//! Non-empty constructor works with given byte array. +//! +//! To read chunks from byte array use function \a read() that returns ID of +//! readed chunk. Then you can get value of this chunk with functions \a getData() or \a get(), +//! but you should definitely know type of this value. You can read from byte array +//! while \a atEnd() if false. +//! +//! \~russian +//! %PIChunkStream работает с элементами под названием "чанк". Чанк имеет ID, размер и значение, +//! и может быть записан или прочитан в/из %PIChunkStream с помощью операторов << и >>. +//! +//! Для создания потока на запись используется любой не-умолчальный конструктор. Пустой конструктор +//! создает внутренний буфер, который можно получить с помощью метода \a data(). +//! Непустой конструктор работает с переданным байтовым массивом. +//! +//! Для чтения чанков из байтового массива используется метод \a read(), который возвращает +//! ID прочитанного чанка. Получить значение этого чанка далее можно с помощью методов \a getData() или get(), +//! но тип значения должен быть известен. Читать из потока можно пока метод \a atEnd() возвращает ложь. +//! +//! \~english \section PIChunkStream_sec2 Examples +//! \~russian \section PIChunkStream_sec2 Пример +//! +//! \~english Using simple operator and cascade serialization: +//! \~russian Использование простого оператора и каскадная сериализация: +//! +//! \~english Prepare your structs to work with %PIChunkStream: +//! \~russian Подготовка своей структуры для работы с %PIChunkStream: +//! \~\snippet pichunkstream.cpp struct +//! \~english Old-style writing to %PIChunkStream: +//! \~russian Старый стиль использования %PIChunkStream: +//! \~\snippet pichunkstream.cpp write +//! \~english Fastest reading from %PIChunkStream: +//! \~russian Самое быстрое чтение из %PIChunkStream: +//! \~\snippet pichunkstream.cpp read +//! +//! \~english And next code show how to serialize your struct with %PIChunkStream: +//! \~russian Следующий код показывает, как сериализовать свою структуру в %PIChunkStream: +//! \~\snippet pichunkstream.cpp write_new +//! +//! \~english ... and deserialize: +//! \~russian ... в десериализовать: +//! \~\snippet pichunkstream.cpp read_new +//! +//! \} void PIChunkStream::setSource(const PIByteArray & data) { diff --git a/libs/main/core/pichunkstream.h b/libs/main/core/pichunkstream.h index 16f96824..7f1fa2ce 100644 --- a/libs/main/core/pichunkstream.h +++ b/libs/main/core/pichunkstream.h @@ -1,5 +1,7 @@ /*! \file pichunkstream.h - * \brief Binary markup serializator + * \~\brief + * \~english Binary markup de/serializator stream + * \~russian Бинарный поток для де/сериализации с разметкой */ /* PIP - Platform Independent Primitives @@ -30,20 +32,27 @@ class PIP_EXPORT PIChunkStream { public: + //! \~english //! Version of data packing. Read-access %PIChunkStream automatic detect version, but write-access //! %PIChunkStream by default write in new version, be careful! + //! \~russian + //! Версия хранения данных. %PIChunkStream на чтение автоматически определяет версию, но для записи + //! использует по умолчанию новую, осторожно! enum Version { - Version_1 /*! First, old version */, - Version_2 /*! Second, more optimized version */ = 2, + Version_1 /*! \~english First, old version \~russian Первая, старая версия */, + Version_2 /*! \~english Second, more optimized version \~russian Вторая, более оптимизированная версия */ = 2, }; - //! Contructs stream for read from "data" + //! \~english Contructs stream for read from "data" + //! \~russian Создает поток на чтение из "data" PIChunkStream(const PIByteArray & data): version_(Version_2) {setSource(data);} - //! Contructs stream for read or write to/from "data", or empty stream for write + //! \~english Contructs stream for read or write to/from "data", or empty stream for write if "data" = 0 + //! \~russian Создает поток на чтение или запись из/в "data", или пустой поток на запись если "data" = 0 PIChunkStream(PIByteArray * data = 0, Version v = Version_2): version_(v) {setSource(data);} - //! Contructs empty stream for write with version \"v\" + //! \~english Contructs empty stream for write with version \"v\" + //! \~russian Создает пустой поток на запись с версией \"v\" PIChunkStream(Version v): version_(v) {setSource(0);} ~PIChunkStream(); @@ -61,48 +70,64 @@ public: const T & data; }; - //! Returns chunk with ID "id" and value "data" for write to stream + //! \~english Returns chunk with ID "id" and value "data" for write to stream + //! \~russian Возвращает чанк с ID "id" и значением "data" для записи в поток template static ChunkConst chunk(int id, const T & data) {return ChunkConst(id, data);} - //! Add data to this chunk strean with ID "id" and value "data" + //! \~english Add to this stream chunk with ID "id" and value "data" + //! \~russian Добавляет в этот поток чанк с ID "id" и значением "data" template PIChunkStream & add(int id, const T & data) {*this << ChunkConst(id, data); return *this;} + //! \~english //! Extract %PIByteArray from "data" and set it current stream. //! If "read_all" then call \a readAll() after extract. //! Returns if has data to read. + //! \~russian + //! Извлекает %PIByteArray из "data" и инициализирует им поток. + //! Если указан "read_all", то вызывает \a readAll() после инициализации. + //! Возвращает если ли данные для чтения. bool extract(PIByteArray & data, bool read_all = false); void setSource(const PIByteArray & data); void setSource(PIByteArray * data); - //! Returns internal buffer with written data + //! \~english Returns internal buffer with written data + //! \~russian Возвращает внутренний буфер с записанными данными PIByteArray data() const; - //! Returns if there is end of stream + //! \~english Returns if there is end of stream + //! \~russian Возвращает достигнут ли конец потока bool atEnd() const {return data_->size_s() <= 1;} - //! Returns stream version + //! \~english Returns stream version + //! \~russian Возвращает версию потока Version version() const {return (Version)version_;} - //! Read one chunk from stream and returns its ID + //! \~english Read one chunk from stream and returns its ID + //! \~russian Читает один чанк из потока и возвращает его ID int read(); - //! Read all chunks from stream. This function just index input data + //! \~english Read all chunks from stream. This function just index input data + //! \~russian Читает все чанки из потока. Данный метод лишь индексирует данные void readAll(); - //! Returns last readed chunk ID + //! \~english Returns last readed chunk ID + //! \~russian Возвращает ID последнего прочитанного чанка int getID() {return last_id;} - //! Returns value of last readed chunk + //! \~english Returns value of last readed chunk + //! \~russian Возвращает значение последнего прочитанного чанка template T getData() const {T ret; PIByteArray s(last_data); s >> ret; return ret;} - //! Place value of last readed chunk into \"v\" + //! \~english Place value of last readed chunk into \"v\" + //! \~russian Записывает значение последнего прочитанного чанка в \"v\" template void get(T & v) const {v = getData();} - //! Place value of chunk with id \"id\" into \"v\". You should call \a readAll() before using this function! + //! \~english Place value of chunk with ID \"id\" into \"v\". You should call \a readAll() before using this function! + //! \~russian Записывает значение чанка с ID \"id\" в \"v\". Необходимо вызвать \a readAll() перед использованием этого метода! template const PIChunkStream & get(int id, T & v) const { CacheEntry pos = data_map.value(id); @@ -113,7 +138,8 @@ public: return *this; } - //! Replace value of chunk with ID \"id\" to \"v\". You should call \a readAll() before using this function! + //! \~english Replace value of chunk with ID \"id\" to \"v\". You should call \a readAll() before using this function! + //! \~russian Заменяет значение чанка с ID \"id\" на \"v\". Необходимо вызвать \a readAll() перед использованием этого метода! template PIChunkStream & set(int id, const T & v) { PIByteArray ba; diff --git a/libs/main/core/picli.cpp b/libs/main/core/picli.cpp index cb58e5e4..3c85c040 100644 --- a/libs/main/core/picli.cpp +++ b/libs/main/core/picli.cpp @@ -21,16 +21,32 @@ #include "pisysteminfo.h" -/*! \class PICLI - * \brief Command-line arguments parser - * - * \section PICLI_sec0 Synopsis - * This class provide handy parsing of command-line arguments. First you should add - * arguments to PICLI with function \a addArgument(). Then you can check if there - * is some argument in application command-line with function \a hasArgument(); - * \section PICLI_sec1 Example - * \snippet picli.cpp main - */ +//! \addtogroup Core +//! \{ +//! \class PICLI picli.h +//! \~\brief +//! \~english Command-Line parser +//! \~russian Парсер командной строки +//! +//! \~english \section PICLI_sec0 Synopsis +//! \~russian \section PICLI_sec0 Краткий обзор +//! \~english +//! This class provide handy parsing of command-line arguments. First you should add +//! arguments to %PICLI with function \a addArgument(). Then you can check if there +//! is some argument in application command-line with function \a hasArgument(), +//! or obtain argument value by \a argumentValue(). +//! +//! \~russian +//! Этот класс предоставляет удобный механизм для разбора аргументов командной строки. +//! Сперва необходимо добавить аргументы в %PICLI с помощью методов \a addArgument(). +//! Далее можно проверять аргументы на наличие в командной строке методом \a hasArgument(), +//! а также получить их значения при помощи \a argumentValue(). +//! +//! \~english \section PICLI_sec1 Example +//! \~russian \section PICLI_sec0 Пример +//! \~\snippet picli.cpp main +//! +//! /} PICLI::PICLI(int argc, char * argv[]) { diff --git a/libs/main/core/picli.h b/libs/main/core/picli.h index 43d8e01c..c2792877 100644 --- a/libs/main/core/picli.h +++ b/libs/main/core/picli.h @@ -1,5 +1,7 @@ /*! \file picli.h - * \brief Command-Line parser + * \~\brief + * \~english Command-Line parser + * \~russian Парсер командной строки */ /* PIP - Platform Independent Primitives @@ -30,39 +32,54 @@ class PIP_EXPORT PICLI: public PIObject PIOBJECT_SUBCLASS(PICLI, PIObject) public: - //! Constructor + //! \~english Constructor + //! \~russian Конструктор PICLI(int argc, char * argv[]); - //! Add argument with name "name", short key = name first letter, full key = name + //! \~english Add argument with name "name", short key = name first letter and full key = name + //! \~russian Добавляет аргумент с именем "name", коротким ключом = первой букве имени и полным ключом = имени void addArgument(const PIString & name, bool value = false) {_args << Argument(name, name[0], name, value); needParse = true;} - //! Add argument with name "name", short key = "shortKey", full key = name + //! \~english Add argument with name "name", short key = "shortKey" and full key = name + //! \~russian Добавляет аргумент с именем "name", коротким ключом = "shortKey" и полным ключом = имени void addArgument(const PIString & name, const PIChar & shortKey, bool value = false) {_args << Argument(name, shortKey, name, value); needParse = true;} - //! Add argument with name "name", short key = "shortKey", full key = name + //! \~english Add argument with name "name", short key = "shortKey" and full key = name + //! \~russian Добавляет аргумент с именем "name", коротким ключом = "shortKey" и полным ключом = имени void addArgument(const PIString & name, const char * shortKey, bool value = false) {_args << Argument(name, PIChar(shortKey), name, value); needParse = true;} - //! Add argument with name "name", short key = "shortKey", full key = "fullKey" + //! \~english Add argument with name "name", short key = "shortKey" and full key = "fullKey" + //! \~russian Добавляет аргумент с именем "name", коротким ключом = "shortKey" и полным ключом = "fullKey" void addArgument(const PIString & name, const PIChar & shortKey, const PIString & fullKey, bool value = false) {_args << Argument(name, shortKey, fullKey, value); needParse = true;} - //! Add argument with name "name", short key = "shortKey", full key = "fullKey" + //! \~english Add argument with name "name", short key = "shortKey" and full key = "fullKey" + //! \~russian Добавляет аргумент с именем "name", коротким ключом = "shortKey" и полным ключом = "fullKey" void addArgument(const PIString & name, const char * shortKey, const PIString & fullKey, bool value = false) {_args << Argument(name, PIChar(shortKey), fullKey, value); needParse = true;} - //! Returns unparsed command-line argument by index "index". Index 0 is program execute command. + //! \~english Returns unparsed command-line argument by index "index". Index 0 is program execute command + //! \~russian Возвращает исходный аргумент командной строки по индексу "index". Индекс 0 это команда вызова программы PIString rawArgument(int index) {parse(); return _args_raw[index];} PIString mandatoryArgument(int index) {parse(); return _args_mand[index];} PIString optionalArgument(int index) {parse(); return _args_opt[index];} - //! Returns unparsed command-line arguments + //! \~english Returns unparsed command-line arguments + //! \~russian Возвращает исходные аргументы командной строки const PIStringList & rawArguments() {parse(); return _args_raw;} const PIStringList & mandatoryArguments() {parse(); return _args_mand;} const PIStringList & optionalArguments() {parse(); return _args_opt;} - //! Returns program execute command without arguments + //! \~english Returns program execute command without arguments + //! \~russian Возвращает команду вызова программы без аргументов PIString programCommand() {parse(); return _args_raw.size() > 0 ? _args_raw.front() : PIString();} + + //! \~english Returns if argument "name" found + //! \~russian Возвращает найден ли аргумент "name" bool hasArgument(const PIString & name) {parse(); piForeach (Argument & i, _args) if (i.name == name && i.found) return true; return false;} + + //! \~english Returns argument "name" value, or empty string if this is no value + //! \~russian Возвращает значение аргумента "name" или пустую строку, если значения нет PIString argumentValue(const PIString & name) {parse(); piForeach (Argument &i, _args) if (i.name == name && i.found) return i.value; return PIString();} PIString argumentShortKey(const PIString & name) {piForeach (Argument &i, _args) if (i.name == name) return i.short_key; return PIString();} PIString argumentFullKey(const PIString & name) {piForeach (Argument &i, _args) if (i.name == name) return i.full_key; return PIString();} diff --git a/libs/main/core/picoremodule.h b/libs/main/core/picoremodule.h index de313302..abb88bbf 100644 --- a/libs/main/core/picoremodule.h +++ b/libs/main/core/picoremodule.h @@ -16,6 +16,46 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +/** \defgroup Core + * \~\brief + * \~english This module contains basic functionality. + * \~russian Модуль обеспечивает базовую функциональность. + * + * \~\details + * Scope | Use + * ----- | ------- + * C++ | #include + * CMake | PIP + * + * \~english These files provides platform abstraction, useful macros, methods and classes: + * \~russian Эти файлы обеспечивают абстракцию операционной системы, полезные макросы, методы и классы: + * \~ + * * \a PIFlags + * * \a PICout + * * \a PICLI + * * \a PIChar + * * \a PIString + * * \a PIStringList + * * \a PIBitArray + * * \a PIByteArray + * * \a PIChunkStream + * * \a PIPropertyStorage + * * \a PITime + * * \a PIDate + * * \a PIDateTime + * * \a PISystemTime + * * \a PITimeMeasurer + * * \a PIVariant + * * \a PIObject + * + * \~\authors + * \~english + * Ivan Pelipenko peri4ko@yandex.ru; + * Andrey Bychkov work.a.b@yandex.ru; + * \~russian + * Иван Пелипенко peri4ko@yandex.ru; + * Андрей Бычков work.a.b@yandex.ru; +*/ #ifndef PICOREMODULE_H #define PICOREMODULE_H diff --git a/libs/main/core/picout.cpp b/libs/main/core/picout.cpp index edc61909..1a107ac7 100644 --- a/libs/main/core/picout.cpp +++ b/libs/main/core/picout.cpp @@ -273,10 +273,10 @@ PICout PICout::operator <<(const PICoutSpecialChar v) { switch (v) { case Null: if (buffer_) { - (*buffer_) << PIChar(0); + (*buffer_) << PIChar(); } else { if (isOutputDeviceActive(StdOut)) std::cout << char(0); - if (isOutputDeviceActive(Buffer)) PICout::__string__() << PIChar(0); + if (isOutputDeviceActive(Buffer)) PICout::__string__() << PIChar(); } break; case NewLine: diff --git a/libs/main/io_devices/piethernet.cpp b/libs/main/io_devices/piethernet.cpp index 315927ad..fcf4a00b 100644 --- a/libs/main/io_devices/piethernet.cpp +++ b/libs/main/io_devices/piethernet.cpp @@ -69,9 +69,11 @@ #include -/** \class PIEthernet - * \brief Ethernet device - * \details +/** \class PIEthernet piethernet.h + * \brief + * Ethernet device + * + * \details * \section PIEthernet_sec0 Synopsis * %PIEthernet designed to work with IPv4 network via two protocols: * UDP and TCP. This class allow you send and receive packets to/from diff --git a/utils/piterminal/main.cpp b/utils/piterminal/main.cpp index 0e45491b..aeae643d 100644 --- a/utils/piterminal/main.cpp +++ b/utils/piterminal/main.cpp @@ -200,9 +200,9 @@ public: ir[j].Event.KeyEvent.dwControlKeyState = KeyModifiers2ControlKeyState(k.modifiers); if (PITerminal::isSpecialKey(k.key)) { ir[j].Event.KeyEvent.wVirtualKeyCode = SpecialKey2VirtualKeyCode((PIKbdListener::SpecialKey)k.key); - ir[j].Event.KeyEvent.uChar.AsciiChar = PIChar(piMaxi(k.key, 0)).toAscii(); + ir[j].Event.KeyEvent.uChar.AsciiChar = PIChar((ushort)piMaxi(k.key, 0)).toAscii(); } else - ir[j].Event.KeyEvent.uChar.UnicodeChar = PIChar(piMaxi(k.key, 0)).toWChar(); + ir[j].Event.KeyEvent.uChar.UnicodeChar = PIChar((ushort)piMaxi(k.key, 0)).toWChar(); //piCout << ir[j].Event.KeyEvent.wVirtualKeyCode << int(ir[j].Event.KeyEvent.uChar.AsciiChar); ir[j].Event.KeyEvent.bKeyDown = true; ir[z] = ir[j];