BIG deep clean

This commit is contained in:
2020-06-10 13:14:16 +03:00
parent f579718e0b
commit c59579d5d5
222 changed files with 2392 additions and 11600 deletions

View File

@@ -43,20 +43,6 @@ endif()
set(CMAKE_CXX_STANDARD 11)
# Apple crosscompiling rpath patch
# macro(apple_rpath_patch _T)
# if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
# foreach(_RP ${CMAKE_INSTALL_RPATH})
# add_custom_command(TARGET ${_T} POST_BUILD
# COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
# "-add_rpath" "${_RP}"
# "$<TARGET_FILE_DIR:${_T}>/$<TARGET_FILE_NAME:${_T}>"
# COMMENT "Add to ${_T} rpath \"${_RP}\"")
# endforeach()
# endif()
# endmacro()
# Basic
macro(gather_src DIR CPP H H_P)
set(CS)
@@ -175,7 +161,6 @@ endif()
# Compiler
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
#link_directories(${CMAKE_CURRENT_BINARY_DIR})
#message("${C_COMPILER}")
@@ -183,10 +168,6 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
# Main lib
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
if(PIP_FREERTOS)
#list(REMOVE_ITEM PIP_FOLDERS "console")
#include_directories("${PIP_SRC_MAIN}/console")
endif()
include_directories("${PIP_SRC_MAIN}")
set(PIP_MAIN_FOLDERS)
foreach(F ${PIP_FOLDERS})
@@ -350,7 +331,6 @@ if(APPLE)
endif()
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${ANDROID_NDK}/sysroot/usr/include")
#message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include")
#message("${ANDROID_NDK}/sysroot/usr/include")
endif()
@@ -679,9 +659,6 @@ if(LIB)
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
# Precompiled header
#add_custom_target(pip_pch ALL COMMAND ${CMAKE_CXX_COMPILER} -O2 -fPIC -g3 ${CMAKE_INSTALL_PREFIX}/include/pip/pip.h DEPENDS pip SOURCES ${HDRS})
#list(APPEND HDRS "pip.h.gch")
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else()
@@ -697,10 +674,6 @@ else()
endif()
endif()
# foreach(_T ${PIP_LIBS_TARGETS})
# apple_rpath_patch(${_T})
# endforeach()
if(NOT PIP_FREERTOS)
# Auxiliary
@@ -745,27 +718,6 @@ endif()
#
# Build Documentation
#
# find_package(Doxygen QUIET)
# if(Doxygen_FOUND)
# message(STATUS "Building PIP with documentation via Doxygen")
# #set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in)
# set(DOXYFILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
# #configure_file(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
# add_custom_target(DOC
# COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
# COMMENT "Generating API documentation with Doxygen"
# VERBATIM)
# add_custom_command(TARGET DOC
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/source/doc/Documentation.html ${CMAKE_SOURCE_DIR}/doc
# )
# install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
# endif()
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
include(PIPDocumentation)
find_package(Doxygen)

View File

@@ -388,7 +388,6 @@ macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
else()
set(_p "${_RELPATH}/${_PATH}")
endif()
#if (EXISTS "${_p}")
if ("${_p}" MATCHES ".*/$")
string(LENGTH "${_p}" __sl)
math(EXPR __sl ${__sl}-1)
@@ -397,7 +396,6 @@ macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
else()
list(APPEND ${_FILE_VAR} "${_p}")
endif()
#endif()
endmacro()
set(__win_host 0)
@@ -617,7 +615,6 @@ macro(deploy_target _T)
foreach (_L ${DEPLOY_ADD_LIBPATH})
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
endforeach()
#set(_add_search_path "${_add_search_path}")
#message("app depend ${_T} libpath ${_add_search_path}")
set(_CMD_)
set(_deployed)
@@ -643,8 +640,6 @@ macro(deploy_target _T)
endif()
endforeach()
endif()
#execute_process(COMMAND "lsb_release -si" OUTPUT_VARIABLE _os_id)
#execute_process(COMMAND "lsb_release -sr" OUTPUT_VARIABLE _os_ver)
set(_build "${${_T}_VERSION_BUILD}")
if (NOT "x${_build}" STREQUAL "x")
set(_build "-${_build}")
@@ -770,7 +765,6 @@ macro(deploy_target _T)
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_}
#COMMAND -l "${CMAKE_LDD}" -P xcb -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib;${_add_search_path}\"" -o ${_AGD}/usr/lib -p ${_AGD}/usr/ ${_AGD}/Contents/MacOS/${_T}
# generate deb
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
@@ -826,7 +820,6 @@ macro(deploy_target _T)
${_CMD_}
# generate deb
#COMMAND cd ${_AGD} "&&" md5deep -rl * ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM
@@ -893,13 +886,8 @@ macro(deploy_target _T)
endif()
set(_dmg_name "${_TV}_macosx_x64.dmg")
set(_cmd_gen_dmg COMMAND genisoimage -quiet -V "${MACOSX_BUNDLE_BUNDLE_NAME}" -D -R -apple -no-pad -o ${_DESTINATION}/${_dmg_name} ${_DMG})
#set(_cmd_int)
if (__mac_host)
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG})
#set(_rpathes "@executable_path/../Frameworks" "@executable_path/lib" "@loader_path/../lib")
#foreach (_r ${_rpathes})
# set(_cmd_int ${_cmd_int} COMMAND install_name_tool -add_rpath "${_r}" \"${_AGD}/Contents/MacOS/${_T}\")
#endforeach()
endif()
if (_ZIP_DMG)
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"")
@@ -915,10 +903,7 @@ macro(deploy_target _T)
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Frameworks
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
${_CMD_}
#COMMAND cp ${_ICON_FN} ${_AGD}/Contents/Resources
#COMMAND cp -r ${_DEPLOY_DIR}/lang ${_AGD}/Contents/Resources
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -M "${CMAKE_OTOOL}" -P cocoa,minimal -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib${_add_search_path}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_ADD_DEPS}
#${_cmd_int}
# prepare dmg dir
COMMAND rm -rf ${_DMG}
COMMAND mkdir ${_VERB} -p ${_DMG}
@@ -949,8 +934,6 @@ macro(deploy_target _T)
endforeach()
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>")
#__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}/res")
#__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}/Contents/MacOS")
set(_AT ${_T}_lib)
set(_ATA ${_AT}_${ANDROID_ABI})
get_target_property(_sources ${_T} SOURCES)
@@ -976,9 +959,7 @@ macro(deploy_target _T)
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
__make_copy(_CMD_ _dir _file "${_AGD}")
#__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/")
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
#get_target_property(_LL ${_T} )
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
if("x${SDK_ROOT}" STREQUAL "x")
set(SDK_ROOT "$ENV{ANDROID_HOME}")
@@ -1059,7 +1040,6 @@ macro(deploy_target _T)
if (NOT __win_host)
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
endif()
#set(_CMD_ ${_CMD_} COMMAND "${SDK_ROOT}/tools/android" update project --path "\"${_AGD}\"" --target android-${ANDROID_TARGET_SDK} --name QtApp)
set(_CMD_ ${_CMD_} COMMAND "${Qt5_BIN}/androiddeployqt" --aux-mode --android-platform ${ANDROID_PLATFORM} --output "\"${_AGD}\"" --input "\"${_out_json}\"")
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" assembleDebug)
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)

View File

@@ -12,7 +12,6 @@ if(${MINGW})
PATH_SUFFIXES
include)
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
#if(NOT ${MINGW_INCLUDE}) MINGW_INCLUDE = ${MINGW_DIR}/include
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
if (NOT _MGW_MSG)

View File

@@ -16,7 +16,6 @@ main library
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
#set(_PIP_MODULES pip pip_usb pip_crypt pip_fftw)
if(WIN32)
find_package(MinGW REQUIRED)
endif()
@@ -33,10 +32,6 @@ endif()
if(CMAKE_CROSSCOMPILING)
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
#if (DEFINED ANDROID_PLATFORM)
# list(APPEND _PIP_INCDIR ${CMAKE_PREFIX_PATH}/include/pip)
# list(APPEND _PIP_LIBDIR ${CMAKE_PREFIX_PATH}/lib)
#endif()
else()
if(NOT WIN32)
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
@@ -60,9 +55,6 @@ else()
endif()
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
set(_pip_suffix "")
#if(DEFINED ANDROID_PLATFORM)
# set(_pip_suffix "_${ANDROID_ABI}")
#endif()
find_library(PIP_LIBRARY pip${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_USB_LIBRARY pip_usb${_pip_suffix} HINTS ${_PIP_LIBDIR})
@@ -73,11 +65,7 @@ find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR
find_library(PIP_CONCURRENT_LIBRARY pip_concurrent${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
#if (DEFINED ANDROID_PLATFORM)
# set(PIP_INCLUDES ${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include/pip)
#else()
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
#endif()
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
set(__ext "")
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
set(__ext ".exe")

View File

@@ -86,17 +86,11 @@ macro(pip_resources RESULT INPUT)
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
set(${RESULT} ${${RESULT}} ${RC_OUT})
set(CCM_FILES)
#if (ABS)
if(IS_ABSOLUTE "${INPUT}")
set(RC_FILES "${INPUT}")
else()
set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
endif()
#else()
# foreach(csrc ${CCM_SRC})
# list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
# endforeach()
#endif()
#message(STATUS "CCM = ${RESULT}")
if(NOT DEFINED PIP_DLL_DIR)
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})

View File

@@ -16,7 +16,6 @@ list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/system")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/thread")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/introspection")
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs)
#set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component()
set(PIP_FREERTOS ON)
set(LIB OFF)

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
PICloud Client
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
PICloud Server
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
PICloud TCP transport
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Cryptographic class using lib Sodium
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Compress class using zlib
Andrey Bychkov work.a.b@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

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Stephan Fomenko
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/>.
*/
#include "executor.h"

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Stephan Fomenko
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/>.
*/
#include "piconditionlock.h"
#ifdef WINDOWS
#include "synchapi.h"

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Stephan Fomenko
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/>.
*/
#include "piplatform.h"
#include "piconditionvar.h"
#include "pithread.h"

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
PIP Authentication API
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Cryptographic class using lib Sodium
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,249 +0,0 @@
/*
PIP - Platform Independent Primitives
Variable, Struct (simple serialization)
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pivariable.h"
bool PIVariant::operator ==(const PIVariant & v) const {
if (type != v.type) return false;
switch (type) {
case PIVariant::Bool: return vBool == v.vBool;
case PIVariant::Char: return vChar == v.vChar;
case PIVariant::Short: return vShort == v.vShort;
case PIVariant::Int: return vInt == v.vInt;
case PIVariant::Long: return vLong == v.vLong;
case PIVariant::LLong: return vLLong == v.vLLong;
case PIVariant::UChar: return vUChar == v.vUChar;
case PIVariant::UShort: return vUShort == v.vUShort;
case PIVariant::UInt: return vUInt == v.vUInt;
case PIVariant::ULong: return vULong == v.vULong;
case PIVariant::ULLong: return vULLong == v.vULLong;
case PIVariant::Float: return vFloat == v.vFloat;
case PIVariant::Double: return vDouble == v.vDouble;
case PIVariant::LDouble: return vLDouble == v.vLDouble;
case PIVariant::String: return vString == v.vString;
case PIVariant::StringList: return vStringList == v.vStringList;
};
return false;
}
void PIVariant::setValueOnly(const PIString & s) {
switch (type) {
case PIVariant::Bool: vBool = s.toBool(); break;
case PIVariant::Char: vChar = s.toChar(); break;
case PIVariant::Short: vShort = s.toShort(); break;
case PIVariant::Int: vInt = s.toInt(); break;
case PIVariant::Long: vLong = s.toLong(); break;
case PIVariant::LLong: vLLong = s.toLLong(); break;
case PIVariant::UChar: vUChar = s.toChar(); break;
case PIVariant::UShort: vUShort = s.toShort(); break;
case PIVariant::UInt: vUInt = s.toInt(); break;
case PIVariant::ULong: vULong = s.toLong(); break;
case PIVariant::ULLong: vULLong = s.toLLong(); break;
case PIVariant::Float: vFloat = s.toFloat(); break;
case PIVariant::Double: vDouble = s.toDouble(); break;
case PIVariant::LDouble: vLDouble = s.toLDouble(); break;
case PIVariant::String: vString = s; break;
case PIVariant::StringList: vStringList = s.split("%|%"); break;
};
}
PIString PIVariant::stringValue() const {
switch (type) {
case PIVariant::Bool: return (vBool ? "true" : "false");
case PIVariant::Char: return PIString::fromNumber(vChar);
case PIVariant::Short: return PIString::fromNumber(vShort);
case PIVariant::Int: return PIString::fromNumber(vInt);
case PIVariant::Long: return PIString::fromNumber(vLong);
case PIVariant::LLong: return PIString::fromNumber(static_cast<long>(vLLong));
case PIVariant::UChar: return PIString::fromNumber(vUChar);
case PIVariant::UShort: return PIString::fromNumber(vUShort);
case PIVariant::UInt: return PIString::fromNumber(vUInt);
case PIVariant::ULong: return PIString::fromNumber(static_cast<long>(vULong));
case PIVariant::ULLong: return PIString::fromNumber(static_cast<long>(vULLong));
case PIVariant::Float: return PIString::fromNumber(vFloat);
case PIVariant::Double: return PIString::fromNumber(vDouble);
case PIVariant::LDouble: return PIString::fromNumber(vLDouble);
case PIVariant::String: return vString;
case PIVariant::StringList: return vStringList.join("%|%");
};
return vString;
}
PIVariant PIVariant::readFromString(const PIString & s) {
int i = s.find(':');
if (i < 0 || s.length() < 2) return PIVariant(s);
PIVariant ret;
ret.type = PIVariant::fromString(s.left(i));
ret.setValueOnly(s.right(s.length() - i - 1));
return ret;
}
PIVariant::Type PIVariant::fromString(const PIString & str) {
PIString s = str.trimmed().toLowerCase().replace(" ", "");
if (s == "bool") return PIVariant::Bool;
if (s == "char" || s == "sbyte") return PIVariant::Char;
if (s == "short" || s == "short int" || s == "signed short" || s == "signed short int" || s == "sword") return PIVariant::Short;
if (s == "int" || s == "signed" || s == "signed int") return PIVariant::Int;
if (s == "long" || s == "long int" || s == "signed long" || s == "signed long int" || s == "sdword") return PIVariant::Long;
if (s == "llong" || s == "long long" || s == "long long int" || s == "signed long long" || s == "signed long long int" || s == "sqword") return PIVariant::LLong;
if (s == "uchar" || s == "byte") return PIVariant::UChar;
if (s == "ushort" || s == "unsigned short" || s == "unsigned short int" || s == "word") return PIVariant::UShort;
if (s == "uint" || s == "unsigned" || s == "unsigned int") return PIVariant::UInt;
if (s == "ulong" || s == "unsigned long" || s == "unsigned long int" || s == "dword") return PIVariant::ULong;
if (s == "ullong" || s == "unsigned long long" || s == "unsigned long long int" || s == "qword") return PIVariant::ULLong;
if (s == "float") return PIVariant::Float;
if (s == "double" || s == "real") return PIVariant::Double;
if (s == "ldouble" || s == "long double") return PIVariant::LDouble;
if (s == "pistring" || s == "string") return PIVariant::String;
if (s == "pistringlist" || s == "vector<string>" || s == "vector<pistring>" || s == "pivector<string>" || s == "pivector<pistring>") return PIVariant::StringList;
return PIVariant::Double;
}
PIString PIVariant::toString(const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return "bool";
case PIVariant::Char: return "char";
case PIVariant::Short: return "short";
case PIVariant::Int: return "int";
case PIVariant::Long: return "long";
case PIVariant::LLong: return "llong";
case PIVariant::UChar: return "uchar";
case PIVariant::UShort: return "ushort";
case PIVariant::UInt: return "uint";
case PIVariant::ULong: return "ulong";
case PIVariant::ULLong: return "ullong";
case PIVariant::Float: return "float";
case PIVariant::Double: return "double";
case PIVariant::LDouble: return "ldouble";
case PIVariant::String: return "string";
case PIVariant::StringList: return "stringlist";
}
return "double";
}
uint PIVariant::variableSize(const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return sizeof(bool);
case PIVariant::Char: return sizeof(char);
case PIVariant::Short: return sizeof(short);
case PIVariant::Int: return sizeof(int);
case PIVariant::Long: return sizeof(long);
case PIVariant::LLong: return sizeof(llong);
case PIVariant::UChar: return sizeof(uchar);
case PIVariant::UShort: return sizeof(ushort);
case PIVariant::UInt: return sizeof(uint);
case PIVariant::ULong: return sizeof(ulong);
case PIVariant::ULLong: return sizeof(ullong);
case PIVariant::Float: return sizeof(float);
case PIVariant::Double: return sizeof(double);
case PIVariant::LDouble: return sizeof(ldouble);
default: break;
}
return 0;
}
double PIVariant::variableValue(const void * var_ptr, const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return (double)(*((bool * )var_ptr));
case PIVariant::Char: return (double)(*((char * )var_ptr));
case PIVariant::Short: return (double)(*((short * )var_ptr));
case PIVariant::Int: return (double)(*((int * )var_ptr));
case PIVariant::Long: return (double)(*((long * )var_ptr));
case PIVariant::LLong: return (double)(*((llong * )var_ptr));
case PIVariant::UChar: return (double)(*((uchar * )var_ptr));
case PIVariant::UShort: return (double)(*((ushort * )var_ptr));
case PIVariant::UInt: return (double)(*((uint * )var_ptr));
case PIVariant::ULong: return (double)(*((ulong * )var_ptr));
case PIVariant::ULLong: return (double)(*((ullong * )var_ptr));
case PIVariant::Float: return (double)(*((float * )var_ptr));
case PIVariant::Double: return (double)(*((double * )var_ptr));
case PIVariant::LDouble: return (ldouble)(*((ldouble * )var_ptr));
default: break;
}
return 0.;
}
void PIVariable::setVariable(const PIString & str) {
type_ = PIVariant::fromString(str);
size_ = PIVariant::variableSize(type_);
}
void PIVariable::writeVariable(void * dest) {
switch (type_) {
case PIVariant::Bool: *((bool * )((ullong)dest + offset)) = value_ > 0.; return;
case PIVariant::Char: *((char * )((ullong)dest + offset)) = char(value_); return;
case PIVariant::Short: *((short * )((ullong)dest + offset)) = short(value_); return;
case PIVariant::Int: *((int * )((ullong)dest + offset)) = int(value_); return;
case PIVariant::Long: *((long * )((ullong)dest + offset)) = long(value_); return;
case PIVariant::LLong: *((llong * )((ullong)dest + offset)) = llong(value_); return;
case PIVariant::UChar: *((uchar * )((ullong)dest + offset)) = uchar(value_); return;
case PIVariant::UShort: *((ushort * )((ullong)dest + offset)) = ushort(value_); return;
case PIVariant::UInt: *((uint * )((ullong)dest + offset)) = uint(value_); return;
case PIVariant::ULong: *((ulong * )((ullong)dest + offset)) = ulong(value_); return;
case PIVariant::ULLong: *((ullong * )((ullong)dest + offset)) = ullong(value_); return;
case PIVariant::Float: *((float * )((ullong)dest + offset)) = float(value_); return;
case PIVariant::Double: *((double * )((ullong)dest + offset)) = value_; return;
case PIVariant::LDouble: *((ldouble * )((ullong)dest + offset)) = ldouble(value_); return;
default: break;
}
}
void PIStruct::parseFile(const PIString & file) {
PIConfig conf(file, PIIODevice::ReadOnly);
PIVariable var;
PIString ts;
uint sz = 0;
vars.clear();
for (int i = 0; i < conf.entriesCount(); ++i) {
var.setVariable(conf.getValue(i));
var.setName(conf.getName(i));
var.offset = sz;
sz += var.size();
ts = conf.getComment(i);
if (ts.length() > 0)
var.setValue(ts.toDouble());
else var.setValue(0.);
vars.push_back(var);
}
size_ = sz;
}
void PIStruct::readData(const void * data) {
for (uint i = 0; i < vars.size(); ++i)
vars[i].readVariable(data);
}
void PIStruct::writeData(void * data) {
for (uint i = 0; i < vars.size(); ++i)
vars[i].writeVariable(data);
}

View File

@@ -1,249 +0,0 @@
/*
PIP - Platform Independent Primitives
Variable, Struct (simple serialization)
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
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/>.
*/
#include "pivariable.h"
bool PIVariant::operator ==(const PIVariant & v) const {
if (type != v.type) return false;
switch (type) {
case PIVariant::Bool: return vBool == v.vBool;
case PIVariant::Char: return vChar == v.vChar;
case PIVariant::Short: return vShort == v.vShort;
case PIVariant::Int: return vInt == v.vInt;
case PIVariant::Long: return vLong == v.vLong;
case PIVariant::LLong: return vLLong == v.vLLong;
case PIVariant::UChar: return vUChar == v.vUChar;
case PIVariant::UShort: return vUShort == v.vUShort;
case PIVariant::UInt: return vUInt == v.vUInt;
case PIVariant::ULong: return vULong == v.vULong;
case PIVariant::ULLong: return vULLong == v.vULLong;
case PIVariant::Float: return vFloat == v.vFloat;
case PIVariant::Double: return vDouble == v.vDouble;
case PIVariant::LDouble: return vLDouble == v.vLDouble;
case PIVariant::String: return vString == v.vString;
case PIVariant::StringList: return vStringList == v.vStringList;
};
return false;
}
void PIVariant::setValueOnly(const PIString & s) {
switch (type) {
case PIVariant::Bool: vBool = s.toBool(); break;
case PIVariant::Char: vChar = s.toChar(); break;
case PIVariant::Short: vShort = s.toShort(); break;
case PIVariant::Int: vInt = s.toInt(); break;
case PIVariant::Long: vLong = s.toLong(); break;
case PIVariant::LLong: vLLong = s.toLLong(); break;
case PIVariant::UChar: vUChar = s.toChar(); break;
case PIVariant::UShort: vUShort = s.toShort(); break;
case PIVariant::UInt: vUInt = s.toInt(); break;
case PIVariant::ULong: vULong = s.toLong(); break;
case PIVariant::ULLong: vULLong = s.toLLong(); break;
case PIVariant::Float: vFloat = s.toFloat(); break;
case PIVariant::Double: vDouble = s.toDouble(); break;
case PIVariant::LDouble: vLDouble = s.toLDouble(); break;
case PIVariant::String: vString = s; break;
case PIVariant::StringList: vStringList = s.split("%|%"); break;
};
}
PIString PIVariant::stringValue() const {
switch (type) {
case PIVariant::Bool: return (vBool ? "true" : "false");
case PIVariant::Char: return PIString::fromNumber(vChar);
case PIVariant::Short: return PIString::fromNumber(vShort);
case PIVariant::Int: return PIString::fromNumber(vInt);
case PIVariant::Long: return PIString::fromNumber(vLong);
case PIVariant::LLong: return PIString::fromNumber(static_cast<long>(vLLong));
case PIVariant::UChar: return PIString::fromNumber(vUChar);
case PIVariant::UShort: return PIString::fromNumber(vUShort);
case PIVariant::UInt: return PIString::fromNumber(vUInt);
case PIVariant::ULong: return PIString::fromNumber(static_cast<long>(vULong));
case PIVariant::ULLong: return PIString::fromNumber(static_cast<long>(vULLong));
case PIVariant::Float: return PIString::fromNumber(vFloat);
case PIVariant::Double: return PIString::fromNumber(vDouble);
case PIVariant::LDouble: return PIString::fromNumber(vLDouble);
case PIVariant::String: return vString;
case PIVariant::StringList: return vStringList.join("%|%");
};
return vString;
}
PIVariant PIVariant::readFromString(const PIString & s) {
int i = s.find(':');
if (i < 0 || s.length() < 2) return PIVariant(s);
PIVariant ret;
ret.type = PIVariant::fromString(s.left(i));
ret.setValueOnly(s.right(s.length() - i - 1));
return ret;
}
PIVariant::Type PIVariant::fromString(const PIString & str) {
PIString s = str.trimmed().toLowerCase().replace(" ", "");
if (s == "bool") return PIVariant::Bool;
if (s == "char" || s == "sbyte") return PIVariant::Char;
if (s == "short" || s == "short int" || s == "signed short" || s == "signed short int" || s == "sword") return PIVariant::Short;
if (s == "int" || s == "signed" || s == "signed int") return PIVariant::Int;
if (s == "long" || s == "long int" || s == "signed long" || s == "signed long int" || s == "sdword") return PIVariant::Long;
if (s == "llong" || s == "long long" || s == "long long int" || s == "signed long long" || s == "signed long long int" || s == "sqword") return PIVariant::LLong;
if (s == "uchar" || s == "byte") return PIVariant::UChar;
if (s == "ushort" || s == "unsigned short" || s == "unsigned short int" || s == "word") return PIVariant::UShort;
if (s == "uint" || s == "unsigned" || s == "unsigned int") return PIVariant::UInt;
if (s == "ulong" || s == "unsigned long" || s == "unsigned long int" || s == "dword") return PIVariant::ULong;
if (s == "ullong" || s == "unsigned long long" || s == "unsigned long long int" || s == "qword") return PIVariant::ULLong;
if (s == "float") return PIVariant::Float;
if (s == "double" || s == "real") return PIVariant::Double;
if (s == "ldouble" || s == "long double") return PIVariant::LDouble;
if (s == "pistring" || s == "string") return PIVariant::String;
if (s == "pistringlist" || s == "vector<string>" || s == "vector<pistring>" || s == "pivector<string>" || s == "pivector<pistring>") return PIVariant::StringList;
return PIVariant::Double;
}
PIString PIVariant::toString(const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return "bool";
case PIVariant::Char: return "char";
case PIVariant::Short: return "short";
case PIVariant::Int: return "int";
case PIVariant::Long: return "long";
case PIVariant::LLong: return "llong";
case PIVariant::UChar: return "uchar";
case PIVariant::UShort: return "ushort";
case PIVariant::UInt: return "uint";
case PIVariant::ULong: return "ulong";
case PIVariant::ULLong: return "ullong";
case PIVariant::Float: return "float";
case PIVariant::Double: return "double";
case PIVariant::LDouble: return "ldouble";
case PIVariant::String: return "string";
case PIVariant::StringList: return "stringlist";
}
return "double";
}
uint PIVariant::variableSize(const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return sizeof(bool);
case PIVariant::Char: return sizeof(char);
case PIVariant::Short: return sizeof(short);
case PIVariant::Int: return sizeof(int);
case PIVariant::Long: return sizeof(long);
case PIVariant::LLong: return sizeof(llong);
case PIVariant::UChar: return sizeof(uchar);
case PIVariant::UShort: return sizeof(ushort);
case PIVariant::UInt: return sizeof(uint);
case PIVariant::ULong: return sizeof(ulong);
case PIVariant::ULLong: return sizeof(ullong);
case PIVariant::Float: return sizeof(float);
case PIVariant::Double: return sizeof(double);
case PIVariant::LDouble: return sizeof(ldouble);
default: break;
}
return 0;
}
double PIVariant::variableValue(const void * var_ptr, const PIVariant::Type & var) {
switch (var) {
case PIVariant::Bool: return (double)(*((bool * )var_ptr));
case PIVariant::Char: return (double)(*((char * )var_ptr));
case PIVariant::Short: return (double)(*((short * )var_ptr));
case PIVariant::Int: return (double)(*((int * )var_ptr));
case PIVariant::Long: return (double)(*((long * )var_ptr));
case PIVariant::LLong: return (double)(*((llong * )var_ptr));
case PIVariant::UChar: return (double)(*((uchar * )var_ptr));
case PIVariant::UShort: return (double)(*((ushort * )var_ptr));
case PIVariant::UInt: return (double)(*((uint * )var_ptr));
case PIVariant::ULong: return (double)(*((ulong * )var_ptr));
case PIVariant::ULLong: return (double)(*((ullong * )var_ptr));
case PIVariant::Float: return (double)(*((float * )var_ptr));
case PIVariant::Double: return (double)(*((double * )var_ptr));
case PIVariant::LDouble: return (ldouble)(*((ldouble * )var_ptr));
default: break;
}
return 0.;
}
void PIVariable::setVariable(const PIString & str) {
type_ = PIVariant::fromString(str);
size_ = PIVariant::variableSize(type_);
}
void PIVariable::writeVariable(void * dest) {
switch (type_) {
case PIVariant::Bool: *((bool * )((ullong)dest + offset)) = value_ > 0.; return;
case PIVariant::Char: *((char * )((ullong)dest + offset)) = char(value_); return;
case PIVariant::Short: *((short * )((ullong)dest + offset)) = short(value_); return;
case PIVariant::Int: *((int * )((ullong)dest + offset)) = int(value_); return;
case PIVariant::Long: *((long * )((ullong)dest + offset)) = long(value_); return;
case PIVariant::LLong: *((llong * )((ullong)dest + offset)) = llong(value_); return;
case PIVariant::UChar: *((uchar * )((ullong)dest + offset)) = uchar(value_); return;
case PIVariant::UShort: *((ushort * )((ullong)dest + offset)) = ushort(value_); return;
case PIVariant::UInt: *((uint * )((ullong)dest + offset)) = uint(value_); return;
case PIVariant::ULong: *((ulong * )((ullong)dest + offset)) = ulong(value_); return;
case PIVariant::ULLong: *((ullong * )((ullong)dest + offset)) = ullong(value_); return;
case PIVariant::Float: *((float * )((ullong)dest + offset)) = float(value_); return;
case PIVariant::Double: *((double * )((ullong)dest + offset)) = value_; return;
case PIVariant::LDouble: *((ldouble * )((ullong)dest + offset)) = ldouble(value_); return;
default: break;
}
}
void PIStruct::parseFile(const PIString & file) {
PIConfig conf(file, PIIODevice::ReadOnly);
PIVariable var;
PIString ts;
uint sz = 0;
vars.clear();
for (int i = 0; i < conf.entriesCount(); ++i) {
var.setVariable(conf.getValue(i));
var.setName(conf.getName(i));
var.offset = sz;
sz += var.size();
ts = conf.getComment(i);
if (ts.length() > 0)
var.setValue(ts.toDouble());
else var.setValue(0.);
vars.push_back(var);
}
size_ = sz;
}
void PIStruct::readData(const void * data) {
for (uint i = 0; i < vars.size(); ++i)
vars[i].readVariable(data);
}
void PIStruct::writeData(void * data) {
for (uint i = 0; i < vars.size(); ++i)
vars[i].writeVariable(data);
}

View File

@@ -1,196 +0,0 @@
/*
PIP - Platform Independent Primitives
Variable, Struct (simple serialization)
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
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 PIVARIABLE_H
#define PIVARIABLE_H
#include "piconfig.h"
class PIP_EXPORT PIVariant {
friend class PIVariable;
public:
enum Type {Bool, Char, Short, Int, Long, LLong, UChar, UShort, UInt, ULong, ULLong, Float, Double, LDouble, String, StringList};
PIVariant() {setValue(0.);}
PIVariant(const char * v) {setValue(v);}
PIVariant(const bool & v) {setValue(v);}
PIVariant(const char & v) {setValue(v);}
PIVariant(const short & v) {setValue(v);}
PIVariant(const int & v) {setValue(v);}
PIVariant(const long & v) {setValue(v);}
PIVariant(const llong & v) {setValue(v);}
PIVariant(const uchar & v) {setValue(v);}
PIVariant(const ushort & v) {setValue(v);}
PIVariant(const uint & v) {setValue(v);}
PIVariant(const ulong & v) {setValue(v);}
PIVariant(const ullong & v) {setValue(v);}
PIVariant(const float & v) {setValue(v);}
PIVariant(const double & v) {setValue(v);}
PIVariant(const ldouble & v) {setValue(v);}
PIVariant(const PIString & v) {setValue(v);}
PIVariant(const PIStringList & v) {setValue(v);}
void setValue(const char * v) {setValue(PIString(v));}
void setValue(const bool & v) {type = PIVariant::Bool; vBool = v;}
void setValue(const char & v) {type = PIVariant::Char; vChar = v;}
void setValue(const short & v) {type = PIVariant::Short; vShort = v;}
void setValue(const int & v) {type = PIVariant::Int; vInt = v;}
void setValue(const long & v) {type = PIVariant::Long; vLong = v;}
void setValue(const llong & v) {type = PIVariant::LLong; vLLong = v;}
void setValue(const uchar & v) {type = PIVariant::UChar; vUChar = v;}
void setValue(const ushort & v) {type = PIVariant::UShort; vUShort = v;}
void setValue(const uint & v) {type = PIVariant::UInt; vUInt = v;}
void setValue(const ulong & v) {type = PIVariant::ULong; vULong = v;}
void setValue(const ullong & v) {type = PIVariant::ULLong; vULLong = v;}
void setValue(const float & v) {type = PIVariant::Float; vFloat = v;}
void setValue(const double & v) {type = PIVariant::Double; vDouble = v;}
void setValue(const ldouble & v) {type = PIVariant::LDouble; vLDouble = v;}
void setValue(const PIString & v) {type = PIVariant::String; vString = v;}
void setValue(const PIStringList & v) {type = PIVariant::StringList; vStringList = v;}
void setValueOnly(const PIString & v);
PIString typeName() const {return PIVariant::toString(type);}
double doubleValue() const {return PIVariant::variableValue(&vChar, type);}
PIString stringValue() const;
void typeFromString(const PIString & str) {type = PIVariant::fromString(str);}
PIString typeToString() const {return PIVariant::toString(type);}
uint size() {if (type != PIVariant::String && type != PIVariant::StringList) return PIVariant::variableSize(type); if (type == PIVariant::String) return vString.size(); else return vStringList.contentSize();}
PIString writeToString() const {return typeName() + ":" + stringValue();}
#ifdef QNX
void operator =(const PIVariant & v) {type = v.type; vLDouble = v.vLDouble; vString = v.vString; vStringList = v.vStringList;}
#endif
void operator =(const char * v) {setValue(PIString(v));}
void operator =(const bool & v) {type = PIVariant::Bool; vBool = v;}
void operator =(const char & v) {type = PIVariant::Char; vChar = v;}
void operator =(const short & v) {type = PIVariant::Short; vShort = v;}
void operator =(const int & v) {type = PIVariant::Int; vInt = v;}
void operator =(const long & v) {type = PIVariant::Long; vLong = v;}
void operator =(const llong & v) {type = PIVariant::LLong; vLLong = v;}
void operator =(const uchar & v) {type = PIVariant::UChar; vUChar = v;}
void operator =(const ushort & v) {type = PIVariant::UShort; vUShort = v;}
void operator =(const uint & v) {type = PIVariant::UInt; vUInt = v;}
void operator =(const ulong & v) {type = PIVariant::ULong; vULong = v;}
void operator =(const ullong & v) {type = PIVariant::ULLong; vULLong = v;}
void operator =(const float & v) {type = PIVariant::Float; vFloat = v;}
void operator =(const double & v) {type = PIVariant::Double; vDouble = v;}
void operator =(const ldouble & v) {type = PIVariant::LDouble; vLDouble = v;}
void operator =(const PIString & v) {type = PIVariant::String; vString = v;}
void operator =(const PIStringList & v) {type = PIVariant::StringList; vStringList = v;}
bool operator ==(const PIVariant & v) const;
bool operator !=(const PIVariant & v) const {return !(*this == v);}
PIVariant::Type type;
union {
bool vBool;
char vChar;
short vShort;
int vInt;
long vLong;
llong vLLong;
uchar vUChar;
ushort vUShort;
uint vUInt;
ulong vULong;
ullong vULLong;
float vFloat;
double vDouble;
ldouble vLDouble;
};
PIString vString;
PIStringList vStringList;
static PIVariant readFromString(const PIString & s);
private:
static PIVariant::Type fromString(const PIString & str);
static PIString toString(const PIVariant::Type & var);
static uint variableSize(const PIVariant::Type & var);
static double variableValue(const void * var_ptr, const PIVariant::Type & var);
};
inline std::ostream & operator <<(std::ostream & s, const PIVariant & v) {s << v.typeName() << ": " << v.stringValue(); return s;}
class PIP_EXPORT PIVariable {
public:
PIVariable() {;}
PIVariable(const PIString & str) {setVariable(str);}
~PIVariable() {;}
void setVariable(const PIString & str);
void writeVariable(void * dest);
void readVariable(const void * var_ptr) {value_ = PIVariant::variableValue((char * )((long)var_ptr + offset), type_);}
PIVariant::Type type() const {return type_;}
uint size() const {return size_;}
const PIString & name() {return name_;}
void setName(const PIString & str) {name_ = str;}
double value() const {return value_;}
void setValue(const double & val) {value_ = val;}
int offset;
private:
PIVariant::Type type_;
uint size_;
PIString name_;
double value_;
};
/*
* PIStruct is abstract structure, described by *.conf file with format of each line:
* "<name> = <type> #<n|f|b> <start_value>".
* e.g. "pi = double #f 3.1418"
*
* You can write or read binary content of this struct
* by functions "writeData" and "readData", e.g.
* "char * data = new char[struct.size()];
* struct.writeData(data);"
*
* Access to each variable in struct is looks like
* "double value = struct["pi"].value();"
*/
class PIP_EXPORT PIStruct {
public:
PIStruct() {;}
PIStruct(const PIString & str) {parseFile(str);}
void parseFile(const PIString & file);
void readData(const void * data);
void writeData(void * data);
void clear() {vars.clear(); size_ = 0;}
uint count() const {return vars.size();}
uint size() const {return size_;}
const PIString & name() {return name_;}
void setName(const PIString & str) {name_ = str;}
PIVariable & operator[](const uint & index) {return vars[index];}
PIVariable & operator[](const PIString & name) {for (uint i = 0; i < vars.size(); ++i) if (vars[i].name() == name) return vars[i]; return def;}
private:
uint size_;
PIString name_;
PIVariable def;
PIVector<PIVariable> vars;
};
#endif // PIVARIABLE_H

View File

@@ -1,196 +0,0 @@
/*
PIP - Platform Independent Primitives
Variable, Struct (simple serialization)
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
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 PIVARIABLE_H
#define PIVARIABLE_H
#include "piconfig.h"
class PIP_EXPORT PIVariant {
friend class PIVariable;
public:
enum Type {Bool, Char, Short, Int, Long, LLong, UChar, UShort, UInt, ULong, ULLong, Float, Double, LDouble, String, StringList};
PIVariant() {setValue(0.);}
PIVariant(const char * v) {setValue(v);}
PIVariant(const bool & v) {setValue(v);}
PIVariant(const char & v) {setValue(v);}
PIVariant(const short & v) {setValue(v);}
PIVariant(const int & v) {setValue(v);}
PIVariant(const long & v) {setValue(v);}
PIVariant(const llong & v) {setValue(v);}
PIVariant(const uchar & v) {setValue(v);}
PIVariant(const ushort & v) {setValue(v);}
PIVariant(const uint & v) {setValue(v);}
PIVariant(const ulong & v) {setValue(v);}
PIVariant(const ullong & v) {setValue(v);}
PIVariant(const float & v) {setValue(v);}
PIVariant(const double & v) {setValue(v);}
PIVariant(const ldouble & v) {setValue(v);}
PIVariant(const PIString & v) {setValue(v);}
PIVariant(const PIStringList & v) {setValue(v);}
void setValue(const char * v) {setValue(PIString(v));}
void setValue(const bool & v) {type = PIVariant::Bool; vBool = v;}
void setValue(const char & v) {type = PIVariant::Char; vChar = v;}
void setValue(const short & v) {type = PIVariant::Short; vShort = v;}
void setValue(const int & v) {type = PIVariant::Int; vInt = v;}
void setValue(const long & v) {type = PIVariant::Long; vLong = v;}
void setValue(const llong & v) {type = PIVariant::LLong; vLLong = v;}
void setValue(const uchar & v) {type = PIVariant::UChar; vUChar = v;}
void setValue(const ushort & v) {type = PIVariant::UShort; vUShort = v;}
void setValue(const uint & v) {type = PIVariant::UInt; vUInt = v;}
void setValue(const ulong & v) {type = PIVariant::ULong; vULong = v;}
void setValue(const ullong & v) {type = PIVariant::ULLong; vULLong = v;}
void setValue(const float & v) {type = PIVariant::Float; vFloat = v;}
void setValue(const double & v) {type = PIVariant::Double; vDouble = v;}
void setValue(const ldouble & v) {type = PIVariant::LDouble; vLDouble = v;}
void setValue(const PIString & v) {type = PIVariant::String; vString = v;}
void setValue(const PIStringList & v) {type = PIVariant::StringList; vStringList = v;}
void setValueOnly(const PIString & v);
PIString typeName() const {return PIVariant::toString(type);}
double doubleValue() const {return PIVariant::variableValue(&vChar, type);}
PIString stringValue() const;
void typeFromString(const PIString & str) {type = PIVariant::fromString(str);}
PIString typeToString() const {return PIVariant::toString(type);}
uint size() {if (type != PIVariant::String && type != PIVariant::StringList) return PIVariant::variableSize(type); if (type == PIVariant::String) return vString.size(); else return vStringList.contentSize();}
PIString writeToString() const {return typeName() + ":" + stringValue();}
#ifdef QNX
void operator =(const PIVariant & v) {type = v.type; vLDouble = v.vLDouble; vString = v.vString; vStringList = v.vStringList;}
#endif
void operator =(const char * v) {setValue(PIString(v));}
void operator =(const bool & v) {type = PIVariant::Bool; vBool = v;}
void operator =(const char & v) {type = PIVariant::Char; vChar = v;}
void operator =(const short & v) {type = PIVariant::Short; vShort = v;}
void operator =(const int & v) {type = PIVariant::Int; vInt = v;}
void operator =(const long & v) {type = PIVariant::Long; vLong = v;}
void operator =(const llong & v) {type = PIVariant::LLong; vLLong = v;}
void operator =(const uchar & v) {type = PIVariant::UChar; vUChar = v;}
void operator =(const ushort & v) {type = PIVariant::UShort; vUShort = v;}
void operator =(const uint & v) {type = PIVariant::UInt; vUInt = v;}
void operator =(const ulong & v) {type = PIVariant::ULong; vULong = v;}
void operator =(const ullong & v) {type = PIVariant::ULLong; vULLong = v;}
void operator =(const float & v) {type = PIVariant::Float; vFloat = v;}
void operator =(const double & v) {type = PIVariant::Double; vDouble = v;}
void operator =(const ldouble & v) {type = PIVariant::LDouble; vLDouble = v;}
void operator =(const PIString & v) {type = PIVariant::String; vString = v;}
void operator =(const PIStringList & v) {type = PIVariant::StringList; vStringList = v;}
bool operator ==(const PIVariant & v) const;
bool operator !=(const PIVariant & v) const {return !(*this == v);}
PIVariant::Type type;
union {
bool vBool;
char vChar;
short vShort;
int vInt;
long vLong;
llong vLLong;
uchar vUChar;
ushort vUShort;
uint vUInt;
ulong vULong;
ullong vULLong;
float vFloat;
double vDouble;
ldouble vLDouble;
};
PIString vString;
PIStringList vStringList;
static PIVariant readFromString(const PIString & s);
private:
static PIVariant::Type fromString(const PIString & str);
static PIString toString(const PIVariant::Type & var);
static uint variableSize(const PIVariant::Type & var);
static double variableValue(const void * var_ptr, const PIVariant::Type & var);
};
inline std::ostream & operator <<(std::ostream & s, const PIVariant & v) {s << v.typeName() << ": " << v.stringValue(); return s;}
class PIP_EXPORT PIVariable {
public:
PIVariable() {;}
PIVariable(const PIString & str) {setVariable(str);}
~PIVariable() {;}
void setVariable(const PIString & str);
void writeVariable(void * dest);
void readVariable(const void * var_ptr) {value_ = PIVariant::variableValue((char * )((long)var_ptr + offset), type_);}
PIVariant::Type type() const {return type_;}
uint size() const {return size_;}
const PIString & name() {return name_;}
void setName(const PIString & str) {name_ = str;}
double value() const {return value_;}
void setValue(const double & val) {value_ = val;}
int offset;
private:
PIVariant::Type type_;
uint size_;
PIString name_;
double value_;
};
/*
* PIStruct is abstract structure, described by *.conf file with format of each line:
* "<name> = <type> #<n|f|b> <start_value>".
* e.g. "pi = double #f 3.1418"
*
* You can write or read binary content of this struct
* by functions "writeData" and "readData", e.g.
* "char * data = new char[struct.size()];
* struct.writeData(data);"
*
* Access to each variable in struct is looks like
* "double value = struct["pi"].value();"
*/
class PIP_EXPORT PIStruct {
public:
PIStruct() {;}
PIStruct(const PIString & str) {parseFile(str);}
void parseFile(const PIString & file);
void readData(const void * data);
void writeData(void * data);
void clear() {vars.clear(); size_ = 0;}
uint count() const {return vars.size();}
uint size() const {return size_;}
const PIString & name() {return name_;}
void setName(const PIString & str) {name_ = str;}
PIVariable & operator[](const uint & index) {return vars[index];}
PIVariable & operator[](const PIString & name) {for (uint i = 0; i < vars.size(); ++i) if (vars[i].name() == name) return vars[i]; return def;}
private:
uint size_;
PIString name_;
PIVariable def;
PIVector<PIVariable> vars;
};
#endif // PIVARIABLE_H

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Terminal client for windows, used by PITerminal and pisd
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/>.
*/
#include "piincludes_p.h"
#ifndef WINDOWS
int main (int argc, char * argv[]) {

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
PICloud Client
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -23,13 +23,13 @@
#ifndef PICCLOUDCLIENT_H
#define PICCLOUDCLIENT_H
#include "pistring.h"
#include "piiodevice.h"
class PIP_EXPORT PICloudClient {
public:
//!
PICloudClient();
explicit PICloudClient();
private:

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
PICloud Server
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -23,12 +23,13 @@
#ifndef PICCLOUDSERVER_H
#define PICCLOUDSERVER_H
#include "pistring.h"
#include "piiodevice.h"
class PIP_EXPORT PICloudServer {
public:
//!
PICloudServer();
explicit PICloudServer();
private:

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
PICloud TCP transport
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -24,7 +24,7 @@
#ifndef PICODEINFO_H
#define PICODEINFO_H
#include "pistring.h"
#include "pistringlist.h"
class PIVariant;

View File

@@ -207,13 +207,6 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
if (c == '"' && !mlc && pc != '\'') {
if (i > 0) if (fc[i - 1] == '\\') continue;
cc = !cc;
/*if (cc) ccs = i;
if (!cc) {
ccmn = "$" + PIString::fromNumber(cchars.size());
cchars[ccmn] = fc.mid(ccs, i - ccs + 1);
fc.replace(ccs, i - ccs + 1, ccmn);
i = ccs - 1 + ccmn.size_s();
}*/
continue;
}
if (i > 0)
@@ -227,7 +220,6 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
if (fc.mid(i, 2) == "*/" && mlc) {mlc = false; fc.cutMid(mls, i - mls + 2); i = mls - 1; continue;}
if (fc.mid(i, 2) == "//" && !mlc) {ole = fc.find('\n', i); fc.cutMid(i, ole < 0 ? -1 : ole - i); --i; continue;}
}
//PICout(PICoutManipulators::DefaultControls) << fc;
pfc = procMacros(fc);
replaceMeta(pfc);
@@ -374,7 +366,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
Entity * e = new Entity();
e->meta = meta;
e->name = cur_namespace + cn;
e->type = typename_;//(is_class ? "class" : "struct");
e->type = typename_;
e->has_name = has_name;
e->parents = parents;
e->file = cur_file;
@@ -444,7 +436,7 @@ PIString PICodeParser::parseClass(Entity * parent, PIString & fc) {
parseMember(ce, tmp);
if (def) fc.takeRange("{", "}");
else fc.takeSymbol();
if (ps == fc.size_s()) {/*cur_namespace = prev_namespace;*/ fc.cutLeft(1);/*return false*/;}
if (ps == fc.size_s()) {fc.cutLeft(1);}
ps = fc.size_s();
}
cur_def_vis = prev_vis;
@@ -948,8 +940,8 @@ PIString PICodeParser::procMacros(PIString fc) {
ifcnt = 0;
nfc.clear();
} else {
/*if (!*/parseDirective(line.cutLeft(1).trim())/*)*/
;//return false; /// WARNING: now skip errors
parseDirective(line.cutLeft(1).trim());
//return false; /// WARNING: now skip errors
}
} else {
if (grab) nfc << line << "\n";
@@ -982,7 +974,6 @@ bool PICodeParser::parseDirective(PIString d) {
macros << Macro(mname, d.trim(), args);
} else { // define
d.trim();
//if (mname == d) d.clear();
defines << Define(mname, d);
evaluator.setVariable(mname, complexd_1);
}

View File

@@ -170,7 +170,6 @@ private:
int macros_iter, anon_num;
bool with_includes;
PIEvaluator evaluator;
//PIVector<Entity * > tree;
PISet<PIString> proc_files;
PIString cur_file, main_file;
PIStringList includes;

View File

@@ -731,14 +731,11 @@ void PIConsole::fillLabels() {
newLine();
}
status();
//couts(fstr(Normal));
//fflush(0);
}
void PIConsole::status() {
Tab * ctab;
//clearLine();
for (uint i = 0; i < tabsCount(); ++i) {
ctab = &tabs[i];
if (ctab->key == 0) continue;

View File

@@ -436,19 +436,6 @@ public:
bool server_mode, pause_;
ConnectedState state;
/*struct RemoteData {
RemoteData() {msg_count = msg_rec = msg_send = 0;}
void clear() {msg_count = msg_rec = msg_send = 0; data.clear();}
bool isEmpty() const {return msg_count == 0;}
bool isReadyRec() const {return msg_count == msg_rec;}
bool isReadySend() const {return msg_count == msg_send;}
void setData(const PIByteArray & ba) {data = ba; msg_rec = msg_send = 0; msg_count = (data.size_s() - 1) / 4096 + 1;}
PIByteArray data;
int msg_count;
int msg_rec;
int msg_send;
};*/
struct RemoteClient {
RemoteClient(const PIString & n = "") {name = n; state = Disconnected;}
PIString name;

View File

@@ -267,10 +267,8 @@ void PIKbdListener::readKeyboard() {
case MOUSE_EVENT: {
MOUSE_EVENT_RECORD mer = ir.Event.MouseEvent;
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
//height = PRIVATE->sbi.srWindow.Bottom - ;
me.modifiers = getModifiers(mer.dwControlKeyState);
MouseButtons mb = getButtons(mer.dwButtonState);
//me.action = getButtons(mer.dwButtonState);
if (mer.dwEventFlags & MOUSE_WHEELED) {
memcpy((void*)(&we), (const void*)(&me), sizeof(me));
we.action = MouseWheel;
@@ -317,16 +315,6 @@ void PIKbdListener::readKeyboard() {
piMSleep(10);
return;
}
/*if (lc == 0) {
ReadConsole(hIn, &rc, 1, &(PRIVATE->ret), 0);
//cout << "read console" << endl;
lc = char(rc);
}*/
/*if (PRIVATE->ret < 0 || PRIVATE->ret > 3) return;
lc = char(((uchar * )&rc)[PRIVATE->ret - 1]);
for (int i = 0; i < PRIVATE->ret; ++i)
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
cout << endl << std::hex << rc << endl;*/
#else
tcsetattr(0, TCSANOW, &PRIVATE->tterm);
PRIVATE->ret = read(0, rc, 8);

View File

@@ -162,7 +162,6 @@ void PIScreen::SystemConsole::print() {
///cells[mouse_y][mouse_x].format.flags ^= Inverse;
}
#ifdef WINDOWS
//static int cnt = 0;
PRIVATE->srect = PRIVATE->sbi.srWindow;
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
for (int j = 0; j < height; ++j) {
@@ -189,11 +188,8 @@ void PIScreen::SystemConsole::print() {
Cell & c(cells[j + dy0][i + dx0]);
PRIVATE->chars[k].Char.UnicodeChar = 0;
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte();
//PRIVATE->chars[k].Char.UnicodeChar = c.symbol.toInt();
PRIVATE->chars[k].Attributes = attributes(c);
}
//PRIVATE->bc.X = dx0;
//PRIVATE->bc.Y = dy0;
//piCout << "draw" << dw << dh;
PRIVATE->bs.X = dw;
PRIVATE->bs.Y = dh;
@@ -235,10 +231,6 @@ void PIScreen::SystemConsole::print() {
printf("%s", s.data());
s.clear();
}
/*for (int i = 0; i < width; ++i) {
moveTo(i, j);
printf("%s", (formatString(cells[j][i]) + cells[j][i].symbol).data());
}*/
}
printf("\e[0m");
fflush(0);
@@ -420,9 +412,7 @@ PIScreen::~PIScreen() {
void PIScreen::setMouseEnabled(bool on) {
mouse_ = on;
//lock();
console.mouse_x = console.mouse_y = -1;
//unlock();
}

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Tile for PIScreen with PIConsole API
Andrey Bychkov work.a.b@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/>.
*/
#include "piscreenconsole.h"
using namespace PIScreenTypes;

View File

@@ -111,10 +111,7 @@ void PIScreenTile::setScreen(PIScreenBase * s) {
void PIScreenTile::deleteChildren() {
//piCout << this << "deleteChildren";
piForeach (PIScreenTile * t, tiles) {
//piCout << this << " child" << t;
//t->deleteChildren();
t->parent = 0;
delete t;
}
@@ -130,7 +127,6 @@ void PIScreenTile::setFocus() {
void PIScreenTile::drawEventInternal(PIScreenDrawer * d) {
if (!visible) {
//d->clearRect(x, y, x + width, y + height);
return;
}
d->fillRect(x_, y_, x_ + width_, y_ + height_, back_symbol, (Color)back_format.color_char, (Color)back_format.color_back, back_format.flags);
@@ -232,7 +228,7 @@ void PIScreenTile::layout() {
}
int cx = x_ + marginLeft, cy = y_ + marginTop;
for (int i = 0; i < tiles.size_s(); ++i) {
PIScreenTile * t(tiles[i]);
PIScreenTile * t = tiles[i];
if (!t->visible || !t->needLayout()) continue;
t->x_ = cx;
t->y_ = cy;

View File

@@ -154,7 +154,6 @@ void TileList::resizeEvent(int w, int h) {
void TileList::drawEvent(PIScreenDrawer * d) {
lhei = height_ - 2;
//int osp = piMini(3, lhei / 4);
int is = piClampi(offset, 0, piMaxi(0, content.size_s() - 1)), ie = piClampi(offset + lhei, 0, content.size_s());
if (is > 0) d->drawText(x_, y_, PIString(" /\\ ").repeat(width_ / 4), Green, Default, Bold);
if (ie < content.size_s()) d->drawText(x_, y_ + height_ - 1, PIString(" \\/ ").repeat(width_ / 4), Green, Default, Bold);
@@ -182,11 +181,6 @@ void TileList::drawEvent(PIScreenDrawer * d) {
}
scroll->setMaximum(piMaxi(0, content.size_s() - 1));
scroll->setValue(cur);
/*int cx = x_ + width_ - 1;
d->drawLine(cx, y_ + 1, cx, y_ + height_ - 2, vert_line, Green);
if (content.size_s() > 1)
d->drawPixel(cx, y_ + piRound(float(cur) / (content.size_s() - 1) * (lhei - 1)) + 1, ' ', Green, Green);
if (ie < content.size_s()) d->drawText(x_, y_ + height_ - 1, PIString(" \\/ ").repeat(width_ / 4), Green, Default, Bold);*/
}
@@ -289,7 +283,6 @@ bool TileList::mouseEvent(PIKbdListener::MouseEvent me) {
break;
case PIKbdListener::MouseButtonDblClick:
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
//raiseEvent(TileEvent(RowPressed, cur));
return true;
default: break;
}

View File

@@ -196,9 +196,6 @@ class PIP_EXPORT TileInput: public PIScreenTile {
public:
TileInput(const PIString & n = PIString());
virtual ~TileInput() {}
/*enum EventType {
EditFinished
};*/
PIScreenTypes::CellFormat format;
PIString text;
int max_length;
@@ -212,34 +209,5 @@ protected:
PITimeMeasurer tm_blink;
};
/*
class PIP_EXPORT TileTabs: public PIScreenTile {
PIOBJECT_SUBCLASS(TileTabs, PIScreenTile)
public:
TileTabs(const PIString & n = PIString());
enum EventType {
TabChanged
};
struct Tab {
Tab(const PIString & l = PIString(), int k = 0, PIScreenTile * t = 0) {
label = l;
key = k;
tile = t;
}
PIString label;
int key;
PIScreenTile * tile;
};
PIScreenTypes::CellFormat format_tab;
PIScreenTypes::CellFormat format_tab_selected;
PIDeque<Tab> tabs;
protected:
void sizeHint(int & w, int & h) const;
void drawEvent(PIScreenDrawer * d);
bool keyEvent(PIKbdListener::KeyEvent key);
void selectTab(int index);
int cur;
};
*/
#endif // PISCREENTILES_H

View File

@@ -72,14 +72,6 @@ namespace PIScreenTypes {
Vertical /** Vertical */
};
//! Position
enum PIP_EXPORT Position {
//Left /** Left */ ,
//Right /** Right */ ,
//Top /** Top */ ,
//Bottom /** Bottom */
};
//! Focus flags
enum PIP_EXPORT FocusFlag {
CanHasFocus /** Tile can has focus */ = 0x1,
@@ -150,8 +142,5 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v)
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.format.raw_format >> v.symbol; return s;}
//__PICONTAINERS_SIMPLE_TYPE__(PIScreenTypes::Cell)
//__PIBYTEARRAY_SIMPLE_TYPE__(PIScreenTypes::Cell)
#endif // PISCREENTYPES_H

View File

@@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// * This class based on std::vector, expanding his functionality
/** \class PIVector
* \brief Dynamic array of any type

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -6,7 +6,7 @@
/*
PIP - Platform Independent Primitives
Dynamic array of any type
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -97,7 +97,6 @@ public:
size_t pos;
public:
inline const_iterator(): parent(0), pos(0) {}
//inline T & operator *() {return (*parent)[pos];}
inline const T & operator *() const {return (*parent)[pos];}
inline void operator ++() {++pos;}
inline void operator ++(int) {++pos;}
@@ -133,7 +132,6 @@ public:
size_t pos;
public:
inline const_reverse_iterator(): parent(0), pos(0) {}
//inline T & operator *() {return (*parent)[pos];}
inline const T & operator *() const {return (*parent)[pos];}
inline void operator ++() {--pos;}
inline void operator ++(int) {--pos;}

View File

@@ -201,11 +201,6 @@ public:
if (other.isEmpty()) return *this;
if (other.size() == 1) {insert(other.pim_index[0].key, other.pim_content[0]); return *this;}
if (other.size() == 2) {insert(other.pim_index[0].key, other.pim_content[0]); insert(other.pim_index[1].key, other.pim_content[1]); return *this;}
/*pim_content << other.pim_content;
size_t si = pim_index.size();
for (int i = 0; i < other.pim_index.size_s(); ++i)
pim_index << MapIndex(other.pim_index[i].key, other.pim_index[i].index + si);
_sort();*/
for (int i = 0; i < other.pim_index.size_s(); ++i)
insert(other.pim_index[i].key, other.pim_content[other.pim_index[i].index]);
return *this;
@@ -214,11 +209,9 @@ public:
bool operator ==(const PIMap<Key, T> & t) const {return (pim_content == t.pim_content && pim_index == t.pim_index);}
bool operator !=(const PIMap<Key, T> & t) const {return (pim_content != t.pim_content || pim_index != t.pim_index);}
bool contains(const Key & key) const {bool f(false); _find(key, f); return f;}
//int etries(const T & v) const {int ec = 0; for (size_t i = 0; i < pim_size; ++i) if (v == pim_data[i]) ++ec; return ec;}
PIMap<Key, T> & reserve(size_t new_size) {pim_content.reserve(new_size); pim_index.reserve(new_size); return *this;}
//PIMap<Key, T> & removeAll(const T & v) {for (llong i = 0; i < pim_size; ++i) if (pim_data[i] == v) {remove(i); --i;} return *this;}
PIMap<Key, T> & removeOne(const Key & key) {bool f(false); ssize_t i = _find(key, f); if (f) _remove(i); return *this;}
PIMap<Key, T> & remove(const Key & key) {return removeOne(key);}
PIMap<Key, T> & erase(const Key & key) {return removeOne(key);}
@@ -230,7 +223,6 @@ public:
}
PIMap<Key, T> & insert(const Key & key, const T & value) {
//MapIndex * i = _find(key);
bool f(false);
ssize_t i = _find(key, f);
//piCout << "insert key=" << key << "found=" << f << "index=" << i << "value=" << value;
@@ -239,11 +231,9 @@ public:
} else {
pim_content.push_back(value);
pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
//_sort();
}
return *this;
}
//const T value(const Key & key, const T & default_ = T()) const {MapIndex * i = _find(key); if (i == 0) return default_; return pim_content[i->index];}
const T value(const Key & key, const T & default_ = T()) const {bool f(false); ssize_t i = _find(key, f); if (!f) return default_; return pim_content[pim_index[i].index];}
PIVector<T> values() const {return pim_content;}
Key key(const T & value_, const Key & default_ = Key()) const {for (int i = 0; i < pim_index.size_s(); ++i) if (pim_content[pim_index[i].index] == value_) return pim_index[i].key; return default_;}
@@ -289,12 +279,6 @@ protected:
}
void _sort() {piQuickSort<MapIndex>(pim_index.data(), pim_index.size_s() - 1);}
ssize_t _find(const Key & k, bool & found) const {
/*for (size_t i = 0; i < pim_index.size(); ++i)
if (pim_index[i].key == k) {
return (MapIndex * )&(pim_index[i]);
}
return 0;*/
//piCout << "find for" << k << pim_index.size_s();
if (pim_index.isEmpty()) {
found = false;
return 0;
@@ -325,62 +309,8 @@ protected:
PIVector<T> pim_content;
PIDeque<MapIndex> pim_index;
};
//template <typename Key, typename T> bool operator <(const typename PIMap<Key, T>::MapIndex & f, const typename PIMap<Key, T>::MapIndex & s) {return f.key < s.key;}
//template <typename Key, typename T> bool operator >(const typename PIMap<Key, T>::MapIndex & f, const typename PIMap<Key, T>::MapIndex & s) {return f.key > s.key;}
/*#define __PIMAP_SIMPLE_FUNCTIONS__(T)
template<> inline PIMap<Key, T>::~PIMap() {dealloc(); _reset();} \
template<> inline PIMap<Key, T> & PIMap<Key, T>::push_back(const T & v) {alloc(pim_size + 1); pim_data[pim_size - 1] = v; return *this;} \
template<> inline PIMap<Key, T> & PIMap<Key, T>::fill(const T & f) { \
for (size_t i = 0; i < pim_size; ++i) \
pim_data[i] = f; \
return *this; \
} \
template<> inline PIMap<Key, T> & PIMap<Key, T>::resize(size_t new_size, const T & f) { \
if (new_size < pim_size) \
pim_size = new_size; \
if (new_size > pim_size) { \
size_t os = pim_size; \
alloc(new_size); \
for (size_t i = os; i < new_size; ++i) pim_data[i] = f; \
} \
return *this; \
} \
template<> inline PIMap<Key, T> & PIMap<Key, T>::insert(size_t index, const T & v) { \
alloc(pim_size + 1); \
if (index < pim_size - 1) { \
size_t os = pim_size - index - 1; \
memmove(&(pim_data[index + 1]), &(pim_data[index]), os * sizeof(T)); \
} \
pim_data[index] = v; \
return *this; \
} \
template<> inline PIMap<Key, T> & PIMap<Key, T>::remove(size_t index, size_t count) { \
if (index + count >= pim_size) { \
resize(index); \
return *this; \
} \
size_t os = pim_size - index - count; \
memmove(&(pim_data[index]), &(pim_data[index + count]), os * sizeof(T)); \
pim_size -= count; \
return *this; \
}
__PIMAP_SIMPLE_FUNCTIONS__(char)
__PIMAP_SIMPLE_FUNCTIONS__(uchar)
__PIMAP_SIMPLE_FUNCTIONS__(short)
__PIMAP_SIMPLE_FUNCTIONS__(ushort)
__PIMAP_SIMPLE_FUNCTIONS__(int)
__PIMAP_SIMPLE_FUNCTIONS__(uint)
__PIMAP_SIMPLE_FUNCTIONS__(long)
__PIMAP_SIMPLE_FUNCTIONS__(ulong)
__PIMAP_SIMPLE_FUNCTIONS__(llong)
__PIMAP_SIMPLE_FUNCTIONS__(ullong)
__PIMAP_SIMPLE_FUNCTIONS__(float)
__PIMAP_SIMPLE_FUNCTIONS__(double)
__PIMAP_SIMPLE_FUNCTIONS__(ldouble)*/
#else

View File

@@ -59,27 +59,17 @@ public:
//! Contructs set from vector of elements
PISet(const PIVector<T> & values) {
if (values.isEmpty()) return;
//_CSet::pim_content.resize(values.size_s());
//_CSet::pim_index.resize(values.size_s());
for (int i = 0; i < values.size_s(); ++i) {
//_CSet::pim_index[i].index = i;
//_CSet::pim_index[i].key = values[i];
_CSet::insert(values[i], 0);
}
//_CSet::_sort();
}
//! Contructs set from deque of elements
PISet(const PIDeque<T> & values) {
if (values.isEmpty()) return;
//_CSet::pim_content.resize(values.size_s());
//_CSet::pim_index.resize(values.size_s());
for (int i = 0; i < values.size_s(); ++i) {
//_CSet::pim_index[i].index = i;
//_CSet::pim_index[i].key = values[i];
_CSet::insert(values[i], 0);
}
//_CSet::_sort();
}
typedef T key_type;

View File

@@ -6,7 +6,7 @@
/*
PIP - Platform Independent Primitives
Dynamic array of any type
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Bit array
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/>.
*/
#include "pibitarray.h"
#include "picout.h"

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Byte array
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -18,7 +18,7 @@
*/
#include "pibytearray.h"
#include "pistring.h"
#include "pistringlist.h"
#include <iostream>
/*! \class PIByteArray

View File

@@ -301,7 +301,6 @@ inline bool operator !=(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.s
__PIBYTEARRAY_SIMPLE_TYPE__(bool)
__PIBYTEARRAY_SIMPLE_TYPE__(char)
//__PIBYTEARRAY_SIMPLE_TYPE__(uchar)
__PIBYTEARRAY_SIMPLE_TYPE__(short)
__PIBYTEARRAY_SIMPLE_TYPE__(ushort)
__PIBYTEARRAY_SIMPLE_TYPE__(int)

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Unicode char
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -75,7 +75,6 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t
if (ret <= 0) return 0;
if (taken) *taken = ret;
return buffer;
//printf("request %d\n", sz);
# else
wchar_t wc(0);
mbtowc(0, 0, 0); // reset mbtowc
@@ -378,10 +377,7 @@ PICout operator <<(PICout s, const PIChar & v) {
} else
#endif
#ifdef WINDOWS
//if (PICout::isBufferActive())
s << v.toSystem();
//else
// s << v.toConsole1Byte();
#else
{
char tc[8];

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Unicode char
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -57,37 +57,14 @@ public:
//! Contructs symbol from no more than 4 bytes of string
PIChar(const char * c, int * bytes = 0);
//inline operator const int() {return static_cast<const int>(ch);}
//inline operator const char() {return toAscii();}
//! Copy operator
PIChar & operator =(const char v) {ch = v; return *this;}
/*inline PIChar & operator =(const short v) {ch = v; return *this;}
inline PIChar & operator =(const int v) {ch = v; return *this;}
inline PIChar & operator =(const uchar v) {ch = v; return *this;}
inline PIChar & operator =(const ushort v) {ch = v; return *this;}
inline PIChar & operator =(const uint v) {ch = v; return *this;}*/
//! Compare operator
bool operator ==(const PIChar & o) const;
/*inline bool operator ==(const PIChar & o) const {if (o.isAscii() ^ isAscii()) return false;
if (isAscii()) return (o.toAscii() == toAscii());
return (o.toInt() == toInt());}
inline bool operator ==(const char o) const {return (PIChar(o) == *this);}
inline bool operator ==(const short o) const {return (PIChar(o) == *this);}
inline bool operator ==(const int o) const {return (PIChar(o) == *this);}
inline bool operator ==(const uchar o) const {return (PIChar(o) == *this);}
inline bool operator ==(const ushort o) const {return (PIChar(o) == *this);}
inline bool operator ==(const uint o) const {return (PIChar(o) == *this);}*/
//! Compare operator
bool operator !=(const PIChar & o) const {return !(o == *this);}
/*inline bool operator !=(const char o) const {return (PIChar(o) != *this);}
inline bool operator !=(const short o) const {return (PIChar(o) != *this);}
inline bool operator !=(const int o) const {return (PIChar(o) != *this);}
inline bool operator !=(const uchar o) const {return (PIChar(o) != *this);}
inline bool operator !=(const ushort o) const {return (PIChar(o) != *this);}
inline bool operator !=(const uint o) const {return (PIChar(o) != *this);}*/
//! Compare operator
bool operator >(const PIChar & o) const;

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Binary markup serializator
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/>.
*/
#include "pichunkstream.h"
/*! \class PIChunkStream
@@ -99,7 +118,6 @@ uint PIChunkStream::readVInt(PIByteArray & s) {
for (abc = 0; abc < 3; ++abc) {
uchar mask = (0x80 >> abc);
if ((bytes[0] & mask) == mask) {
//if (s.isEmpty()) return 0;
bytes[0] &= (mask - 1);
s >> bytes[abc + 1];
} else break;

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Peer - named I/O ethernet node, forming self-organized peering network
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/>.
*/
#include "picollection.h"

View File

@@ -72,7 +72,6 @@ public:
protected:
struct Group {
Group(const PIString & name_ = PIString()) {name = name_;}
//~Group() {piCout << "delete group" << name << this; piForeach (const PIObject * o, elements) delete o; elements.clear();}
PIString name;
PIVector<const PIObject * > elements;
};

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -22,7 +22,6 @@
#include "picollection.h"
#include "piobject.h"
#include "pistatemachine.h"
#include "pitime.h"
#include "picli.h"
#include "pichunkstream.h"

View File

@@ -226,13 +226,6 @@ PICout PICout::operator <<(const PICoutAction v) {
if (isOutputDeviceActive(StdOut)) {
#ifdef WINDOWS
/// TODO : wondows ClearScreen !!!
/*GetConsoleCursorInfo(__Private__::hOut, &curinfo);
curinfo.bVisible = false;
SetConsoleCursorInfo(__Private__::hOut, &curinfo);
SetConsoleCursorPosition(__Private__::hOut, ulcoord);
FillConsoleOutputAttribute(__Private__::hOut, __Private__::dattr, width * (height + 1), ulcoord, &written);
FillConsoleOutputCharacter(__Private__::hOut, ' ', width * (height + 1), ulcoord, &written);*/
#else
printf("\e[H\e[J");
#endif
@@ -262,14 +255,11 @@ PICout PICout::operator <<(const PICoutAction v) {
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v);\
}\
}
//#define PICOUTTOTARGETS(v) {if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v); else printf("%s", (v).dataConsole());}
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_))
PICout PICout::operator <<(const char * v) {if (!act_) return *this; if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
//PICout PICout::operator <<(const std::string & v) {space(); quote(); if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << StdString2PIString(v); else std::cout << (v); quote(); return *this;}
PICout PICout::operator <<(const bool v) {if (!act_) return *this; space(); if (v) PICOUTTOTARGET("true") else PICOUTTOTARGET("false") return *this;}
PICout PICout::operator <<(const char v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Private PIP includes
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -33,10 +33,10 @@
#endif
#ifdef WINDOWS
# include <winsock2.h>
extern FILETIME __pi_ftjan1970;
extern PINtQueryTimerResolution getTimerResolutionAddr;
extern PINtSetTimerResolution setTimerResolutionAddr;
void __PISetTimerResolution() {
extern FILETIME __pi_ftjan1970;
extern PINtQueryTimerResolution getTimerResolutionAddr;
extern PINtSetTimerResolution setTimerResolutionAddr;
void __PISetTimerResolution() {
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
return;
ULONG _max(0), _min(0), _cur(0);
@@ -46,7 +46,7 @@
if (q == 0)
setTimerResolutionAddr(_min, TRUE, &_cur);
//printf("setTimerResolution %lu\n", cur);
}
}
#else
# include <pwd.h>
# ifndef FREERTOS
@@ -64,24 +64,13 @@
# include <mach/mach.h>
# include <mach/clock.h>
//# include <crt_externs.h>
extern clock_serv_t __pi_mac_clock;
extern clock_serv_t __pi_mac_clock;
#endif
#ifdef PIP_ICU
# define U_NOEXCEPT
# include <unicode/uclean.h>
# include <unicode/ucnv.h>
#endif
/*
#ifdef WINDOWS
# include <conio.h>
# include <io.h>
# include <windows.h>
# include <wincon.h>
#else
# include <fcntl.h>
# include <sys/ioctl.h>
# include <pthread.h>
#endif*/
#ifdef HAS_LOCALE
@@ -90,10 +79,10 @@ static locale_t currentLocale_t = 0;
PRIVATE_DEFINITION_START(PIInit)
#ifdef WINDOWS
HMODULE ntlib;
ULONG prev_res;
HMODULE ntlib;
ULONG prev_res;
#endif
bool delete_locs;
bool delete_locs;
PRIVATE_DEFINITION_END(PIInit)
#ifndef FREERTOS
@@ -165,9 +154,7 @@ PIInit::PIInit() {
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
__PISetTimerResolution();
}
/*if (setTimerResolution) setTimerResolutionAddr(1, TRUE, &(PRIVATE->prev_res));*/
# endif
//piDebug = true;
# ifdef HAS_LOCALE
//cout << "has locale" << endl;
if (currentLocale_t != 0) {
@@ -284,22 +271,22 @@ PIInit::PIInit() {
sinfo->OS_version = esp_get_idf_version();
#endif
sinfo->OS_name =
#ifdef WINDOWS
#ifdef WINDOWS
PIStringAscii("Windows");
#else
# ifdef QNX
# ifdef QNX
PIStringAscii("QNX");
# else
# ifdef MAC_OS
# ifdef MAC_OS
PIStringAscii("MacOS");
# else
# ifdef ANDROID
# ifdef ANDROID
PIStringAscii("Android");
# else
# ifdef FREE_BSD
# ifdef FREE_BSD
PIStringAscii("FreeBSD");
# else
# ifdef FREERTOS
# ifdef FREERTOS
PIStringAscii("FreeRTOS");
# else
uns.sysname;
@@ -318,7 +305,6 @@ PIInit::~PIInit() {
PIResourcesStorage::instance()->clear();
#ifdef WINDOWS
WSACleanup();
//if (setTimerResolution) setTimerResolutionAddr(PRIVATE->prev_res, TRUE, &(PRIVATE->prev_res));
if (PRIVATE->ntlib) FreeLibrary(PRIVATE->ntlib);
PRIVATE->ntlib = 0;
#endif
@@ -332,62 +318,61 @@ PIInit::~PIInit() {
#ifdef PIP_ICU
u_cleanup();
#endif
//if (currentLocale_t != 0) freelocale(currentLocale_t);
}
bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) {
switch (o) {
case ICU: return
#ifdef PIP_ICU
#ifdef PIP_ICU
true;
#else
false;
#endif
case USB: return
#ifdef PIP_USB
#ifdef PIP_USB
true;
#else
false;
#endif
case STL: return
#ifdef PIP_CONTAINERS_STL
#ifdef PIP_CONTAINERS_STL
true;
#else
false;
#endif
case Crypt: return
#ifdef PIP_CRYPT
#ifdef PIP_CRYPT
true;
#else
false;
#endif
case Introspection: return
#ifdef PIP_INTROSPECTION
#ifdef PIP_INTROSPECTION
true;
#else
false;
#endif
case FFTW: return
#ifdef PIP_FFTW
#ifdef PIP_FFTW
true;
#else
false;
#endif
case Compress: return
#ifdef PIP_COMPRESS
#ifdef PIP_COMPRESS
true;
#else
false;
#endif
case OpenCL: return
#ifdef PIP_OPENCL
#ifdef PIP_OPENCL
true;
#else
false;
#endif
case Cloud: return
#ifdef PIP_CLOUD
#ifdef PIP_CLOUD
true;
#else
false;

View File

@@ -73,7 +73,6 @@ PIString PIObject::__MetaFunc::fullFormat() const {
PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__), emitter_(0), thread_safe_(false), proc_event_queue(false) {
//__PIVariantInitBuiltin__();
setName(name);
setDebug(true);
mutexObjects().lock();
@@ -181,14 +180,6 @@ void PIObject::piConnect(const PIString & src, const PIString & sig, const PIStr
d->connectors << s;
}
/*
PIStringList PIObject::events() {
PIStringList l;
for (PIMap<NamedFunction, PIString>::const_iterator i = signals_.begin(); i != signals_.end(); i++)
l << (*i).first;
return l;
}
*/
PIStringList PIObject::scopeList() const {
PIMutexLocker ml(__meta_mutex());
@@ -580,8 +571,6 @@ bool PIObject::isPIObject(const PIObject * o) {
}
void PIObject::dump(const PIString & line_prefix) const {
//printf("dump %s \"%s\"\n", className(), name().data());
PICout(PICoutManipulators::AddNewLine) << line_prefix << "class " << className() << " (" << (const void*)this << ", \"" << name() << "\") {";
@@ -627,8 +616,6 @@ void PIObject::dump(const PIString & line_prefix) const {
}
void dumpApplication() {
PIMutexLocker _ml(PIObject::mutexObjects());
//printf("dump application ...\n");
@@ -654,6 +641,7 @@ void dumpApplication() {
//printf("dump application done\n");
}
#ifndef FREERTOS
bool dumpApplicationToFile(const PIString & path) {
PIFile f(path + "_tmp");
@@ -672,8 +660,6 @@ bool dumpApplicationToFile(const PIString & path) {
#endif
void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
if (!scope_id.contains(shash)) {
scope_list << s;
@@ -682,8 +668,6 @@ void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
}
void PIObject::__Connection::destroy() {
#ifdef PIP_CXX11_SUPPORT
if (functor) delete functor;

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Storage of properties for GUI usage
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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/>.
*/
#include "pipropertystorage.h"

View File

@@ -1,334 +0,0 @@
/*! \file pistatemachine.h
* \brief Base class for custom state machine
*/
/*
PIP - Platform Independent Primitives
State machine
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 PISTATEMACHINE_H
#define PISTATEMACHINE_H
#include "piobject.h"
/*! \brief Base class for custom state machine
*
* \section PIStateMachine_synopsis Synopsis
* This class provide functionality of state machine.
* You should inherit from this class, implement \a execution()
* and \a transition() functions, set rules and periodically
* call \a tick() function to proper work of machine.
*
* \section PIStateMachine_prepare Prepare for work
* %State machine operates with "state", "rule" and "condition".
* * "State" is some class (by default \c int), associated name and
* optional "handler" - pointer to function executed on every \a tick();
* * "Rule" define rule of transition from one machine state to other.
* It is also has optional "handler";
* * "Condition" is a part of rule and define possibility of transition.
*
* First of all you should define states of your machine by function
* \a addState(). Then you should define transition rules for machine
* by function \a addRule(). Finally you can set initial state by function
* \a setInitialState() and provide periodically execution of function
* \a tick().
*
* \section PIStateMachine_principle Principle of work
* At any time the state machine is in some state. You can ask machine
* to enter in new state by function \a switchToState(). If all conditions
* done machine switch it state immediately, else machine remember request
* and will be try switch to the new state every tick. Successfull state
* switching execute function \a transition(), every tick execute
* function \a execution() with current state. On successfull transition
* if rule "handler" is not null it execute. Every \a tick() if current
* state "handler" is not null it execute.
*
* \section PIStateMachine_conditions Conditions
* Each rule has transition condition. Condition is array of pairs
* (string, number). It means that every condition by name "string"
* should be performed as least "number" times. Empty condition always
* permits transition.
*
* %State machine have current performed conditions. You can read this
* conditions by function \a currentConditions() and perform new
* conditions by functions \a performCondition() and \a performConditions().
* Currend conditions can de erased by function \a resetConditions().
*
* \section PIStateMachine_example Example
* This is simple example demonstrates all features:
* \snippet pistatemachine.cpp main
*/
template <typename Type = int>
class PIP_EXPORT PIStateMachine: public PIObject
{
PIOBJECT_SUBCLASS(PIStateMachine, PIObject)
public:
//! Constructs an empty state machine
PIStateMachine(void * _parent = 0) {if (_parent == 0) parent_ = this; else parent_ = _parent; resetConditions();}
~PIStateMachine() {;}
//! %Condition is a pair (string, number)
typedef PIPair<PIString, int> Condition;
//! %Rule of transition between states of machine
struct Rule {
//! Constuctor
Rule() {handler = 0; from = to = Type(); autoTransition = resetAllConditions = false;}
//! Constuctor
Rule(Type f, Type t, const PIStringList & c = PIStringList(), Handler h = 0, bool at = false, bool rac = false) {
from = f;
to = t;
for (int i = 0; i < c.size_s(); ++i)
conditions << Condition(c[i], 1);
autoTransition = at;
resetAllConditions = rac;
handler = h;
}
//! Source state
Type from;
//! Destination state
Type to;
//! %Conditions of transition
PIVector<Condition> conditions;
//! Automatic transition
bool autoTransition;
//! Reset or not all performed conditions of machine on transition
bool resetAllConditions;
//! Pointer to function executed on transition
Handler handler;
//! Add condition of transition
void addCondition(const PIString & name, int times = 1) {if (times > 0) conditions << Condition(name, times);}
bool operator ==(const Rule & other) const {return (from == other.from) && (to == other.to);}
bool operator !=(const Rule & other) const {return (from != other.from) || (to != other.to);}
};
//! %State of machine
struct State {
//! Constuctor
State() {handler = 0; value = Type();}
//! Constuctor
State(Type v, const PIString & n = "", Handler h = 0) {value = v; name = n; handler = h;}
//! %State value
Type value;
//! %State name
PIString name;
//! Pointer to function executed on tick
Handler handler;
bool operator ==(const State & other) const {return value == other.value;}
bool operator !=(const State & other) const {return value != other.value;}
};
void * parent() const {return parent_;}
void setParent(void * parent) {parent_ = parent;}
//! Add state of machine
void addState(Type value, const PIString & name = "", Handler handler = 0) {if (states_.contains(State(value, name))) return; states_ << State(value, name, handler);}
//! States count
int statesCount() const {return states_.size_s();}
//! Remove all states
void clearStates() {states_.clear();}
//! Add rule of transition
void addRule(Type from, Type to, const PIString & condition, Handler handler = 0, bool autoTransition = false, bool resetAllConditions = false) {if (rules_.contains(Rule(from, to))) return; rules_ << Rule(from, to, PIStringList(condition), handler, autoTransition, resetAllConditions);}
//! Add rule of transition
void addRule(Type from, Type to, Handler handler, bool autoTransition = false, bool resetAllConditions = false) {if (rules_.contains(Rule(from, to))) return; rules_ << Rule(from, to, PIStringList(), handler, autoTransition, resetAllConditions);}
//! Add rule of transition
void addRule(Type from, Type to, const PIStringList & conditions = PIStringList(), Handler handler = 0, bool autoTransition = false, bool resetAllConditions = false) {if (rules_.contains(Rule(from, to))) return; rules_ << Rule(from, to, conditions, handler, autoTransition, resetAllConditions);}
//! Add rule of transition
void addRule(const Rule & rule) {if (rules_.contains(rule)) return; rules_ << rule;}
//! Rules count
int rulesCount() const {return rules_.size_s();}
//! Remove all rules
void clearRules() {rules_.clear();}
//! Setup initial state. \a reset() will set machine state to "value"
void setInitialState(Type value) {
for (int i = 0; i < states_.size_s(); ++i)
if (states_[i].value == value) {
init_ = state_ = states_[i];
return;
}
}
/** \brief Try to switch machine state to state "to"
* \details If there is rule of transition exists and this rule conditions
* is performed then machine switched to new state immediately. Otherwise machine
* will be try to enter to new state every \a tick().
* \return \c true if state switched immediately, otherwise \c false */
bool switchToState(Type to) {
switch_to = to;
for (int i = 0; i < rules_.size_s(); ++i) {
Rule & r(rules_[i]);
if ((r.from != state_.value) || (r.to != to)) continue;
if (!checkConditions(r)) continue;
State ts = findState(to);
if (r.handler != 0 && parent_ != 0) r.handler(parent_);
transition(state_, ts);
state_ = ts;
resetConditions(r);
return true;
}
return false;
}
//! Reset machine state to initial and clear all conditions
void reset() {state_ = init_; resetConditions();}
//! Returns current state of machine
const State & currentState() const {return state_;}
//! Reset all performed conditions
void resetConditions() {cond.clear(); cond_count = 0;}
//! Reset performed condition with name "name"
void resetCondition(const PIString & name) {
for (int i = 0; i < cond.size_s(); ++i)
if (cond[i].first == name) {
cond.remove(i);
i--;
}
}
//! Perform condition with name "name" "times" times.
void performCondition(const PIString & name, int times = 1) {
if (times <= 0) return;
for (int i = 0; i < cond.size_s(); ++i)
if (cond[i].first == name) {
cond[i].second += times;
return;
}
cond << Condition(name, times);
}
//! Perform every condition with name from "names" one time.
void performConditions(const PIStringList & names) {
bool ok;
for (int n = 0; n < names.size_s(); ++n) {
ok = false;
for (int i = 0; i < cond.size_s(); ++i) {
if (cond[i].first == names[n]) {
cond[i].second++;
ok = true;
break;
}
}
if (ok) continue;
cond << Condition(names[n], 1);
}
}
//! Returns all current performed conditions
const PIVector<Condition> & currentConditions() const {return cond;}
Type * currentState_ptr() {return &state_.value;}
int * conditionsCount_ptr() {cond_count = cond.size_s(); return &cond_count;}
//! \handlers
//! \{
//! \fn void tick()
//! \brief Main function of machine. Execute \a execution() and check if need to switch state
//! \fn void tick(void * data, int delim)
//! \brief Main function of machine. Execute \a execution() and check if need to switch state
//! \}
EVENT_HANDLER(void, tick) {tick(0, 0);}
EVENT_HANDLER2(void, tick, void * , data, int, delim) {
execution(state_);
if (state_.handler != 0 && parent_ != 0) state_.handler(parent_);
if (switch_to != state_.value) switchToState(switch_to);
else {
piForeachC (Rule & r, rules_) {
if (!r.autoTransition || r.from != state_.value) continue;
if (checkConditions(r)) {
switchToState(r.to);
break;
}
}
}
}
protected:
//! Reimplement this function to process current state of machine
virtual void execution(const State & state) {;}
//! Reimplement this function to process switching current state of machine
virtual void transition(const State & from, const State & to) {;}
private:
State findState(Type value) {
for (int i = 0; i < states_.size_s(); ++i)
if (states_[i].value == value)
return states_[i];
return State();
}
bool checkConditions(const Rule & rule) {
//if (cond.size_s() < rule.conditions.size_s()) return false;
int oc = 0;
for (int i = 0; i < cond.size_s(); ++i) {
PIString & rn(cond[i].first);
for (int j = 0; j < rule.conditions.size_s(); ++j) {
if (rn != rule.conditions[j].first) continue;
if (cond[i].second < rule.conditions[j].second) return false;
oc++;
}
}
return (rule.conditions.size_s() == oc);
}
void resetConditions(const Rule & rule) {
if (rule.resetAllConditions) {
cond.clear();
return;
}
for (int i = 0; i < cond.size_s(); ++i) {
PIString & rn(cond[i].first);
for (int j = 0; j < rule.conditions.size_s(); ++j) {
if (rn != rule.conditions[j].first) continue;
cond[i].second -= rule.conditions[j].second;
if (cond[i].second <= 0) {
cond.remove(i);
i--;
}
}
}
}
PIVector<State> states_;
PIVector<Rule> rules_;
State init_, state_;
Type switch_to;
void * parent_;
int cond_count;
PIVector<Condition> cond;
};
#endif // PISTATEMACHINE_H

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
String
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -16,8 +16,10 @@
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 "piincludes_p.h"
#include "pistring.h"
#include "pistringlist.h"
#ifdef PIP_ICU
# define U_NOEXCEPT
# include "unicode/ucnv.h"
@@ -216,7 +218,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
else base = 10;
} else
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
//v.reverse();
if (ok) *ok = true;
PIVector<int> digits;
llong ret = 0, m = 1;
@@ -236,14 +237,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
m *= base;
}
if (neg) ret = -ret;
/*piForeachC (PIChar & i, v) {
if (i == PIChar('-')) {ret = -ret; continue;}
cs = fromBaseN[int(i.toAscii())];
cout << i << " = " << cs << endl;
if (cs < 0 || cs >= base) return ret;
ret += cs * m;
m *= base;
}*/
return ret;
}
@@ -494,29 +487,6 @@ PIString & PIString::operator +=(const char * str) {
PIString & PIString::operator +=(const wchar_t * str) {
if (!str) return *this;
//cout << "wc" << endl;
/*int l = 0, sz;
char * c = new char[MB_CUR_MAX];
while (str[l] != 0) ++l;
for (int i = 0; i < l; ++i) {
sz = wctomb(c, str[i]);
switch (sz) {
case 4:
push_back(PIChar(*(int*)c));
continue;
case 3:
push_back(PIChar(*(int*)c));
back().ch &= 0xFFFFFF;
continue;
case 2:
push_back(PIChar(*(short * )c));
continue;
default:
push_back(PIChar(c[0]));
break;
}
}
delete[] c;*/
int i = -1;
while (str[++i])
push_back(PIChar(ushort(str[i])));
@@ -589,9 +559,6 @@ PIString PIString::mid(const int start, const int len) const {
} else {
if (l > length() - s)
l = length() - s;
//for (int i = s; i < s + l; ++i)
// str += at(i);
// std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
return PIString(&(at(s)), l);
}
return PIString();
@@ -668,8 +635,6 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
PIString & PIString::insert(int index, const PIString & str) {
//uint c = str.length();
//for (uint i = 0; i < c; ++i) insert(index + i, str[i]);
PIDeque<PIChar>::insert(index, *((const PIDeque<PIChar>*)&str));
return *this;
}
@@ -1094,46 +1059,6 @@ ldouble PIString::toLDouble() const {
return atof(toNativeDecimalPoints().data());
}
/*
short PIString::toShort() const {
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
short v;
if (s.left(2) == "0x") {sscanf(s.data(), "%hx", &v); return v;}
if (s.left(1) == "0") {sscanf(s.data(), "%ho", &v); return v;}
sscanf(s.data(), "%hd", &v);
return v;
}
int PIString::toInt() const {
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
int v;
if (s.left(2) == "0x") {sscanf(s.data(), "%x", &v); return v;}
if (s.left(1) == "0") {sscanf(s.data(), "%o", &v); return v;}
sscanf(s.data(), "%d", &v);
return v;
}
long PIString::toLong() const {
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
long v;
if (s.left(2) == "0x") {sscanf(s.data(), "%lx", &v); return v;}
if (s.left(1) == "0") {sscanf(s.data(), "%lo", &v); return v;}
sscanf(s.data(), "%ld", &v);
return v;
}
llong PIString::toLLong() const {
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
llong v;
if (s.left(2) == "0x") {sscanf(s.data(), "%llx", &v); return v;}
if (s.left(1) == "0") {sscanf(s.data(), "%llo", &v); return v;}
sscanf(s.data(), "%lld", &v);
return v;
}
*/
PIString & PIString::setReadableSize(llong bytes) {
clear();
@@ -1164,20 +1089,19 @@ PIString & PIString::setReadableSize(llong bytes) {
inline char chrUpr(char c) {
if (c >= 'a' && c <= 'z') return c + 'A' - 'a';
//if (c >= 'а' && c <= 'я') return c + 'А' - 'а';
return c;
}
inline char chrLwr(char c) {
if (c >= 'A' && c <= 'Z') return c + 'a' - 'A';
//if (c >= 'А' && c <= 'Я') return c + 'а' - 'А';
return c;
}
const static PIString _versionDelims_ = PIStringAscii("._-+");
void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
s.trim();
if (s.isEmpty()) {
@@ -1220,6 +1144,7 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
//piCout << codes << strs;
}
int versionLabelValue(PIString s) {
int ret = -10000;
if (s.isEmpty()) return 0;
@@ -1240,6 +1165,7 @@ int versionLabelValue(PIString s) {
return ret;
}
int versionCompare(const PIString & v0, const PIString & v1, int components) {
PIStringList strs[2]; PIVector<int> codes[2];
parseVersion(v0.toLowerCase(), codes[0], strs[0]);
@@ -1291,35 +1217,9 @@ PICout operator <<(PICout s, const PIString & v) {
s.space();
s.quote();
s.setControl(0, true);
//if (PICout::isBufferActive())
s << v.data();
//else {
// s << v.dataConsole();
//}
s.restoreControl();
s.quote();
return s;
}
PIStringList& PIStringList::removeDuplicates() {
PIStringList l;
PIString s;
bool ae;
for (int i = 0; i < size_s(); ++i) {
ae = false;
s = at(i);
for (int j = 0; j < l.size_s(); ++j) {
if (s != l[j]) continue;
ae = true; break;
}
if (!ae) {
l << s;
continue;
}
remove(i);
--i;
}
return *this;
}

View File

@@ -6,7 +6,7 @@
/*
PIP - Platform Independent Primitives
String
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -43,14 +43,12 @@ public:
static const float ElideCenter;
static const float ElideRight ;
//inline PIString & operator +=(const char c) {push_back(c); return *this;}
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
PIString & operator +=(const char * str);
PIString & operator +=(const wchar_t * str);
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
PIString & operator +=(const PIString & str);
//PIString(const char c) {*this += c;}
PIString(const PIString & o): PIDeque<PIChar>() {*this += o;}
@@ -86,19 +84,6 @@ public:
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
PIString(const int len, const PIChar & c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
// PIString(const short & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const ushort & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const int & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const uint & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const long & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const ulong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const llong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const ullong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const float & value): PIDeque<PIChar>() {*this = fromNumber(value);}
// PIString(const double & value): PIDeque<PIChar>() {*this = fromNumber(value);}
~PIString() {}
@@ -122,7 +107,6 @@ public:
//! Compare operator
bool operator ==(const PIChar c) const {return *this == PIString(c);}
//inline bool operator ==(const char c) const {return *this == PIString(c);}
//! Compare operator
bool operator ==(const char * str) const {return *this == PIString(str);}
@@ -132,7 +116,6 @@ public:
//! Compare operator
bool operator !=(const PIChar c) const {return *this != PIString(c);}
//inline bool operator !=(const char c) const {return *this != PIString(c);}
//! Compare operator
bool operator !=(const char * str) const {return *this != PIString(str);}
@@ -142,7 +125,6 @@ public:
//! Compare operator
bool operator <(const PIChar c) const {return *this < PIString(c);}
//inline bool operator <(const char c) const {return *this < PIString(c);}
//! Compare operator
bool operator <(const char * str) const {return *this < PIString(str);}
@@ -152,7 +134,6 @@ public:
//! Compare operator
bool operator >(const PIChar c) const {return *this > PIString(c);}
//inline bool operator >(const char c) const {return *this > PIString(c);}
//! Compare operator
bool operator >(const char * str) const {return *this > PIString(str);}
@@ -162,7 +143,6 @@ public:
//! Compare operator
bool operator <=(const PIChar c) const {return *this <= PIString(c);}
//inline bool operator <=(const char c) const {return *this <= PIString(c);}
//! Compare operator
bool operator <=(const char * str) const {return *this <= PIString(str);}
@@ -172,29 +152,13 @@ public:
//! Compare operator
bool operator >=(const PIChar c) const {return *this >= PIString(c);}
//inline bool operator >=(const char c) const {return *this >= PIString(c);}
//! Compare operator
bool operator >=(const char * str) const {return *this >= PIString(str);}
// operator bool() const {return toBool();}
// operator short() const {return toShort();}
// operator ushort() const {return toUShort();}
// operator int() const {return toInt();}
// operator uint() const {return toUInt();}
// operator long() const {return toLong();}
// operator ulong() const {return toULong();}
// operator llong() const {return toLLong();}
// operator ullong() const {return toULLong();}
// operator float() const {return toFloat();}
// operator double() const {return toDouble();}
/*! \brief Append string "str" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIString) */
PIString & operator <<(const PIString & str) {*this += str; return *this;}
// inline PIString & operator <<(const char c) {*this += c; return *this;}
/*! \brief Append symbol "c" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
@@ -633,8 +597,6 @@ public:
//! \details Example: \snippet pistring.cpp PIString::toFloat
ldouble toLDouble() const;
//inline PIString & setNumber(const char value) {clear(); *this += itos(value); return *this;}
//! \brief Set string content to numeric representation of "value" in base "base"
//! \details Example: \snippet pistring.cpp PIString::setNumber
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
@@ -683,8 +645,6 @@ public:
//! \details Example: \snippet pistring.cpp PIString::setReadableSize
PIString & setReadableSize(llong bytes);
//inline static PIString fromNumber(const char value) {return PIString(itos(value));}
//! \brief Return string contains numeric representation of "value" in base "base"
//! \details Example: \snippet pistring.cpp PIString::fromNumber
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
@@ -793,13 +753,9 @@ inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.clear(); s >>
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
//inline PIString operator +(const PIString & f, const char c) {PIString s(f); s.push_back(c); return s;}
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
//inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
@@ -812,79 +768,6 @@ int versionCompare(const PIString & v0, const PIString & v1, int components = 6)
PIString versionNormalize(const PIString & v);
/*!\brief Strings array class
* \details This class is based on \a PIDeque<PIString> and
* expand it functionality. */
class PIP_EXPORT PIStringList: public PIDeque<PIString>
{
public:
//! Contructs empty strings list
PIStringList() {;}
~PIStringList() {;}
//! Contructs strings list with one string "str"
PIStringList(const PIString & str) {push_back(str);}
//! Contructs empty strings list with strings "s0" and "s1"
PIStringList(const PIString & s0, const PIString & s1) {push_back(s0); push_back(s1);}
//! Contructs empty strings list with strings "s0", "s1" and "s2"
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2) {push_back(s0); push_back(s1); push_back(s2);}
//! Contructs empty strings list with strings "s0", "s1", "s2" and "s3"
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2, const PIString & s3) {push_back(s0); push_back(s1); push_back(s2); push_back(s3);}
PIStringList(const PIStringList & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
PIStringList(const PIVector<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
PIStringList(const PIDeque<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
//! \brief Join all strings in one with delimiter "delim" and return it
//! \details Example: \snippet pistring.cpp PIStringList::join
PIString join(const PIString & delim) const {PIString s; for (uint i = 0; i < size(); ++i) {s += at(i); if (i < size() - 1) s += delim;} return s;}
//! \brief Remove all strings equal "value" and return this
//! \details Example: \snippet pistring.cpp PIStringList::removeStrings
PIStringList & removeStrings(const PIString & value) {for (uint i = 0; i < size(); ++i) {if (at(i) == value) {remove(i); --i;}} return *this;}
PIStringList & remove(uint num) {PIDeque<PIString>::remove(num); return *this;}
PIStringList & remove(uint num, uint count) {PIDeque<PIString>::remove(num, count); return *this;}
//! \brief Remove duplicated strings and return this
//! \details Example: \snippet pistring.cpp PIStringList::removeDuplicates
PIStringList & removeDuplicates();
//! \brief Trim all strings
//! \details Example: \snippet pistring.cpp PIStringList::trim
PIStringList & trim() {for (uint i = 0; i < size(); ++i) at(i).trim(); return *this;}
//! Return sum of lengths of all strings
uint contentSize() {uint s = 0; for (uint i = 0; i < size(); ++i) s += at(i).size(); return s;}
//! Compare operator
bool operator ==(const PIStringList & o) const {if (size() != o.size()) return false; for (size_t i = 0; i < size(); ++i) if (o[i] != (*this)[i]) return false; return true;}
//! Compare operator
bool operator !=(const PIStringList & o) const {return !(o == (*this));}
PIStringList & operator =(const PIStringList & o) {PIDeque<PIString>::operator=(o); return *this;}
PIStringList & operator <<(const PIString & str) {append(str); return *this;}
PIStringList & operator <<(const PIStringList & sl) {append(sl); return *this;}
};
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Output operator to PIByteArray
inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s << int(v.size_s()); for (int i = 0; i < v.size_s(); ++i) s << v[i]; return s;}
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Input operator from PIByteArray
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
//! \relatesalso PIStringList \relatesalso PICout \brief Output operator to PICout
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
template<> inline uint piHash(const PIString & s) {return s.hash();}

View File

@@ -6,7 +6,7 @@
/*
PIP - Platform Independent Primitives
STD for PIString
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -28,7 +28,7 @@
typedef std::basic_string<wchar_t> wstring;
#endif
#include "pistring.h"
#include "pistringlist.h"
inline std::string PIString2StdString(const PIString & v) {
@@ -42,12 +42,6 @@ inline std::string PIString2StdString(const PIString & v) {
s.push_back(char(tc));
wc >>= 8;
}
/*if (at(i).isAscii())
s.push_back(at(i).toAscii());
else {
s.push_back(at(i).toCharPtr()[0]);
s.push_back(at(i).toCharPtr()[1]);
}*/
}
}
return s;

View File

@@ -0,0 +1,42 @@
/*
PIP - Platform Independent Primitives
Strings array class
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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/>.
*/
#include "pistringlist.h"
PIStringList& PIStringList::removeDuplicates() {
PIStringList l;
PIString s;
bool ae;
for (int i = 0; i < size_s(); ++i) {
ae = false;
s = at(i);
for (int j = 0; j < l.size_s(); ++j) {
if (s != l[j]) continue;
ae = true; break;
}
if (!ae) {
l << s;
continue;
}
remove(i);
--i;
}
return *this;
}

View File

@@ -0,0 +1,100 @@
/*! \brief Strings array class
* \details This class is based on \a PIDeque<PIString> and
* expand it functionality. */
/*
PIP - Platform Independent Primitives
Strings array class
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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 PISTRINGLIST_H
#define PISTRINGLIST_H
#include "pistring.h"
class PIP_EXPORT PIStringList: public PIDeque<PIString>
{
public:
//! Contructs empty strings list
PIStringList() {;}
~PIStringList() {;}
//! Contructs strings list with one string "str"
PIStringList(const PIString & str) {push_back(str);}
//! Contructs empty strings list with strings "s0" and "s1"
PIStringList(const PIString & s0, const PIString & s1) {push_back(s0); push_back(s1);}
//! Contructs empty strings list with strings "s0", "s1" and "s2"
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2) {push_back(s0); push_back(s1); push_back(s2);}
//! Contructs empty strings list with strings "s0", "s1", "s2" and "s3"
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2, const PIString & s3) {push_back(s0); push_back(s1); push_back(s2); push_back(s3);}
PIStringList(const PIStringList & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
PIStringList(const PIVector<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
PIStringList(const PIDeque<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
//! \brief Join all strings in one with delimiter "delim" and return it
//! \details Example: \snippet pistring.cpp PIStringList::join
PIString join(const PIString & delim) const {PIString s; for (uint i = 0; i < size(); ++i) {s += at(i); if (i < size() - 1) s += delim;} return s;}
//! \brief Remove all strings equal "value" and return this
//! \details Example: \snippet pistring.cpp PIStringList::removeStrings
PIStringList & removeStrings(const PIString & value) {for (uint i = 0; i < size(); ++i) {if (at(i) == value) {remove(i); --i;}} return *this;}
PIStringList & remove(uint num) {PIDeque<PIString>::remove(num); return *this;}
PIStringList & remove(uint num, uint count) {PIDeque<PIString>::remove(num, count); return *this;}
//! \brief Remove duplicated strings and return this
//! \details Example: \snippet pistring.cpp PIStringList::removeDuplicates
PIStringList & removeDuplicates();
//! \brief Trim all strings
//! \details Example: \snippet pistring.cpp PIStringList::trim
PIStringList & trim() {for (uint i = 0; i < size(); ++i) at(i).trim(); return *this;}
//! Return sum of lengths of all strings
uint contentSize() {uint s = 0; for (uint i = 0; i < size(); ++i) s += at(i).size(); return s;}
//! Compare operator
bool operator ==(const PIStringList & o) const {if (size() != o.size()) return false; for (size_t i = 0; i < size(); ++i) if (o[i] != (*this)[i]) return false; return true;}
//! Compare operator
bool operator !=(const PIStringList & o) const {return !(o == (*this));}
PIStringList & operator =(const PIStringList & o) {PIDeque<PIString>::operator=(o); return *this;}
PIStringList & operator <<(const PIString & str) {append(str); return *this;}
PIStringList & operator <<(const PIStringList & sl) {append(sl); return *this;}
};
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Output operator to PIByteArray
inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s << int(v.size_s()); for (int i = 0; i < v.size_s(); ++i) s << v[i]; return s;}
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Input operator from PIByteArray
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
//! \relatesalso PIStringList \relatesalso PICout \brief Output operator to PICout
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
#endif // PISTRINGLIST_H

View File

@@ -16,6 +16,7 @@
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 "piincludes_p.h"
#include "pitime.h"
#include "pisystemtests.h"
@@ -244,8 +245,6 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U);
}
//long t_cur = GetCurrentTime();
//return PISystemTime(t_cur / 1000, (t_cur % 1000) * 1000000);
#else
# ifdef MAC_OS
mach_timespec_t t_cur;

View File

@@ -31,11 +31,6 @@
#include <windows.h>
//inline PISystemTime SYSTEMTIME2PISystemTime(SYSTEMTIME &t) {
// PISystemTime st;
//}
inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) {
PISystemTime st;
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime);

View File

@@ -82,8 +82,6 @@ struct PIP_EXPORT __PIVariantTypeInfo__ {
__TYPEINFO_SINGLE(T, T &) \
__TYPEINFO_SINGLE(T, const T) \
__TYPEINFO_SINGLE(T, const T &)
//__TYPEINFO_SINGLE(T, T *)
//__TYPEINFO_SINGLE(T, const T *)
class PIP_EXPORT __PIVariantInfoStorage__ {
@@ -465,31 +463,6 @@ public:
* Otherwise returns content as type T. */
template<typename T>
T value() const {return getAsValue<T>(*this);}
/*
operator bool() const {return toBool();}
operator char() const {return toInt();}
operator uchar() const {return toInt();}
operator short() const {return toInt();}
operator ushort() const {return toInt();}
operator int() const {return toInt();}
operator uint() const {return toInt();}
operator long() const {return toInt();}
operator ulong() const {return toInt();}
operator llong() const {return toLLong();}
operator ullong() const {return (ullong)toLLong();}
operator float() const {return toFloat();}
operator double() const {return toDouble();}
operator ldouble() const {return toLDouble();}
operator PITime() const {return toTime();}
operator PIDate() const {return toDate();}
operator PIDateTime() const {return toDateTime();}
operator PIString() const {return toString();}
operator PIStringList() const {return toStringList();}
operator PIBitArray() const {return toBitArray();}
operator PIByteArray() const {return toByteArray();}
operator const char*() const {return toString().data();}
operator void*() const {return (void*)(toLLong());}
*/
//! Assign operator
PIVariant & operator =(const PIVariant & v);
@@ -683,7 +656,6 @@ template<> inline PIVariantTypes::IODevice PIVariant::value() const {return toIO
template<> inline PIPointd PIVariant::value() const {return toPoint();}
template<> inline PIRectd PIVariant::value() const {return toRect();}
//template<> inline PIVariant PIVariant::fromValue(const char * v) {return PIVariant(PIString(v));}
template<> inline PIVariant PIVariant::fromValue(const bool & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const char & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const uchar & v) {return PIVariant(v);}

View File

@@ -25,7 +25,7 @@
#ifndef PIVARIANTYPES_H
#define PIVARIANTYPES_H
#include "pistring.h"
#include "pistringlist.h"
class PIPropertyStorage;
@@ -33,20 +33,20 @@ class PIPropertyStorage;
namespace PIVariantTypes {
/**
/**
* @brief name-value pair
*/
struct PIP_EXPORT Enumerator {
struct PIP_EXPORT Enumerator {
Enumerator(int v = 0, const PIString & n = PIString()): value(v), name(n) {}
int value;
PIString name;
};
};
/**
/**
* @brief Collection of PIVariantTypes::Enumerator. It's replace classic c-style enum.
* Contains elements with unique name and not uniqueue values.
*/
struct PIP_EXPORT Enum {
struct PIP_EXPORT Enum {
Enum(const PIString & n = PIString()): enum_name(n) {}
PIString toString() const {return selected;} // obsolete
@@ -120,29 +120,29 @@ namespace PIVariantTypes {
* @brief Add PIVariantTypes::Enumerator element for each name in vector
*/
Enum & operator <<(const PIStringList & v);
};
};
struct PIP_EXPORT File {
struct PIP_EXPORT File {
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
PIString toString() const {return file;}
PIString file;
PIString filter;
bool is_abs;
};
};
struct PIP_EXPORT Dir {
struct PIP_EXPORT Dir {
Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {}
PIString toString() const {return dir;}
PIString dir;
bool is_abs;
};
};
struct PIP_EXPORT Color {
struct PIP_EXPORT Color {
Color(uint v = 0) {rgba = v;}
uint rgba;
};
};
struct PIP_EXPORT IODevice {
struct PIP_EXPORT IODevice {
IODevice();
void set(const PIPropertyStorage & ps);
PIPropertyStorage get() const;
@@ -151,7 +151,7 @@ namespace PIVariantTypes {
int mode; // PIIODevice::DeviceMode
int options; // PIIODevice::DeviceOptions
PIByteArray props;
};
};
}

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
PIP Authentication API
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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
@@ -87,9 +87,6 @@ public:
//! Server event on check client password
EVENT1(passwordCheck, bool, result)
//EVENT_HANDLER1(void, received, PIByteArray, data);
private:
State disconnect(PIByteArray & ba, const PIString & error = PIString());
bool isAuthorizedKey(const PIByteArray & pkey);

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Cryptographic class using lib Sodium
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Contains geo ellipsoid models
Andrey Bychkov work.a.b@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/>.
*/
#include "piellipsoidmodel.h"

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Contains geo ellipsoid models
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
Class for geo position storage and conversions
Andrey Bychkov work.a.b@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/>.
*/
#include "pigeoposition.h"
const double PIGeoPosition::one_cm_tolerance = 0.01; // One centimeter tolerance.
@@ -382,12 +401,6 @@ double PIGeoPosition::radiusEarth(double geolat, PIEllipsoidModel ell) {
}
//PIGeoPosition &PIGeoPosition::operator=(const PIGeoPosition &v) {
// *((PIMathVectorT3d*)(this)) = *((PIMathVectorT3d*)&v);
// return *this;
//}
PIGeoPosition &PIGeoPosition::operator=(const PIMathVectorT3d &v) {
*((PIMathVectorT3d*)(this)) = v;
return *this;

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Class for geo position storage and conversions
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
Andrey Bychkov work.a.b@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
@@ -141,7 +141,6 @@ public:
/// Returns as PIMathVectorT3d
const PIMathVectorT3d & vector() const {return *this;}
// PIGeoPosition &operator=(const PIGeoPosition & v);
PIGeoPosition &operator=(const PIMathVectorT3d & v);
PIGeoPosition &operator-=(const PIGeoPosition &right);
PIGeoPosition &operator+=(const PIGeoPosition &right);

View File

@@ -27,8 +27,6 @@
const uint PIIntrospection::sign = 0x0F1C2B3A;
PIIntrospection::RequiredInfo::RequiredInfo() {
types = itInfo;
}
@@ -39,18 +37,13 @@ PIIntrospection::ProcessInfo::ProcessInfo() {
}
PIIntrospection::ObjectInfo::ObjectInfo() {
queued_events = 0;
}
PIIntrospection::ProcessInfo PIIntrospection::getInfo() {
PIIntrospection::ProcessInfo ret;
PISystemInfo * si = PISystemInfo::instance();
ret.architecture = si->architecture;
ret.execCommand = si->execCommand;
@@ -60,9 +53,7 @@ PIIntrospection::ProcessInfo PIIntrospection::getInfo() {
ret.OS_version = si->OS_version;
ret.processorsCount = si->processorsCount;
ret.user = si->user;
ret.build_options = PIInit::buildOptions();
return ret;
}

View File

@@ -36,9 +36,7 @@ PIIntrospectionThreads::PIIntrospectionThreads() {
void PIIntrospectionThreads::threadNew(PIThread * t) {
PIMutexLocker _ml(mutex);
//ThreadInfo & ti(threads[t]);
threads.insert(t, ThreadInfo());
//piCout << "register thread" << id << name;
}

View File

@@ -1,3 +1,21 @@
/*
PIP - Platform Independent Primitives
CAN
Andrey Bychkov work.a.b@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/>.
*/
#include "pican.h"
#include "pipropertystorage.h"
#include "piincludes_p.h"
@@ -18,14 +36,6 @@
#endif
//PRIVATE_DEFINITION_START(PICAN)
//#ifdef PIP_CAN
//int fd;
//spi_ioc_transfer spi_ioc_tr;
//#endif
//PRIVATE_DEFINITION_END(PICAN)
REGISTER_DEVICE(PICAN)

View File

@@ -1,3 +1,25 @@
/*! \file pican.h
* \brief CAN device
*/
/*
PIP - Platform Independent Primitives
CAN
Andrey Bychkov work.a.b@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 PICAN_H
#define PICAN_H

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Config parser
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -17,12 +17,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include "piconfig.h"
#include "pifile.h"
#include "piiostring.h"
#include "pistring_std.h"
#ifdef PIP_STD_IOSTREAM
# include "pistring_std.h"
# include <iostream>
#endif
/*! \class PIConfig
* \brief Configuration file
* \details This class provide handle access to configuration file.
@@ -258,7 +260,7 @@ void PIConfig::Entry::coutt(std::ostream & s, const PIString & p) const {
void PIConfig::Entry::piCoutt(PICout s, const PIString & p) const {
PIString nl = p + " ";
if (!_value.isEmpty()) s << p << _name << " = " << _value << " (" << _type << " " << _comment << ")" << PICoutManipulators::NewLine;
else std::cout << p << _name << std::endl;
else s << p << _name << PICoutManipulators::NewLine;
piForeachC (Entry * i, _children) i->piCoutt(s, nl);
}
@@ -620,8 +622,6 @@ PIString PIConfig::getPrefixFromLine(PIString line, bool * exists) {
void PIConfig::writeAll() {
//cout << this << " write < " << size() << endl;
_clearDev();
//*this << "1234567894132456798\n"; return;
//writeEntry(&root);
buildFullNames(&root);
Branch b = allLeaves();
PIString prefix, tprefix;
@@ -787,7 +787,6 @@ void PIConfig::parse() {
//piCout << "[PIConfig] str" << str.size() << str << str.toUTF8();
ind = str.find('=');
if ((ind > 0) && (str[0] != '#')) {
//name = str.left(ind).trimmed();
tree = (prefix + str.left(ind).trimmed()).split(delim);
if (tree.front() == "include") {
name = str.mid(ind + 1).trimmed();

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Configuration parser and writer
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -94,8 +94,6 @@ public:
bool isEntryExists(const PIString & name) const {piForeachC (Entry * i, *this) if (entryExists(i, name)) return true; return false;}
int indexOf(const Entry * e) {for (int i = 0; i < size_s(); ++i) if (at(i) == e) return i; return -1;}
//void clear() {piForeach (Entry * i, *this) delete i; PIVector<Entry * >::clear();}
private:
bool entryExists(const Entry * e, const PIString & name) const;
void allLeaves(Branch & b, Entry * e) {piForeach (Entry * i, e->_children) {if (i->isLeaf()) b << i; else allLeaves(b, i);}}

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Directory
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Directory
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Ethernet, UDP/TCP Broadcast/Multicast
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -216,7 +216,6 @@ PIEthernet::PIEthernet(): PIIODevice("", ReadWrite) {
construct();
setType(UDP);
setParameters(PIEthernet::ReuseAddress | PIEthernet::MulticastLoop | PIEthernet::KeepConnection);
//if (type_ != UDP) init();
}
@@ -297,13 +296,9 @@ bool PIEthernet::init() {
}
if (params[PIEthernet::ReuseAddress]) ethSetsockoptBool(sock, SOL_SOCKET, SO_REUSEADDR);
if (params[PIEthernet::Broadcast]) ethSetsockoptBool(sock, SOL_SOCKET, SO_BROADCAST);
//if (type() == PIEthernet::TCP_Client) ethSetsockoptBool(sock, SOL_SOCKET, SO_KEEPALIVE);
applyTimeouts();
applyOptInt(IPPROTO_IP, IP_TTL, TTL());
// piCoutObj << "inited" << path();
//cout << "inited " << sock << ": bc = " << params << endl;
//fcntl(sock, F_SETFL, 0/*O_NONBLOCK*/);
//piCoutObj << "init" << sock;
return true;
}
@@ -360,7 +355,6 @@ bool PIEthernet::openDevice() {
init();
if (sock == -1 || path().isEmpty()) return false;
addr_r.set(path());
//Address::splitIPPort(path(), &ip_, &port_);
if (type() == TCP_Client)
connecting_ = true;
if (type() != UDP || mode() == PIIODevice::WriteOnly)
@@ -387,7 +381,6 @@ bool PIEthernet::openDevice() {
opened_ = true;
while (!mcast_queue.isEmpty())
joinMulticastGroup(mcast_queue.dequeue());
//cout << "!" << endl;
applyTimeouts();
applyOptInt(IPPROTO_IP, IP_TTL, TTL());
addr_lr.clear();
@@ -479,9 +472,6 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
return true;
}
PIFlags<Parameters> params = parameters();
//#ifndef QNX
//if (!params[Broadcast])
//;piCoutObj << "Warning: \"Broadcast\" parameter not set, \"joinMulticastGroup(\"" << group << "\")\" may be useless!";
addr_r.set(path());
#ifndef FREERTOS
struct ip_mreqn mreq;
@@ -508,11 +498,6 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
mreq.imr_interface.s_addr = addr_r.ip();
#endif
/*#ifndef WINDOWS
PIEthernet::InterfaceList il = interfaces();
const PIEthernet::Interface * ci = il.getByAddress(ip_);
if (ci != 0) mreq.imr_ifindex = ci->index;
#endif*/
//piCout << "join group" << group << "ip" << ip_ << "with index" << mreq.imr_ifindex << "socket" << sock;
mreq.imr_multiaddr.s_addr = inet_addr(group.dataAscii());
if (ethSetsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) != 0) {
@@ -522,20 +507,6 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
if (params[PIEthernet::MulticastLoop]) ethSetsockoptInt(sock, IPPROTO_IP, IP_MULTICAST_LOOP);
applyOptInt(IPPROTO_IP, IP_MULTICAST_TTL, multicastTTL());
if (!mcast_groups.contains(group)) mcast_groups << group;
//#else
// parseAddress(path(), &ip_, &port_);
// struct ip_mreq mreq;
// memset(&mreq, 0, sizeof(mreq));
// mreq.imr_interface.s_addr = inet_addr(ip_.dataAscii());
// mreq.imr_multiaddr.s_addr = inet_addr(group.dataAscii());
// if (ethSetsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) != 0) {
// piCoutObj << "Can`t join multicast group " << group << ", " << ethErrorString();
// return false;
// }
// if (params[PIEthernet::MulticastLoop]) ethSetsockoptInt(sock, IPPROTO_IP, IP_MULTICAST_LOOP);
// applyOptInt(IPPROTO_IP, IP_MULTICAST_TTL, multicastTTL());
// if (!mcast_groups.contains(group)) mcast_groups << group;
//#endif
return true;
}
@@ -601,22 +572,6 @@ bool PIEthernet::connect(bool threaded) {
connected();
}
return connected_;
/*if (sock == -1) return false;
memset(addr_, 0, sizeof(*addr_));
parseAddress(path_, &ip_, &port_);
PRIVATE->addr_.sin_port = htons(port_);
PRIVATE->addr_.sin_addr.s_addr = inet_addr(ip_.data());
PRIVATE->addr_.sin_family = AF_INET;
#ifdef QNX
PRIVATE->addr_.sin_len = sizeof(*addr_);
#endif
//piCoutObj << "connect to " << ip << ":" << port_;
connected_ = (::connect(sock, (sockaddr * )addr_, sizeof(*addr_)) == 0);
if (!connected_)
piCoutObj << "Can`t connect to " << ip_ << ":" << port_ << ", " << ethErrorString();
opened_ = connected_;
if (connected_) connected();
return connected_;*/
}
@@ -664,7 +619,7 @@ bool PIEthernet::listen(bool threaded) {
return true;
}
//#include <QDebug>
int PIEthernet::readDevice(void * read_to, int max_size) {
//piCout << "read" << sock;
if (sock == -1) init();
@@ -704,10 +659,8 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
PRIVATE->addr_.sin_len = sizeof(PRIVATE->addr_);
#endif
//piCoutObj << "connect to " << ip_ << ":" << port_ << "...";
//qDebug() << "connect to " << ip_.data() << ":" << port_ << sock << PRIVATE->addr_.sin_addr.s_addr << "...";
connected_ = (::connect(sock, (sockaddr * )&(PRIVATE->addr_), sizeof(PRIVATE->addr_)) == 0);
//piCoutObj << "connect to " << ip_ << ":" << port_ << connected_;
//qDebug() << "connect to " << ip_.data() << ":" << port_ << connected_;
if (!connected_)
piCoutObj << "Can`t connect to" << addr_r << "," << ethErrorString();
opened_ = connected_;
@@ -717,13 +670,11 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
} else
piMSleep(10);
//piCout << "connected to" << path();
//qDebug() << "connected to" << path().data();
}
if (!connected_) return -1;
errorClear();
rs = ethRecv(sock, read_to, max_size);
//piCoutObj << "readed" << rs;
//qDebug() << "readed" << rs;
if (rs <= 0) {
lerr = ethErrorCore();
//piCoutObj << "readed error" << lerr << errorString().data() << parameters()[DisonnectOnTimeout];
@@ -735,7 +686,6 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
if ((lerr == EWOULDBLOCK || lerr == EAGAIN) && !parameters()[DisonnectOnTimeout]) {
#endif
//piCoutObj << errorString();
//piMSleep(10);
return -1;
}
if (connected_) {
@@ -749,7 +699,6 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
//piCoutObj << "eth" << ip_ << "disconnected";
}
if (rs > 0) received(read_to, rs);
//qDebug() << "return from read" << rs;
return rs;
case UDP:
memset(&PRIVATE->raddr_, 0, sizeof(PRIVATE->raddr_));
@@ -757,14 +706,11 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
if (rs > 0) {
addr_lr.set(uint(PRIVATE->raddr_.sin_addr.s_addr), ntohs(PRIVATE->raddr_.sin_port));
//piCoutObj << "read from" << ip_r << ":" << port_r << rs << "bytes";
//piCout << "received from" << lastReadAddress();
received(read_to, rs);
}
//else piCoutObj << "read returt" << rs << ", error" << ethErrorString();
return rs;
//return ::read(sock, read_to, max_size);
default: break;
//return ::read(sock, (char * )read_to, max_size);
}
return -1;
}
@@ -801,8 +747,7 @@ int PIEthernet::writeDevice(const void * data, int max_size) {
return ret;
case UDP:
PRIVATE->saddr_.sin_port = htons(addr_s.port());
/*if (params[PIEthernet::Broadcast]) PRIVATE->saddr_.sin_addr.s_addr = INADDR_BROADCAST;
else*/ PRIVATE->saddr_.sin_addr.s_addr = addr_s.ip();
PRIVATE->saddr_.sin_addr.s_addr = addr_s.ip();
PRIVATE->saddr_.sin_family = AF_INET;
//piCoutObj << "write to" << ip_s << ":" << port_s << "socket" << sock_s << max_size << "bytes ...";
return ethSendto(sock_s, data, max_size,
@@ -843,7 +788,6 @@ int PIEthernet::writeDevice(const void * data, int max_size) {
}
return ret;
default: break;
//return ::read(sock, read_to, max_size);
}
return -1;
}
@@ -907,10 +851,6 @@ void PIEthernet::server_func(void * eth) {
ce->clients_mutex.unlock();
ce->newConnection(e);
//cout << "connected " << ip << endl;
//char d[256];
//cout << " recv " << recv(s, d, 256, 0) << endl;
//cout << recv(ce->clients_.back()->sock, d, 256, 0) << endl;
}
@@ -1029,8 +969,6 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
ci.index = pAdapter->Index;
ci.mac = macFromBytes(PIByteArray(pAdapter->Address, pAdapter->AddressLength));
ci.flags = PIEthernet::ifActive | PIEthernet::ifRunning;
//if (ret->ifa_flags & IFF_BROADCAST) ci.flags |= PIEthernet::ifBroadcast;
//if (ret->ifa_flags & IFF_MULTICAST) ci.flags |= PIEthernet::ifMulticast;
if (pAdapter->Type == MIB_IF_TYPE_PPP) ci.flags |= PIEthernet::ifPTP;
if (pAdapter->Type == MIB_IF_TYPE_LOOPBACK) ci.flags |= PIEthernet::ifLoopback;
ci.broadcast.clear();
@@ -1047,10 +985,6 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
il << ci;
as = as->Next;
}
/*if (ci.flags[PIEthernet::ifBroadcast])
ci.broadcast = getSockAddr(ret->ifa_broadaddr);
if (ci.flags[PIEthernet::ifPTP])
ci.ptp = getSockAddr(ret->ifa_dstaddr);*/
pAdapter = pAdapter->Next;
}
} else
@@ -1060,40 +994,6 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
#else
#ifdef FREERTOS
#else
/*# ifdef QNX
PIStringList il, sl;
PIProcess proc;
proc.setGrabOutput(true);
proc.exec(ifconfigPath.c_str(), "-l");
if (!proc.waitForFinish(1000)) return sl;
PIString out(proc.readOutput());
il = out.split(" ");
il.removeAll("");
piForeachC (PIString & i, il) {
proc.exec(ifconfigPath.c_str(), i);
if (!proc.waitForFinish(1000)) return il;
sl << i.trimmed();
out = proc.readOutput();
int al = out.length();
al = (al - out.replaceAll("alias", "").length()) / 5;
for (int j = 0; j < al; ++j)
sl << i.trimmed() + ":" + PIString::fromNumber(j);
}
return sl;
# else
PIStringList sl;
PIProcess proc;
proc.setGrabOutput(true);
proc.exec(ifconfigPath.c_str(), "-s");
if (!proc.waitForFinish(1000)) return sl;
PIString out(proc.readOutput());
out.cutLeft(out.find('\n') + 1);
while (!out.isEmpty()) {
sl << out.left(out.find(' '));
out.cutLeft(out.find('\n') + 1);
}
return sl;
# endif*/
# ifdef ANDROID
struct ifconf ifc;
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
@@ -1222,38 +1122,6 @@ PIEthernet::Address PIEthernet::interfaceAddress(const PIString & interface_) {
PIVector<PIEthernet::Address> PIEthernet::allAddresses() {
/*#ifdef WINDOWS
PIStringList al;
PIString ca;
PIP_ADAPTER_INFO pAdapterInfo, pAdapter = 0;
int ret = 0;
ulong ulOutBufLen = sizeof(IP_ADAPTER_INFO);
pAdapterInfo = (IP_ADAPTER_INFO * ) HeapAlloc(GetProcessHeap(), 0, (sizeof (IP_ADAPTER_INFO)));
if (pAdapterInfo == 0) {
piCout << "[PIEthernet] Error allocating memory needed to call GetAdaptersinfo";
return PIStringList();
}
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
HeapFree(GetProcessHeap(), 0, (pAdapterInfo));
pAdapterInfo = (IP_ADAPTER_INFO *) HeapAlloc(GetProcessHeap(), 0, (ulOutBufLen));
if (pAdapterInfo == 0) {
piCout << "[PIEthernet] Error allocating memory needed to call GetAdaptersinfo";
return PIStringList();
}
}
if ((ret = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
pAdapter = pAdapterInfo;
while (pAdapter) {
ca = PIString(pAdapter->IpAddressList.IpAddress.String);
if (ca != "0.0.0.0") al << ca;
pAdapter = pAdapter->Next;
}
} else
piCout << "[PIEthernet] GetAdaptersInfo failed with error: " << ret;
if (pAdapterInfo)
HeapFree(GetProcessHeap(), 0, (pAdapterInfo));
return al;
#else*/
PIEthernet::InterfaceList il = interfaces();
PIVector<Address> ret;
bool has_127 = false;
@@ -1266,13 +1134,11 @@ PIVector<PIEthernet::Address> PIEthernet::allAddresses() {
// piCout << "[PIEthernet::allAddresses]" << al;
if (!has_127) ret << Address("127.0.0.1");
return ret;
//#endif
}
// System wrap
int PIEthernet::ethErrorCore() {
#ifdef WINDOWS
return WSAGetLastError();

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Ethernet, UDP/TCP Broadcast/Multicast
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -211,8 +211,6 @@ public:
//! Returns parameters
PIFlags<PIEthernet::Parameters> parameters() const {return (PIFlags<PIEthernet::Parameters>)(property(PIStringAscii("parameters")).toInt());}
//PIByteArray macAddress() {if (!init_) init(); struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); memcpy(ifr.ifr_name, "eth0", 5); ioctl(sock, SIOCSIFHWADDR, &ifr); return PIByteArray(&ifr.ifr_hwaddr.sa_data, 6);}
//! Returns %PIEthernet type
Type type() const {return (Type)(property(PIStringAscii("type")).toInt());}

View File

@@ -16,6 +16,7 @@
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 "piincludes_p.h"
#include "pifile.h"
#include "pidir.h"
@@ -153,15 +154,6 @@ bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
}
//PIFile::PIFile(const PIFile & other) {
// PRIVATE->fd = 0;
// fdi = -1;
// setPrecision(other.prec_);
// setPath(other.path());
// mode_ = other.mode_;
//}
bool PIFile::openDevice() {
close();
PIString p = path();
@@ -632,20 +624,6 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
ret.size = filesize.QuadPart;
ret.time_access = FILETIME2PIDateTime(fi.ftLastAccessTime);
ret.time_modification = FILETIME2PIDateTime(fi.ftLastWriteTime);
/*PIByteArray sec;
DWORD sec_n(0);
//SECURITY_DESCRIPTOR sec;
GetFileSecurity(path.data(), DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, (SECURITY_DESCRIPTOR*)sec.data(), 0, &sec_n);
sec.resize(sec_n);
GetFileSecurity(path.data(), DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, (SECURITY_DESCRIPTOR*)sec.data(), sec.size(), &sec_n);
errorClear();
SID sid; BOOL def;
GetSecurityDescriptorGroup((PSECURITY_DESCRIPTOR)sec.data(), &sid, &def);
char * s(0);
ConvertSidToStringSid((PSID)&sid, s);
piCout << s;
LocalFree(s);
//ret.id_user = ;*/
}
CloseHandle(hFile);
#else
@@ -708,7 +686,6 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
if (!info.perm_user.write) attr |= FILE_ATTRIBUTE_READONLY;
if (SetFileAttributes((LPCTSTR)(fp.data()), attr) == 0) {
piCout << "[PIFile] applyFileInfo: \"SetFileAttributes\" error:" << errorString();
//return false;
}
HANDLE hFile = 0;
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
@@ -724,7 +701,6 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
}
CloseHandle(hFile);
#else
//#ifndef ESP_PLATFORM
int mode(0);
if (info.perm_user.read) mode |= S_IRUSR;
if (info.perm_user.write) mode |= S_IWUSR;
@@ -737,11 +713,9 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
if (info.perm_other.exec) mode |= S_IXOTH;
if (chmod(fp.data(), mode) != 0) {
piCout << "[PIFile] applyFileInfo: \"chmod\" error:" << errorString();
//return false;
}
if (chown(fp.data(), info.id_user, info.id_group) != 0) {
piCout << "[PIFile] applyFileInfo: \"chown\" error:" << errorString();
//return false;
}
struct timeval tm[2];
PISystemTime st = info.time_access.toSystemTime();
@@ -752,9 +726,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
tm[1].tv_usec = st.nanoseconds / 1000;
if (utimes(fp.data(), tm) != 0) {
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
//return false;
}
//#endif
#endif
return true;
}

View File

@@ -91,13 +91,8 @@ public:
//! Open temporary file with open mode "mode"
bool openTemporary(PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
// PIFile(const PIFile & other);
~PIFile() {closeDevice();}
//PIFile & operator =(const PIFile & f) {path_ = f.path_; type_ = f.type_; return *this;}
//! Immediate write all buffered data to disk
void flush();
@@ -112,7 +107,6 @@ public:
//! Move read/write position to text line number "line"
void seekToLine(llong line);
//void fill(char c) {stream.fill(c);}
//! Read one char and return it
char readChar();
@@ -178,8 +172,6 @@ public:
//! Write to file binary content of "v"
PIFile & writeBinary(const double v) {write(&v, sizeof(v)); return *this;}
//PIFile & operator =(const PIFile & f) {PIIODevice::setPath(f.path()); mode_ = f.mode_; return *this;}
//! Write to file text representation of "v"
PIFile & operator <<(const char v);
//! Write to file string "v"
@@ -209,7 +201,6 @@ public:
//! Write to file text representation of "v" with precision \a precision()
PIFile & operator <<(double v);
//! Read from file text representation of "v"
PIFile & operator >>(char & v);
//! Read from file text representation of "v"

View File

@@ -139,7 +139,6 @@ bool PIGPIO::getPinState(int gpio_num) {
}
}
//piCoutObj << "pinState" << gpio_num << ":" << ret << (int)r << errorString();
//initGPIO(gpio_num, PIGPIO::In); TODO: discuss - why?
#endif
return false;
}
@@ -193,7 +192,7 @@ void PIGPIO::end() {
}
void PIGPIO::initPin(int gpio_num, Direction dir) { //, PullUpDownControl pull) {
void PIGPIO::initPin(int gpio_num, Direction dir) {
#ifdef GPIO_SYS_CLASS
PIMutexLocker ml(mutex);
GPIOData & g(gpio_[gpio_num]);

View File

@@ -38,16 +38,12 @@ public:
In /** Input direction (read) */,
Out /** Output direction (write) */
};
//enum PullUpDownControl {NoPull, PullUp, PullDown};
//! \brief Returns singleton object of %PIGPIO
static PIGPIO * instance();
//! \brief Initialize pin \"gpio_num\" for \"dir\" mode
void initPin(int gpio_num, Direction dir = PIGPIO::In);//, PullUpDownControl pull);
void initPin(int gpio_num, Direction dir = PIGPIO::In);
//! \brief Set pin \"gpio_num\" value to \"value\"
void pinSet (int gpio_num, bool value);
@@ -61,7 +57,6 @@ public:
//! \brief Returns pin \"gpio_num\" state
bool pinState(int gpio_num);
//! \brief Starts watch for pin \"gpio_num\".
//! \details Pins watching starts only with \a PIThread::start() function!
//! This function doesn`t affect thread state
@@ -77,7 +72,6 @@ public:
//! This function doesn`t affect thread state
void clearWatch();
EVENT2(pinChanged, int, gpio_num, bool, new_value)
//! \events

View File

@@ -27,8 +27,6 @@
* This class sllow you to use PIByteArray as PIIODevice and pass it to, e.g. PIConfig
*/
//REGISTER_DEVICE(PIIOByteArray);
PIIOByteArray::PIIOByteArray(PIByteArray *buffer, PIIODevice::DeviceMode mode) {
open(buffer, mode);

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Abstract input/output device
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -191,7 +191,6 @@ void PIIODevice::_init() {
// setThreadedReadBufferSize(512);
#else
threaded_read_buffer_size = 4096;
// setThreadedReadBufferSize(4096);
#endif
timer.setName("__S__.PIIODevice.reopen_timer");
write_thread.setName("__S__.PIIODevice.write_thread");
@@ -268,7 +267,6 @@ void PIIODevice::begin() {
//cout << " ok\n";
return;
}
//init();
if (!timer.isRunning() && isReopenEnabled()) timer.start(reopenTimeout());
}

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Abstract input/output device
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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
@@ -209,9 +209,6 @@ public:
//! Write maximum "max_size" bytes of "data" to device
int write(const void * data, int max_size) {return writeDevice(data, max_size);}
//int write(const PIByteArray & data) {return writeDevice(data.data(), data.size_s());}
//! Read from device for "timeout_ms" milliseconds and return readed data as PIByteArray. Timeout should to be greater than 0
PIByteArray readForTime(double timeout_ms);

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@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

View File

@@ -27,8 +27,6 @@
* This class allow you to use PIString as PIIODevice and pass it to, e.g. PIConfig
*/
//REGISTER_DEVICE(PIIOString);
PIIOString::PIIOString(PIString * string, PIIODevice::DeviceMode mode) {
open(string, mode);

View File

@@ -79,7 +79,6 @@ PIPeer::PeerData::~PeerData() {
void PIPeer::PeerData::dtThread() {
// << "send DT ...";
dt_out.send(data);
//piCoutObj << "send DT done";
}
@@ -172,13 +171,10 @@ PIPeer::PIPeer(const PIString & n): PIIODevice(), inited__(false), eth_tcp_srv(P
read_buffer_size = 128;
self_info.dist = 0;
self_info.time = PISystemTime::current();
//joinMulticastGroup("239.240.241.242");
randomize();
//id_ = self_info.name + "_" + PIString::fromNumber(randomi());
CONNECTU(&sync_timer, tickEvent, this, timerEvent);
prev_ifaces = PIEthernet::interfaces();
no_timer = false;
// initNetwork();
sync_timer.addDelimiter(5);
}
@@ -231,7 +227,6 @@ void PIPeer::timerEvent(void * data, int delim) {
checkNetwork();
break;
}
//send("broadcast", 9);
}
@@ -269,7 +264,6 @@ void PIPeer::initEths(PIStringList al) {
void PIPeer::initMBcasts(PIStringList al) {
// destroyMBcasts();
PIEthernet * ce;
const PIEthernet::Interface * cint;
PIString nm;
@@ -316,7 +310,6 @@ void PIPeer::initMBcasts(PIStringList al) {
//piCoutObj << "invalid address for bcast" << a;
}
}
// eth_lo.setDebug(false);
eth_lo.setName("__S__PIPeer_eth_loopback");
eth_lo.setParameters(PIEthernet::SeparateSockets);
eth_lo.init();
@@ -398,17 +391,6 @@ PIPeer::PeerInfo * PIPeer::quickestPeer(const PIString & to) {
if (!peers_map.contains(to)) return 0;
//piCout << "*** search quickest peer" << to;
PIVector<PeerInfo * > tp = addresses_map.value(to);
/*PeerInfo * dp = 0;
int mping = 0x7FFFFFFF;
for (int i = 0; i < tp.size_s(); ++i) {
int p = tp[i]->ping();
if (mping > p && p > 0) {
mping = p;
dp = tp[i];
}
}
//piCout << "*** search quickest peer: found" << (dp ? dp->name : "0");
return dp;*/
if (tp.isEmpty()) return 0;
return tp.back();
}
@@ -471,7 +453,6 @@ bool PIPeer::dataRead(uchar * readed, int size) {
int type, cnt;
PIString from, to;
ba >> type;
// PIMutexLocker locker(eth_mutex);
eth_mutex.lock();
// piCout << "dataRead lock";
if (type == 5) { // ping request
@@ -728,10 +709,8 @@ bool PIPeer::mbcastRead(uchar * data, int size) {
bool PIPeer::sendToNeighbour(PIPeer::PeerInfo * peer, const PIByteArray & ba) {
//if (peer->_neth == 0) return false;
PIEthernet::Address addr = peer->fastestAddress();
//piCout << "[PIPeer] sendToNeighbour" << peer->name << addr << ba.size_s() << "bytes ...";
//bool ok = peer->_neth->send(peer->_naddress, ba.data(), ba.size_s());
send_mutex.lock();
bool ok = eth_send.send(addr, ba);
//piCout << "[PIPeer] sendToNeighbour" << (ok ? "ok" : "fail");
@@ -745,17 +724,11 @@ void PIPeer::sendMBcast(const PIByteArray & ba) {
send_mc_mutex.lock();
// piCout << "sendMBcast" << ba.size() << "bytes ...";
piForeach (PIEthernet * e, eths_mcast) {
//errorClear();
//piCout << "send to" << e->path() << e->sendAddress();// << e->send(ba);
//piCout << PIEthernet::ethErrorString();
if (e->isOpened())
if (e->send(ba))
diag_s.sended(ba.size_s());
}
piForeach (PIEthernet * e, eths_bcast) {
//errorClear();
//piCout << "send to" << e->path() << e->sendAddress();// << e->send(ba);
//piCout << PIEthernet::ethErrorString();
if (e->isOpened())
if (e->send(ba))
diag_s.sended(ba.size_s());
@@ -864,10 +837,6 @@ bool PIPeer::openDevice() {
diag_s.reset();
//piCoutObj << "open...";
return true;
// PIMutexLocker ml(peers_mutex);
// if (trust_peer.isEmpty())
// return !peers.isEmpty();
// return hasPeer(trust_peer);
}
@@ -931,8 +900,6 @@ void PIPeer::checkNetwork() {
void PIPeer::reinit() {
no_timer = true;
// timer.stop();
// timer.clearDelimiters();
PIMutexLocker mbl(mc_mutex);
PIMutexLocker ethl(eth_mutex);
// piCout << "reinit lock";
@@ -940,14 +907,6 @@ void PIPeer::reinit() {
PIMutexLocker sl(send_mutex);
initNetwork();
sendSelfInfo();
// eth_send.close();
// eth_lo.stopThreadedRead();
// eth_lo.close();
// eth_send.init();
// eth_send.open();
// eth_lo.startThreadedRead();
// timer.addDelimiter(5);
// timer.start(1000);
no_timer = false;
if (!sync_timer.isRunning()) sync_timer.start(1000);
}

View File

@@ -47,7 +47,6 @@ public:
struct PeerAddress {
PeerAddress(const PIEthernet::Address & a = PIEthernet::Address(), const PIEthernet::Address & m = PIEthernet::Address("255.255.255.0"));
bool isAvailable() const {return ping > 0;}
//inline const Address & operator =(const Address & v) {address = v.address; netmask = v.netmask; piCout << "!!!!!!!!!" << last_ping; return *this;}
PIEthernet::Address address;
PIEthernet::Address netmask;
double ping; // ms

View File

@@ -16,6 +16,7 @@
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 "piincludes_p.h"
#include "piserial.h"
#include "piconfig.h"
@@ -627,16 +628,6 @@ void PISerial::applySettings() {
PRIVATE->desc.Parity = params[PISerial::ParityOdd] ? 1 : 2;
}
PRIVATE->desc.StopBits = params[PISerial::TwoStopBits] ? TWOSTOPBITS : ONESTOPBIT;
/*PRIVATE->desc.fOutxCtsFlow = 0;
PRIVATE->desc.fOutxDsrFlow = 0;
PRIVATE->desc.fDtrControl = 0;
PRIVATE->desc.fRtsControl = 0;
PRIVATE->desc.fInX = 0;
PRIVATE->desc.fOutX = 0;
PRIVATE->desc.fBinary = 1;
PRIVATE->desc.fAbortOnError = 0;
PRIVATE->desc.fNull = 0;*/
if (SetCommState(PRIVATE->hCom, &PRIVATE->desc) == -1) {
piCoutObj << "Unable to set comm state for \"" << path() << "\"";
return;
@@ -704,7 +695,6 @@ int PISerial::readDevice(void * read_to, int max_size) {
if (!canRead()) return -1;
if (sending) return -1;
// piCoutObj << "com event ...";
//WaitCommEvent(PRIVATE->hCom, 0, 0);
//piCoutObj << "read ..." << PRIVATE->hCom;
ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0);
DWORD err = GetLastError();
@@ -729,12 +719,6 @@ int PISerial::writeDevice(const void * data, int max_size) {
return -1;
}
#ifdef WINDOWS
// if (block_write != wait) {
// block_write = wait;
// piCoutObj << "set timeout ...";
// setReadIsBlocking(block_read);
// piCoutObj << "set timeout ok";
// }
DWORD wrote;
// piCoutObj << "send ...";// << max_size;// << ": " << PIString((char*)data, max_size);
sending = true;
@@ -943,24 +927,6 @@ PIVector<PISerial::DeviceInfo> PISerial::availableDevicesInfo(bool test) {
PIVector<DeviceInfo> ret;
DeviceInfo di;
#ifdef WINDOWS
/*HKEY key = 0;
RegOpenKey(HKEY_LOCAL_MACHINE, (LPCTSTR)"HARDWARE\\DEVICEMAP\\SERIALCOMM", &key);
if (key != 0) {
char name[1024], data[1024];
DWORD index = 0;
LONG res = ERROR_SUCCESS;
while (res != ERROR_NO_MORE_ITEMS) {
memset(name, 0, 1024);
memset(data, 0, 1024);
DWORD name_len = 1024, data_len = 1024, type = 0;
res = RegEnumValue(key, index, (LPTSTR)name, &name_len, NULL, &type, (uchar * )data, &data_len);
if (res == ERROR_NO_MORE_ITEMS) break;
di.path = PIString(data, data_len).trim();
ret << di;
index++;
}
RegCloseKey(key);
}*/
static const GUID guids[] = {GUID_DEVINTERFACE_MODEM, GUID_DEVINTERFACE_COMPORT};
static const int guids_cnt = sizeof(guids) / sizeof(GUID);
for (int i = 0; i < guids_cnt; ++i) {
@@ -1076,17 +1042,7 @@ PIVector<PISerial::DeviceInfo> PISerial::availableDevicesInfo(bool test) {
continue;
}
bool rok = true;
#ifdef WINDOWS
/*COMMTIMEOUTS times;
times.ReadIntervalTimeout = MAXDWORD;
times.ReadTotalTimeoutConstant = 0;
times.ReadTotalTimeoutMultiplier = 0;
times.WriteTotalTimeoutConstant = 1;
times.WriteTotalTimeoutMultiplier = 0;
SetCommTimeouts(hComm, &times);
if (ReadFile(hComm, &void_, 1, &readed_, 0) == 0)
rok = GetLastError() == ;*/
#else
#ifndef WINDOWS
int void_ = 0;
fcntl(fd, F_SETFL, O_NONBLOCK);
if (::read(fd, &void_, 1) == -1)
@@ -1122,7 +1078,6 @@ void PISerial::threadedReadBufferSizeChanged() {
//piCoutObj << "b" << ss.xmit_fifo_size;
ss.xmit_fifo_size = piMaxi(threadedReadBufferSize(), 4096);
ioctl(fd, TIOCSSERIAL, &ss);
//ioctl(fd, TIOCGSERIAL, &ss);
//piCoutObj << "a" << ss.xmit_fifo_size;
#endif
}

View File

@@ -161,8 +161,6 @@ public:
void setVTime(int t) {vtime = t; applySettings();}
//! Returns device name
PIString device() const {return path();}
@@ -174,17 +172,14 @@ public:
int VTime() const {return vtime;}
//! Discard all buffered input and output data
void flush();
int read(void * read_to, int max_size) {return readDevice(read_to, max_size);}
bool read(void * read_to, int max_size, double timeout_ms);
PIString read(int size = -1, double timeout_ms = 1000.);
PIByteArray readData(int size = -1, double timeout_ms = 1000.);
//! \brief Write to device data "data" with maximum size "size" and wait for data written if "wait" is \b true.
//! \returns \b true if sended bytes count = "size"
bool send(const void * data, int size);

View File

@@ -16,6 +16,7 @@
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 "piincludes_p.h"
#include "pisharedmemory.h"
#include "pipropertystorage.h"
@@ -152,7 +153,6 @@ bool PISharedMemory::closeDevice() {
//piCoutObj << "close" << PIString(PRIVATE->name) << PRIVATE->data;
if (PRIVATE->data) munmap(PRIVATE->data, dsize);
if (PRIVATE->owner) {
//if (!PRIVATE->name.isEmpty()) {
//piCout << "unlink" << PIString(PRIVATE->name);
shm_unlink((const char *)PRIVATE->name.data());
}

View File

@@ -88,7 +88,6 @@ private:
int dsize;
PRIVATE_DECLARATION
};

View File

@@ -1,3 +1,22 @@
/*
PIP - Platform Independent Primitives
SPI
Andrey Bychkov work.a.b@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/>.
*/
#include "pispi.h"
#include "pipropertystorage.h"
#include "piincludes_p.h"

Some files were not shown because too many files have changed in this diff Show More