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) 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 # Basic
macro(gather_src DIR CPP H H_P) macro(gather_src DIR CPP H H_P)
set(CS) set(CS)
@@ -175,7 +161,6 @@ endif()
# Compiler # Compiler
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME) get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
#link_directories(${CMAKE_CURRENT_BINARY_DIR})
#message("${C_COMPILER}") #message("${C_COMPILER}")
@@ -183,10 +168,6 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
# Main lib # Main lib
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud") 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}") include_directories("${PIP_SRC_MAIN}")
set(PIP_MAIN_FOLDERS) set(PIP_MAIN_FOLDERS)
foreach(F ${PIP_FOLDERS}) foreach(F ${PIP_FOLDERS})
@@ -350,7 +331,6 @@ if(APPLE)
endif() endif()
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) 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_SYSTEM_LIBRARY_PATH}/usr/include")
#message("${ANDROID_NDK}/sysroot/usr/include") #message("${ANDROID_NDK}/sysroot/usr/include")
endif() endif()
@@ -679,9 +659,6 @@ if(LIB)
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") 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") file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else() else()
@@ -697,10 +674,6 @@ else()
endif() endif()
endif() endif()
# foreach(_T ${PIP_LIBS_TARGETS})
# apple_rpath_patch(${_T})
# endforeach()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
# Auxiliary # Auxiliary
@@ -745,27 +718,6 @@ endif()
# #
# Build Documentation # 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)) if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
include(PIPDocumentation) include(PIPDocumentation)
find_package(Doxygen) find_package(Doxygen)

View File

@@ -388,16 +388,14 @@ macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
else() else()
set(_p "${_RELPATH}/${_PATH}") set(_p "${_RELPATH}/${_PATH}")
endif() endif()
#if (EXISTS "${_p}") if ("${_p}" MATCHES ".*/$")
if ("${_p}" MATCHES ".*/$") string(LENGTH "${_p}" __sl)
string(LENGTH "${_p}" __sl) math(EXPR __sl ${__sl}-1)
math(EXPR __sl ${__sl}-1) string(SUBSTRING "${_p}" 0 ${__sl} _p)
string(SUBSTRING "${_p}" 0 ${__sl} _p) list(APPEND ${_DIR_VAR} "${_p}")
list(APPEND ${_DIR_VAR} "${_p}") else()
else() list(APPEND ${_FILE_VAR} "${_p}")
list(APPEND ${_FILE_VAR} "${_p}") endif()
endif()
#endif()
endmacro() endmacro()
set(__win_host 0) set(__win_host 0)
@@ -617,7 +615,6 @@ macro(deploy_target _T)
foreach (_L ${DEPLOY_ADD_LIBPATH}) foreach (_L ${DEPLOY_ADD_LIBPATH})
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}") set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
endforeach() endforeach()
#set(_add_search_path "${_add_search_path}")
#message("app depend ${_T} libpath ${_add_search_path}") #message("app depend ${_T} libpath ${_add_search_path}")
set(_CMD_) set(_CMD_)
set(_deployed) set(_deployed)
@@ -643,8 +640,6 @@ macro(deploy_target _T)
endif() endif()
endforeach() endforeach()
endif() 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}") set(_build "${${_T}_VERSION_BUILD}")
if (NOT "x${_build}" STREQUAL "x") if (NOT "x${_build}" STREQUAL "x")
set(_build "-${_build}") set(_build "-${_build}")
@@ -770,7 +765,6 @@ macro(deploy_target _T)
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN" COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_} ${_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 # generate deb
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION} COMMAND mkdir ${_VERB} -p ${_DESTINATION}
@@ -826,7 +820,6 @@ macro(deploy_target _T)
${_CMD_} ${_CMD_}
# generate deb # generate deb
#COMMAND cd ${_AGD} "&&" md5deep -rl * ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION} COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name} COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM VERBATIM
@@ -893,13 +886,8 @@ macro(deploy_target _T)
endif() endif()
set(_dmg_name "${_TV}_macosx_x64.dmg") 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_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) if (__mac_host)
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG}) 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() endif()
if (_ZIP_DMG) if (_ZIP_DMG)
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"") 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 ${_AGD}/Contents/Frameworks
COMMAND mkdir ${_VERB} -p ${_DESTINATION} COMMAND mkdir ${_VERB} -p ${_DESTINATION}
${_CMD_} ${_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} 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 # prepare dmg dir
COMMAND rm -rf ${_DMG} COMMAND rm -rf ${_DMG}
COMMAND mkdir ${_VERB} -p ${_DMG} COMMAND mkdir ${_VERB} -p ${_DMG}
@@ -949,8 +934,6 @@ macro(deploy_target _T)
endforeach() endforeach()
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc") set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>") 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(_AT ${_T}_lib)
set(_ATA ${_AT}_${ANDROID_ABI}) set(_ATA ${_AT}_${ANDROID_ABI})
get_target_property(_sources ${_T} SOURCES) get_target_property(_sources ${_T} SOURCES)
@@ -976,9 +959,7 @@ macro(deploy_target _T)
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew" set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat") "${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
__make_copy(_CMD_ _dir _file "${_AGD}") __make_copy(_CMD_ _dir _file "${_AGD}")
#__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/")
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}") #message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
#get_target_property(_LL ${_T} )
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}") set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
if("x${SDK_ROOT}" STREQUAL "x") if("x${SDK_ROOT}" STREQUAL "x")
set(SDK_ROOT "$ENV{ANDROID_HOME}") set(SDK_ROOT "$ENV{ANDROID_HOME}")
@@ -1059,7 +1040,6 @@ macro(deploy_target _T)
if (NOT __win_host) if (NOT __win_host)
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}") set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
endif() 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 "${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}\"" assembleDebug)
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease) set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)

View File

@@ -1,16 +1,16 @@
# Download and unpack googletest at configure time # Download and unpack googletest at configure time
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt) configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result) if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}") message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build . execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result) if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}") message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif() endif()
# Prevent overriding the parent project's compiler/linker # Prevent overriding the parent project's compiler/linker
@@ -20,12 +20,12 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines # Add googletest directly to our build. This defines
# the gtest and gtest_main targets. # the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL) EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path # The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or # dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves. # later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11) if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include") include_directories("${gtest_SOURCE_DIR}/include")
endif() endif()

View File

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

View File

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

View File

@@ -86,17 +86,11 @@ macro(pip_resources RESULT INPUT)
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE}) set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
set(${RESULT} ${${RESULT}} ${RC_OUT}) set(${RESULT} ${${RESULT}} ${RC_OUT})
set(CCM_FILES) set(CCM_FILES)
#if (ABS)
if(IS_ABSOLUTE "${INPUT}") if(IS_ABSOLUTE "${INPUT}")
set(RC_FILES "${INPUT}") set(RC_FILES "${INPUT}")
else() else()
set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}") set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
endif() endif()
#else()
# foreach(csrc ${CCM_SRC})
# list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
# endforeach()
#endif()
#message(STATUS "CCM = ${RESULT}") #message(STATUS "CCM = ${RESULT}")
if(NOT DEFINED PIP_DLL_DIR) if(NOT DEFINED PIP_DLL_DIR)
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_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/thread")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/introspection") list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/introspection")
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs) set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs)
#set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component() register_component()
set(PIP_FREERTOS ON) set(PIP_FREERTOS ON)
set(LIB OFF) set(LIB OFF)

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud Client 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud Server 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud TCP transport 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Cryptographic class using lib Sodium Compress class using zlib
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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "picompress.h" #include "picompress.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 "executor.h" #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" #include "piconditionlock.h"
#ifdef WINDOWS #ifdef WINDOWS
#include "synchapi.h" #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 "piplatform.h"
#include "piconditionvar.h" #include "piconditionvar.h"
#include "pithread.h" #include "pithread.h"

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PIP Authentication API 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Cryptographic class using lib Sodium 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 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 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" #include "piincludes_p.h"
#ifndef WINDOWS #ifndef WINDOWS
int main (int argc, char * argv[]) { int main (int argc, char * argv[]) {

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud Client 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 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 it under the terms of the GNU Lesser General Public License as published by
@@ -23,13 +23,13 @@
#ifndef PICCLOUDCLIENT_H #ifndef PICCLOUDCLIENT_H
#define PICCLOUDCLIENT_H #define PICCLOUDCLIENT_H
#include "pistring.h" #include "piiodevice.h"
class PIP_EXPORT PICloudClient { class PIP_EXPORT PICloudClient {
public: public:
//! //!
PICloudClient(); explicit PICloudClient();
private: private:

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud Server 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 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 it under the terms of the GNU Lesser General Public License as published by
@@ -23,12 +23,13 @@
#ifndef PICCLOUDSERVER_H #ifndef PICCLOUDSERVER_H
#define PICCLOUDSERVER_H #define PICCLOUDSERVER_H
#include "pistring.h" #include "piiodevice.h"
class PIP_EXPORT PICloudServer { class PIP_EXPORT PICloudServer {
public: public:
//! //!
PICloudServer(); explicit PICloudServer();
private: private:

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PICloud TCP transport 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
C++ code info structs C++ code info structs
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "picodeinfo.h" #include "picodeinfo.h"

View File

@@ -2,29 +2,29 @@
* \brief C++ code info structs * \brief C++ code info structs
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
C++ code info structs C++ code info structs
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICODEINFO_H #ifndef PICODEINFO_H
#define PICODEINFO_H #define PICODEINFO_H
#include "pistring.h" #include "pistringlist.h"
class PIVariant; class PIVariant;

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes Module includes
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICODEMODULE_H #ifndef PICODEMODULE_H

View File

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

View File

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

View File

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

View File

@@ -436,19 +436,6 @@ public:
bool server_mode, pause_; bool server_mode, pause_;
ConnectedState state; 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 { struct RemoteClient {
RemoteClient(const PIString & n = "") {name = n; state = Disconnected;} RemoteClient(const PIString & n = "") {name = n; state = Disconnected;}
PIString name; PIString name;

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes Module includes
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICONSOLEMODULE_H #ifndef PICONSOLEMODULE_H

View File

@@ -267,10 +267,8 @@ void PIKbdListener::readKeyboard() {
case MOUSE_EVENT: { case MOUSE_EVENT: {
MOUSE_EVENT_RECORD mer = ir.Event.MouseEvent; MOUSE_EVENT_RECORD mer = ir.Event.MouseEvent;
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi); GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
//height = PRIVATE->sbi.srWindow.Bottom - ;
me.modifiers = getModifiers(mer.dwControlKeyState); me.modifiers = getModifiers(mer.dwControlKeyState);
MouseButtons mb = getButtons(mer.dwButtonState); MouseButtons mb = getButtons(mer.dwButtonState);
//me.action = getButtons(mer.dwButtonState);
if (mer.dwEventFlags & MOUSE_WHEELED) { if (mer.dwEventFlags & MOUSE_WHEELED) {
memcpy((void*)(&we), (const void*)(&me), sizeof(me)); memcpy((void*)(&we), (const void*)(&me), sizeof(me));
we.action = MouseWheel; we.action = MouseWheel;
@@ -317,16 +315,6 @@ void PIKbdListener::readKeyboard() {
piMSleep(10); piMSleep(10);
return; 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 #else
tcsetattr(0, TCSANOW, &PRIVATE->tterm); tcsetattr(0, TCSANOW, &PRIVATE->tterm);
PRIVATE->ret = read(0, rc, 8); PRIVATE->ret = read(0, rc, 8);

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Console output/input Console output/input
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piscreen.h" #include "piscreen.h"
#include "piincludes_p.h" #include "piincludes_p.h"
@@ -162,7 +162,6 @@ void PIScreen::SystemConsole::print() {
///cells[mouse_y][mouse_x].format.flags ^= Inverse; ///cells[mouse_y][mouse_x].format.flags ^= Inverse;
} }
#ifdef WINDOWS #ifdef WINDOWS
//static int cnt = 0;
PRIVATE->srect = PRIVATE->sbi.srWindow; PRIVATE->srect = PRIVATE->sbi.srWindow;
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1; int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
for (int j = 0; j < height; ++j) { for (int j = 0; j < height; ++j) {
@@ -189,11 +188,8 @@ void PIScreen::SystemConsole::print() {
Cell & c(cells[j + dy0][i + dx0]); Cell & c(cells[j + dy0][i + dx0]);
PRIVATE->chars[k].Char.UnicodeChar = 0; PRIVATE->chars[k].Char.UnicodeChar = 0;
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte(); PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte();
//PRIVATE->chars[k].Char.UnicodeChar = c.symbol.toInt();
PRIVATE->chars[k].Attributes = attributes(c); PRIVATE->chars[k].Attributes = attributes(c);
} }
//PRIVATE->bc.X = dx0;
//PRIVATE->bc.Y = dy0;
//piCout << "draw" << dw << dh; //piCout << "draw" << dw << dh;
PRIVATE->bs.X = dw; PRIVATE->bs.X = dw;
PRIVATE->bs.Y = dh; PRIVATE->bs.Y = dh;
@@ -235,10 +231,6 @@ void PIScreen::SystemConsole::print() {
printf("%s", s.data()); printf("%s", s.data());
s.clear(); 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"); printf("\e[0m");
fflush(0); fflush(0);
@@ -420,9 +412,7 @@ PIScreen::~PIScreen() {
void PIScreen::setMouseEnabled(bool on) { void PIScreen::setMouseEnabled(bool on) {
mouse_ = on; mouse_ = on;
//lock();
console.mouse_x = console.mouse_y = -1; console.mouse_x = console.mouse_y = -1;
//unlock();
} }

View File

@@ -2,22 +2,22 @@
* \brief Console GUI class * \brief Console GUI class
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Console GUI Console GUI
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISCREEN_H #ifndef PISCREEN_H

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" #include "piscreenconsole.h"
using namespace PIScreenTypes; using namespace PIScreenTypes;

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Console output/input Console output/input
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piscreendrawer.h" #include "piscreendrawer.h"

View File

@@ -2,22 +2,22 @@
* \brief Drawer for PIScreen * \brief Drawer for PIScreen
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Drawer for PIScreen Drawer for PIScreen
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISCREENDRAWER_H #ifndef PISCREENDRAWER_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Basic PIScreen tile Basic PIScreen tile
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piscreentile.h" #include "piscreentile.h"
@@ -111,10 +111,7 @@ void PIScreenTile::setScreen(PIScreenBase * s) {
void PIScreenTile::deleteChildren() { void PIScreenTile::deleteChildren() {
//piCout << this << "deleteChildren";
piForeach (PIScreenTile * t, tiles) { piForeach (PIScreenTile * t, tiles) {
//piCout << this << " child" << t;
//t->deleteChildren();
t->parent = 0; t->parent = 0;
delete t; delete t;
} }
@@ -130,7 +127,6 @@ void PIScreenTile::setFocus() {
void PIScreenTile::drawEventInternal(PIScreenDrawer * d) { void PIScreenTile::drawEventInternal(PIScreenDrawer * d) {
if (!visible) { if (!visible) {
//d->clearRect(x, y, x + width, y + height);
return; return;
} }
d->fillRect(x_, y_, x_ + width_, y_ + height_, back_symbol, (Color)back_format.color_char, (Color)back_format.color_back, back_format.flags); 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; int cx = x_ + marginLeft, cy = y_ + marginTop;
for (int i = 0; i < tiles.size_s(); ++i) { for (int i = 0; i < tiles.size_s(); ++i) {
PIScreenTile * t(tiles[i]); PIScreenTile * t = tiles[i];
if (!t->visible || !t->needLayout()) continue; if (!t->visible || !t->needLayout()) continue;
t->x_ = cx; t->x_ = cx;
t->y_ = cy; t->y_ = cy;

View File

@@ -2,22 +2,22 @@
* \brief Basic PIScreen tile * \brief Basic PIScreen tile
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Basic PIScreen tile Basic PIScreen tile
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISCREENTILE_H #ifndef PISCREENTILE_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Various tiles for PIScreen Various tiles for PIScreen
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piscreentiles.h" #include "piscreentiles.h"
@@ -154,7 +154,6 @@ void TileList::resizeEvent(int w, int h) {
void TileList::drawEvent(PIScreenDrawer * d) { void TileList::drawEvent(PIScreenDrawer * d) {
lhei = height_ - 2; 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()); 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 (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); 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->setMaximum(piMaxi(0, content.size_s() - 1));
scroll->setValue(cur); 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; break;
case PIKbdListener::MouseButtonDblClick: case PIKbdListener::MouseButtonDblClick:
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return)); keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
//raiseEvent(TileEvent(RowPressed, cur));
return true; return true;
default: break; default: break;
} }

View File

@@ -2,22 +2,22 @@
* \brief Various tiles for PIScreen * \brief Various tiles for PIScreen
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Various tiles for PIScreen Various tiles for PIScreen
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISCREENTILES_H #ifndef PISCREENTILES_H
@@ -196,9 +196,6 @@ class PIP_EXPORT TileInput: public PIScreenTile {
public: public:
TileInput(const PIString & n = PIString()); TileInput(const PIString & n = PIString());
virtual ~TileInput() {} virtual ~TileInput() {}
/*enum EventType {
EditFinished
};*/
PIScreenTypes::CellFormat format; PIScreenTypes::CellFormat format;
PIString text; PIString text;
int max_length; int max_length;
@@ -212,34 +209,5 @@ protected:
PITimeMeasurer tm_blink; 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 #endif // PISCREENTILES_H

View File

@@ -2,22 +2,22 @@
* \brief Types for PIScreen * \brief Types for PIScreen
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Types for PIScreen Types for PIScreen
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISCREENTYPES_H #ifndef PISCREENTYPES_H
@@ -72,14 +72,6 @@ namespace PIScreenTypes {
Vertical /** Vertical */ Vertical /** Vertical */
}; };
//! Position
enum PIP_EXPORT Position {
//Left /** Left */ ,
//Right /** Right */ ,
//Top /** Top */ ,
//Bottom /** Bottom */
};
//! Focus flags //! Focus flags
enum PIP_EXPORT FocusFlag { enum PIP_EXPORT FocusFlag {
CanHasFocus /** Tile can has focus */ = 0x1, 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;} 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 #endif // PISCREENTYPES_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Virtual terminal Virtual terminal
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes_p.h" #include "piincludes_p.h"
#include "piterminal.h" #include "piterminal.h"

View File

@@ -2,22 +2,22 @@
* \brief Virtual terminal * \brief Virtual terminal
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Virtual terminal Virtual terminal
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PITERMINAL_H #ifndef PITERMINAL_H

View File

@@ -1,23 +1,22 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Generic containers Generic containers
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// * This class based on std::vector, expanding his functionality
/** \class PIVector /** \class PIVector
* \brief Dynamic array of any type * \brief Dynamic array of any type

View File

@@ -5,22 +5,22 @@
* to use them * to use them
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Base for generic containers Base for generic containers
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICONTAINERS_H #ifndef PICONTAINERS_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICONTAINERSMODULE_H #ifndef PICONTAINERSMODULE_H

View File

@@ -6,7 +6,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Dynamic array of any type 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 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 it under the terms of the GNU Lesser General Public License as published by
@@ -97,7 +97,6 @@ public:
size_t pos; size_t pos;
public: public:
inline const_iterator(): parent(0), pos(0) {} inline const_iterator(): parent(0), pos(0) {}
//inline T & operator *() {return (*parent)[pos];}
inline const T & operator *() const {return (*parent)[pos];} inline const T & operator *() const {return (*parent)[pos];}
inline void operator ++() {++pos;} inline void operator ++() {++pos;}
inline void operator ++(int) {++pos;} inline void operator ++(int) {++pos;}
@@ -133,7 +132,6 @@ public:
size_t pos; size_t pos;
public: public:
inline const_reverse_iterator(): parent(0), pos(0) {} inline const_reverse_iterator(): parent(0), pos(0) {}
//inline T & operator *() {return (*parent)[pos];}
inline const T & operator *() const {return (*parent)[pos];} inline const T & operator *() const {return (*parent)[pos];}
inline void operator ++() {--pos;} inline void operator ++() {--pos;}
inline void operator ++(int) {--pos;} inline void operator ++(int) {--pos;}

View File

@@ -4,22 +4,22 @@
* This file declares PIMap * This file declares PIMap
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Associative array with custom types of key and value Associative array with custom types of key and value
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIMAP_H #ifndef PIMAP_H
@@ -201,11 +201,6 @@ public:
if (other.isEmpty()) return *this; if (other.isEmpty()) return *this;
if (other.size() == 1) {insert(other.pim_index[0].key, other.pim_content[0]); 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;} 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) 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]); insert(other.pim_index[i].key, other.pim_content[other.pim_index[i].index]);
return *this; 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 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;} 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> & 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> & 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> & remove(const Key & key) {return removeOne(key);}
PIMap<Key, T> & erase(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) { PIMap<Key, T> & insert(const Key & key, const T & value) {
//MapIndex * i = _find(key);
bool f(false); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
//piCout << "insert key=" << key << "found=" << f << "index=" << i << "value=" << value; //piCout << "insert key=" << key << "found=" << f << "index=" << i << "value=" << value;
@@ -239,11 +231,9 @@ public:
} else { } else {
pim_content.push_back(value); pim_content.push_back(value);
pim_index.insert(i, MapIndex(key, pim_content.size() - 1)); pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
//_sort();
} }
return *this; 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];} 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;} 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_;} 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);} void _sort() {piQuickSort<MapIndex>(pim_index.data(), pim_index.size_s() - 1);}
ssize_t _find(const Key & k, bool & found) const { 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()) { if (pim_index.isEmpty()) {
found = false; found = false;
return 0; return 0;
@@ -325,62 +309,8 @@ protected:
PIVector<T> pim_content; PIVector<T> pim_content;
PIDeque<MapIndex> pim_index; 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 #else

View File

@@ -4,22 +4,22 @@
* This file declare PIQueue * This file declare PIQueue
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Queue container Queue container
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIQUEUE_H #ifndef PIQUEUE_H

View File

@@ -4,22 +4,22 @@
* This file declare PISet * This file declare PISet
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Set container Set container
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISET_H #ifndef PISET_H
@@ -59,27 +59,17 @@ public:
//! Contructs set from vector of elements //! Contructs set from vector of elements
PISet(const PIVector<T> & values) { PISet(const PIVector<T> & values) {
if (values.isEmpty()) return; 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) { 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::insert(values[i], 0);
} }
//_CSet::_sort();
} }
//! Contructs set from deque of elements //! Contructs set from deque of elements
PISet(const PIDeque<T> & values) { PISet(const PIDeque<T> & values) {
if (values.isEmpty()) return; 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) { 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::insert(values[i], 0);
} }
//_CSet::_sort();
} }
typedef T key_type; typedef T key_type;

View File

@@ -4,22 +4,22 @@
* This file declare PIStack * This file declare PIStack
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Stack container Stack container
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISTACK_H #ifndef PISTACK_H

View File

@@ -6,7 +6,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Dynamic array of any type 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 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 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 "pibitarray.h"
#include "picout.h" #include "picout.h"

View File

@@ -2,22 +2,22 @@
* \brief Bit array * \brief Bit array
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Bit array Bit array
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIBITARRAY_H #ifndef PIBITARRAY_H

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Byte array 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 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 it under the terms of the GNU Lesser General Public License as published by
@@ -18,7 +18,7 @@
*/ */
#include "pibytearray.h" #include "pibytearray.h"
#include "pistring.h" #include "pistringlist.h"
#include <iostream> #include <iostream>
/*! \class PIByteArray /*! \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__(bool)
__PIBYTEARRAY_SIMPLE_TYPE__(char) __PIBYTEARRAY_SIMPLE_TYPE__(char)
//__PIBYTEARRAY_SIMPLE_TYPE__(uchar)
__PIBYTEARRAY_SIMPLE_TYPE__(short) __PIBYTEARRAY_SIMPLE_TYPE__(short)
__PIBYTEARRAY_SIMPLE_TYPE__(ushort) __PIBYTEARRAY_SIMPLE_TYPE__(ushort)
__PIBYTEARRAY_SIMPLE_TYPE__(int) __PIBYTEARRAY_SIMPLE_TYPE__(int)

View File

@@ -2,22 +2,22 @@
* \brief Unicode char * \brief Unicode char
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Unicode char 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes_p.h" #include "piincludes_p.h"
@@ -75,7 +75,6 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t
if (ret <= 0) return 0; if (ret <= 0) return 0;
if (taken) *taken = ret; if (taken) *taken = ret;
return buffer; return buffer;
//printf("request %d\n", sz);
# else # else
wchar_t wc(0); wchar_t wc(0);
mbtowc(0, 0, 0); // reset mbtowc mbtowc(0, 0, 0); // reset mbtowc
@@ -378,10 +377,7 @@ PICout operator <<(PICout s, const PIChar & v) {
} else } else
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
//if (PICout::isBufferActive())
s << v.toSystem(); s << v.toSystem();
//else
// s << v.toConsole1Byte();
#else #else
{ {
char tc[8]; char tc[8];

View File

@@ -2,22 +2,22 @@
* \brief Unicode char * \brief Unicode char
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Unicode char 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICHAR_H #ifndef PICHAR_H
@@ -57,37 +57,14 @@ public:
//! Contructs symbol from no more than 4 bytes of string //! Contructs symbol from no more than 4 bytes of string
PIChar(const char * c, int * bytes = 0); 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 //! Copy operator
PIChar & operator =(const char v) {ch = v; return *this;} 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 //! Compare operator
bool operator ==(const PIChar & o) const; 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 //! Compare operator
bool operator !=(const PIChar & o) const {return !(o == *this);} 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 //! Compare operator
bool operator >(const PIChar & o) const; 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" #include "pichunkstream.h"
/*! \class PIChunkStream /*! \class PIChunkStream
@@ -99,7 +118,6 @@ uint PIChunkStream::readVInt(PIByteArray & s) {
for (abc = 0; abc < 3; ++abc) { for (abc = 0; abc < 3; ++abc) {
uchar mask = (0x80 >> abc); uchar mask = (0x80 >> abc);
if ((bytes[0] & mask) == mask) { if ((bytes[0] & mask) == mask) {
//if (s.isEmpty()) return 0;
bytes[0] &= (mask - 1); bytes[0] &= (mask - 1);
s >> bytes[abc + 1]; s >> bytes[abc + 1];
} else break; } else break;

View File

@@ -2,22 +2,22 @@
* \brief Binary markup serializator * \brief Binary markup serializator
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Binary markup serializator Binary markup serializator
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICHUNKSTREAM_H #ifndef PICHUNKSTREAM_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Command-Line Parser Command-Line Parser
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "picli.h" #include "picli.h"

View File

@@ -2,22 +2,22 @@
* \brief Command-Line parser * \brief Command-Line parser
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Command-Line Parser Command-Line Parser
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICLI_H #ifndef PICLI_H

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" #include "picollection.h"

View File

@@ -2,22 +2,22 @@
* \brief Custom elements collection * \brief Custom elements collection
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Peer - named I/O ethernet node, forming self-organized peering network Peer - named I/O ethernet node, forming self-organized peering network
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICOLLECTION_H #ifndef PICOLLECTION_H
@@ -72,7 +72,6 @@ public:
protected: protected:
struct Group { struct Group {
Group(const PIString & name_ = PIString()) {name = name_;} Group(const PIString & name_ = PIString()) {name = name_;}
//~Group() {piCout << "delete group" << name << this; piForeach (const PIObject * o, elements) delete o; elements.clear();}
PIString name; PIString name;
PIVector<const PIObject * > elements; PIVector<const PIObject * > elements;
}; };

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICOREMODULE_H #ifndef PICOREMODULE_H
@@ -22,7 +22,6 @@
#include "picollection.h" #include "picollection.h"
#include "piobject.h" #include "piobject.h"
#include "pistatemachine.h"
#include "pitime.h" #include "pitime.h"
#include "picli.h" #include "picli.h"
#include "pichunkstream.h" #include "pichunkstream.h"

View File

@@ -226,13 +226,6 @@ PICout PICout::operator <<(const PICoutAction v) {
if (isOutputDeviceActive(StdOut)) { if (isOutputDeviceActive(StdOut)) {
#ifdef WINDOWS #ifdef WINDOWS
/// TODO : wondows ClearScreen !!! /// 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 #else
printf("\e[H\e[J"); printf("\e[H\e[J");
#endif #endif
@@ -262,14 +255,11 @@ PICout PICout::operator <<(const PICoutAction v) {
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (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_)) #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 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 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;} PICout PICout::operator <<(const char v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}

View File

@@ -2,22 +2,22 @@
* \brief General flags class * \brief General flags class
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
General flags class General flags class
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIFLAGS_H #ifndef PIFLAGS_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Global includes Global includes
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes.h" #include "piincludes.h"

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Minimal PIP includes Minimal PIP includes
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIINCLUDES_H #ifndef PIINCLUDES_H

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Private PIP includes 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Initialization Initialization
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes_p.h" #include "piincludes_p.h"
@@ -33,20 +33,20 @@
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
# include <winsock2.h> # include <winsock2.h>
extern FILETIME __pi_ftjan1970; extern FILETIME __pi_ftjan1970;
extern PINtQueryTimerResolution getTimerResolutionAddr; extern PINtQueryTimerResolution getTimerResolutionAddr;
extern PINtSetTimerResolution setTimerResolutionAddr; extern PINtSetTimerResolution setTimerResolutionAddr;
void __PISetTimerResolution() { void __PISetTimerResolution() {
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL) if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
return; return;
ULONG _max(0), _min(0), _cur(0); ULONG _max(0), _min(0), _cur(0);
//printf("getTimerResolution ...\n"); //printf("getTimerResolution ...\n");
LONG q = getTimerResolutionAddr(&_max, &_min, &_cur); LONG q = getTimerResolutionAddr(&_max, &_min, &_cur);
//printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur); //printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur);
if (q == 0) if (q == 0)
setTimerResolutionAddr(_min, TRUE, &_cur); setTimerResolutionAddr(_min, TRUE, &_cur);
//printf("setTimerResolution %lu\n", cur); //printf("setTimerResolution %lu\n", cur);
} }
#else #else
# include <pwd.h> # include <pwd.h>
# ifndef FREERTOS # ifndef FREERTOS
@@ -64,24 +64,13 @@
# include <mach/mach.h> # include <mach/mach.h>
# include <mach/clock.h> # include <mach/clock.h>
//# include <crt_externs.h> //# include <crt_externs.h>
extern clock_serv_t __pi_mac_clock; extern clock_serv_t __pi_mac_clock;
#endif #endif
#ifdef PIP_ICU #ifdef PIP_ICU
# define U_NOEXCEPT # define U_NOEXCEPT
# include <unicode/uclean.h> # include <unicode/uclean.h>
# include <unicode/ucnv.h> # include <unicode/ucnv.h>
#endif #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 #ifdef HAS_LOCALE
@@ -90,10 +79,10 @@ static locale_t currentLocale_t = 0;
PRIVATE_DEFINITION_START(PIInit) PRIVATE_DEFINITION_START(PIInit)
#ifdef WINDOWS #ifdef WINDOWS
HMODULE ntlib; HMODULE ntlib;
ULONG prev_res; ULONG prev_res;
#endif #endif
bool delete_locs; bool delete_locs;
PRIVATE_DEFINITION_END(PIInit) PRIVATE_DEFINITION_END(PIInit)
#ifndef FREERTOS #ifndef FREERTOS
@@ -133,12 +122,12 @@ PIInit::PIInit() {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
PIStringList ifpathes; PIStringList ifpathes;
ifpathes << PIStringAscii("/bin/ifconfig") << PIStringAscii("/sbin/ifconfig") ifpathes << PIStringAscii("/bin/ifconfig") << PIStringAscii("/sbin/ifconfig")
<< PIStringAscii("/usr/bin/ifconfig") << PIStringAscii("/usr/sbin/ifconfig"); << PIStringAscii("/usr/bin/ifconfig") << PIStringAscii("/usr/sbin/ifconfig");
piForeachC (PIString & i, ifpathes) piForeachC (PIString & i, ifpathes)
if (fileExists(i)) { if (fileExists(i)) {
sinfo->ifconfigPath = i; sinfo->ifconfigPath = i;
piBreak; piBreak;
} }
# else # else
// OS version // OS version
DWORD dwVersion = GetVersion(); DWORD dwVersion = GetVersion();
@@ -165,9 +154,7 @@ PIInit::PIInit() {
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution"); setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
__PISetTimerResolution(); __PISetTimerResolution();
} }
/*if (setTimerResolution) setTimerResolutionAddr(1, TRUE, &(PRIVATE->prev_res));*/
# endif # endif
//piDebug = true;
# ifdef HAS_LOCALE # ifdef HAS_LOCALE
//cout << "has locale" << endl; //cout << "has locale" << endl;
if (currentLocale_t != 0) { if (currentLocale_t != 0) {
@@ -241,12 +228,12 @@ PIInit::PIInit() {
GetSystemInfo(&sysinfo); GetSystemInfo(&sysinfo);
sinfo->processorsCount = sysinfo.dwNumberOfProcessors; sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
switch (sysinfo.wProcessorArchitecture) { switch (sysinfo.wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break; case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break; case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break; case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break; case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
case PROCESSOR_ARCHITECTURE_UNKNOWN: case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: sinfo->architecture = PIStringAscii("unknown"); break; default: sinfo->architecture = PIStringAscii("unknown"); break;
} }
int argc_(0); int argc_(0);
wchar_t ** argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_); wchar_t ** argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);
@@ -284,25 +271,25 @@ PIInit::PIInit() {
sinfo->OS_version = esp_get_idf_version(); sinfo->OS_version = esp_get_idf_version();
#endif #endif
sinfo->OS_name = sinfo->OS_name =
#ifdef WINDOWS #ifdef WINDOWS
PIStringAscii("Windows"); PIStringAscii("Windows");
#else #else
# ifdef QNX # ifdef QNX
PIStringAscii("QNX"); PIStringAscii("QNX");
# else # else
# ifdef MAC_OS # ifdef MAC_OS
PIStringAscii("MacOS"); PIStringAscii("MacOS");
# else # else
# ifdef ANDROID # ifdef ANDROID
PIStringAscii("Android"); PIStringAscii("Android");
# else # else
# ifdef FREE_BSD # ifdef FREE_BSD
PIStringAscii("FreeBSD"); PIStringAscii("FreeBSD");
# else # else
# ifdef FREERTOS # ifdef FREERTOS
PIStringAscii("FreeRTOS"); PIStringAscii("FreeRTOS");
# else # else
uns.sysname; uns.sysname;
# endif # endif
# endif # endif
# endif # endif
@@ -318,7 +305,6 @@ PIInit::~PIInit() {
PIResourcesStorage::instance()->clear(); PIResourcesStorage::instance()->clear();
#ifdef WINDOWS #ifdef WINDOWS
WSACleanup(); WSACleanup();
//if (setTimerResolution) setTimerResolutionAddr(PRIVATE->prev_res, TRUE, &(PRIVATE->prev_res));
if (PRIVATE->ntlib) FreeLibrary(PRIVATE->ntlib); if (PRIVATE->ntlib) FreeLibrary(PRIVATE->ntlib);
PRIVATE->ntlib = 0; PRIVATE->ntlib = 0;
#endif #endif
@@ -332,67 +318,66 @@ PIInit::~PIInit() {
#ifdef PIP_ICU #ifdef PIP_ICU
u_cleanup(); u_cleanup();
#endif #endif
//if (currentLocale_t != 0) freelocale(currentLocale_t);
} }
bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) { bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) {
switch (o) { switch (o) {
case ICU: return case ICU: return
#ifdef PIP_ICU #ifdef PIP_ICU
true; true;
#else #else
false; false;
#endif #endif
case USB: return case USB: return
#ifdef PIP_USB #ifdef PIP_USB
true; true;
#else #else
false; false;
#endif #endif
case STL: return case STL: return
#ifdef PIP_CONTAINERS_STL #ifdef PIP_CONTAINERS_STL
true; true;
#else #else
false; false;
#endif #endif
case Crypt: return case Crypt: return
#ifdef PIP_CRYPT #ifdef PIP_CRYPT
true; true;
#else #else
false; false;
#endif #endif
case Introspection: return case Introspection: return
#ifdef PIP_INTROSPECTION #ifdef PIP_INTROSPECTION
true; true;
#else #else
false; false;
#endif #endif
case FFTW: return case FFTW: return
#ifdef PIP_FFTW #ifdef PIP_FFTW
true; true;
#else #else
false; false;
#endif #endif
case Compress: return case Compress: return
#ifdef PIP_COMPRESS #ifdef PIP_COMPRESS
true; true;
#else #else
false; false;
#endif #endif
case OpenCL: return case OpenCL: return
#ifdef PIP_OPENCL #ifdef PIP_OPENCL
true; true;
#else #else
false; false;
#endif #endif
case Cloud: return case Cloud: return
#ifdef PIP_CLOUD #ifdef PIP_CLOUD
true; true;
#else #else
false; false;
#endif #endif
default: return false; default: return false;
} }
return false; return false;
} }

View File

@@ -2,22 +2,22 @@
* \brief Initialization * \brief Initialization
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Initialization Initialization
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIINIT_H #ifndef PIINIT_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piobject.h" #include "piobject.h"
@@ -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) { PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__), emitter_(0), thread_safe_(false), proc_event_queue(false) {
//__PIVariantInitBuiltin__();
setName(name); setName(name);
setDebug(true); setDebug(true);
mutexObjects().lock(); mutexObjects().lock();
@@ -181,14 +180,6 @@ void PIObject::piConnect(const PIString & src, const PIString & sig, const PIStr
d->connectors << s; 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 { PIStringList PIObject::scopeList() const {
PIMutexLocker ml(__meta_mutex()); PIMutexLocker ml(__meta_mutex());
@@ -580,8 +571,6 @@ bool PIObject::isPIObject(const PIObject * o) {
} }
void PIObject::dump(const PIString & line_prefix) const { void PIObject::dump(const PIString & line_prefix) const {
//printf("dump %s \"%s\"\n", className(), name().data()); //printf("dump %s \"%s\"\n", className(), name().data());
PICout(PICoutManipulators::AddNewLine) << line_prefix << "class " << className() << " (" << (const void*)this << ", \"" << name() << "\") {"; 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() { void dumpApplication() {
PIMutexLocker _ml(PIObject::mutexObjects()); PIMutexLocker _ml(PIObject::mutexObjects());
//printf("dump application ...\n"); //printf("dump application ...\n");
@@ -654,6 +641,7 @@ void dumpApplication() {
//printf("dump application done\n"); //printf("dump application done\n");
} }
#ifndef FREERTOS #ifndef FREERTOS
bool dumpApplicationToFile(const PIString & path) { bool dumpApplicationToFile(const PIString & path) {
PIFile f(path + "_tmp"); PIFile f(path + "_tmp");
@@ -672,8 +660,6 @@ bool dumpApplicationToFile(const PIString & path) {
#endif #endif
void PIObject::__MetaData::addScope(const PIString & s, uint shash) { void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
if (!scope_id.contains(shash)) { if (!scope_id.contains(shash)) {
scope_list << s; scope_list << s;
@@ -682,8 +668,6 @@ void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
} }
void PIObject::__Connection::destroy() { void PIObject::__Connection::destroy() {
#ifdef PIP_CXX11_SUPPORT #ifdef PIP_CXX11_SUPPORT
if (functor) delete functor; if (functor) delete functor;

View File

@@ -4,22 +4,22 @@
* This file declare PIObject class and associated macros * This file declare PIObject class and associated macros
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIOBJECT_H #ifndef PIOBJECT_H

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" #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,23 +1,25 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
String 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes_p.h" #include "piincludes_p.h"
#include "pistring.h" #include "pistring.h"
#include "pistringlist.h"
#ifdef PIP_ICU #ifdef PIP_ICU
# define U_NOEXCEPT # define U_NOEXCEPT
# include "unicode/ucnv.h" # include "unicode/ucnv.h"
@@ -216,7 +218,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
else base = 10; else base = 10;
} else } else
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;} if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
//v.reverse();
if (ok) *ok = true; if (ok) *ok = true;
PIVector<int> digits; PIVector<int> digits;
llong ret = 0, m = 1; llong ret = 0, m = 1;
@@ -236,14 +237,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
m *= base; m *= base;
} }
if (neg) ret = -ret; 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; return ret;
} }
@@ -494,29 +487,6 @@ PIString & PIString::operator +=(const char * str) {
PIString & PIString::operator +=(const wchar_t * str) { PIString & PIString::operator +=(const wchar_t * str) {
if (!str) return *this; 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; int i = -1;
while (str[++i]) while (str[++i])
push_back(PIChar(ushort(str[i]))); push_back(PIChar(ushort(str[i])));
@@ -589,9 +559,6 @@ PIString PIString::mid(const int start, const int len) const {
} else { } else {
if (l > length() - s) if (l > length() - s)
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(&(at(s)), l);
} }
return PIString(); return PIString();
@@ -668,8 +635,6 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
PIString & PIString::insert(int index, const PIString & str) { 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)); PIDeque<PIChar>::insert(index, *((const PIDeque<PIChar>*)&str));
return *this; return *this;
} }
@@ -1094,46 +1059,6 @@ ldouble PIString::toLDouble() const {
return atof(toNativeDecimalPoints().data()); 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) { PIString & PIString::setReadableSize(llong bytes) {
clear(); clear();
@@ -1164,20 +1089,19 @@ PIString & PIString::setReadableSize(llong bytes) {
inline char chrUpr(char c) { inline char chrUpr(char c) {
if (c >= 'a' && c <= 'z') return c + 'A' - 'a'; if (c >= 'a' && c <= 'z') return c + 'A' - 'a';
//if (c >= 'а' && c <= 'я') return c + 'А' - 'а';
return c; return c;
} }
inline char chrLwr(char c) { inline char chrLwr(char c) {
if (c >= 'A' && c <= 'Z') return c + 'a' - 'A'; if (c >= 'A' && c <= 'Z') return c + 'a' - 'A';
//if (c >= 'А' && c <= 'Я') return c + 'а' - 'А';
return c; return c;
} }
const static PIString _versionDelims_ = PIStringAscii("._-+"); const static PIString _versionDelims_ = PIStringAscii("._-+");
void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) { void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
s.trim(); s.trim();
if (s.isEmpty()) { if (s.isEmpty()) {
@@ -1220,6 +1144,7 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
//piCout << codes << strs; //piCout << codes << strs;
} }
int versionLabelValue(PIString s) { int versionLabelValue(PIString s) {
int ret = -10000; int ret = -10000;
if (s.isEmpty()) return 0; if (s.isEmpty()) return 0;
@@ -1240,6 +1165,7 @@ int versionLabelValue(PIString s) {
return ret; return ret;
} }
int versionCompare(const PIString & v0, const PIString & v1, int components) { int versionCompare(const PIString & v0, const PIString & v1, int components) {
PIStringList strs[2]; PIVector<int> codes[2]; PIStringList strs[2]; PIVector<int> codes[2];
parseVersion(v0.toLowerCase(), codes[0], strs[0]); parseVersion(v0.toLowerCase(), codes[0], strs[0]);
@@ -1291,35 +1217,9 @@ PICout operator <<(PICout s, const PIString & v) {
s.space(); s.space();
s.quote(); s.quote();
s.setControl(0, true); s.setControl(0, true);
//if (PICout::isBufferActive()) s << v.data();
s << v.data();
//else {
// s << v.dataConsole();
//}
s.restoreControl(); s.restoreControl();
s.quote(); s.quote();
return s; 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

@@ -4,22 +4,22 @@
* This file declare string and string list classes * This file declare string and string list classes
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
String 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PISTRING_H #ifndef PISTRING_H
@@ -43,14 +43,12 @@ public:
static const float ElideCenter; static const float ElideCenter;
static const float ElideRight ; 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 PIChar & c) {push_back(c); return *this;}
PIString & operator +=(const char * str); PIString & operator +=(const char * str);
PIString & operator +=(const wchar_t * 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 PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
PIString & operator +=(const PIString & str); PIString & operator +=(const PIString & str);
//PIString(const char c) {*this += c;}
PIString(const PIString & o): PIDeque<PIChar>() {*this += o;} PIString(const PIString & o): PIDeque<PIChar>() {*this += o;}
@@ -85,19 +83,6 @@ public:
/*! \brief Contructs string as sequence of symbols "c" of buffer with length "len" /*! \brief Contructs string as sequence of symbols "c" of buffer with length "len"
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */ * \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 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() {} ~PIString() {}
@@ -122,7 +107,6 @@ public:
//! Compare operator //! Compare operator
bool operator ==(const PIChar c) const {return *this == PIString(c);} bool operator ==(const PIChar c) const {return *this == PIString(c);}
//inline bool operator ==(const char c) const {return *this == PIString(c);}
//! Compare operator //! Compare operator
bool operator ==(const char * str) const {return *this == PIString(str);} bool operator ==(const char * str) const {return *this == PIString(str);}
@@ -132,7 +116,6 @@ public:
//! Compare operator //! Compare operator
bool operator !=(const PIChar c) const {return *this != PIString(c);} bool operator !=(const PIChar c) const {return *this != PIString(c);}
//inline bool operator !=(const char c) const {return *this != PIString(c);}
//! Compare operator //! Compare operator
bool operator !=(const char * str) const {return *this != PIString(str);} bool operator !=(const char * str) const {return *this != PIString(str);}
@@ -142,7 +125,6 @@ public:
//! Compare operator //! Compare operator
bool operator <(const PIChar c) const {return *this < PIString(c);} bool operator <(const PIChar c) const {return *this < PIString(c);}
//inline bool operator <(const char c) const {return *this < PIString(c);}
//! Compare operator //! Compare operator
bool operator <(const char * str) const {return *this < PIString(str);} bool operator <(const char * str) const {return *this < PIString(str);}
@@ -152,7 +134,6 @@ public:
//! Compare operator //! Compare operator
bool operator >(const PIChar c) const {return *this > PIString(c);} bool operator >(const PIChar c) const {return *this > PIString(c);}
//inline bool operator >(const char c) const {return *this > PIString(c);}
//! Compare operator //! Compare operator
bool operator >(const char * str) const {return *this > PIString(str);} bool operator >(const char * str) const {return *this > PIString(str);}
@@ -162,7 +143,6 @@ public:
//! Compare operator //! Compare operator
bool operator <=(const PIChar c) const {return *this <= PIString(c);} bool operator <=(const PIChar c) const {return *this <= PIString(c);}
//inline bool operator <=(const char c) const {return *this <= PIString(c);}
//! Compare operator //! Compare operator
bool operator <=(const char * str) const {return *this <= PIString(str);} bool operator <=(const char * str) const {return *this <= PIString(str);}
@@ -172,29 +152,13 @@ public:
//! Compare operator //! Compare operator
bool operator >=(const PIChar c) const {return *this >= PIString(c);} bool operator >=(const PIChar c) const {return *this >= PIString(c);}
//inline bool operator >=(const char c) const {return *this >= PIString(c);}
//! Compare operator //! Compare operator
bool operator >=(const char * str) const {return *this >= PIString(str);} 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 /*! \brief Append string "str" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIString) */ * \details Example: \snippet pistring.cpp PIString::<<(PIString) */
PIString & operator <<(const PIString & str) {*this += str; return *this;} 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 /*! \brief Append symbol "c" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */ * \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
@@ -633,8 +597,6 @@ public:
//! \details Example: \snippet pistring.cpp PIString::toFloat //! \details Example: \snippet pistring.cpp PIString::toFloat
ldouble toLDouble() const; 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" //! \brief Set string content to numeric representation of "value" in base "base"
//! \details Example: \snippet pistring.cpp PIString::setNumber //! \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;} 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 //! \details Example: \snippet pistring.cpp PIString::setReadableSize
PIString & setReadableSize(llong bytes); 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" //! \brief Return string contains numeric representation of "value" in base "base"
//! \details Example: \snippet pistring.cpp PIString::fromNumber //! \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);} 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 //! \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 & 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 //! \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 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 //! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;} 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); 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();} template<> inline uint piHash(const PIString & s) {return s.hash();}

View File

@@ -5,8 +5,8 @@
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
STD for PIString 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 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 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; typedef std::basic_string<wchar_t> wstring;
#endif #endif
#include "pistring.h" #include "pistringlist.h"
inline std::string PIString2StdString(const PIString & v) { inline std::string PIString2StdString(const PIString & v) {
@@ -42,12 +42,6 @@ inline std::string PIString2StdString(const PIString & v) {
s.push_back(char(tc)); s.push_back(char(tc));
wc >>= 8; 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; 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

@@ -1,21 +1,22 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Timer Timer
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piincludes_p.h" #include "piincludes_p.h"
#include "pitime.h" #include "pitime.h"
#include "pisystemtests.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); ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U); return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U);
} }
//long t_cur = GetCurrentTime();
//return PISystemTime(t_cur / 1000, (t_cur % 1000) * 1000000);
#else #else
# ifdef MAC_OS # ifdef MAC_OS
mach_timespec_t t_cur; mach_timespec_t t_cur;

View File

@@ -2,22 +2,22 @@
* \brief Time structs * \brief Time structs
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Time structs Time structs
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PITIME_H #ifndef PITIME_H

View File

@@ -31,11 +31,6 @@
#include <windows.h> #include <windows.h>
//inline PISystemTime SYSTEMTIME2PISystemTime(SYSTEMTIME &t) {
// PISystemTime st;
//}
inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) { inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) {
PISystemTime st; PISystemTime st;
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime); 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, T &) \
__TYPEINFO_SINGLE(T, const T) \ __TYPEINFO_SINGLE(T, const T) \
__TYPEINFO_SINGLE(T, const T &) __TYPEINFO_SINGLE(T, const T &)
//__TYPEINFO_SINGLE(T, T *)
//__TYPEINFO_SINGLE(T, const T *)
class PIP_EXPORT __PIVariantInfoStorage__ { class PIP_EXPORT __PIVariantInfoStorage__ {
@@ -465,31 +463,6 @@ public:
* Otherwise returns content as type T. */ * Otherwise returns content as type T. */
template<typename T> template<typename T>
T value() const {return getAsValue<T>(*this);} 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 //! Assign operator
PIVariant & operator =(const PIVariant & v); 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 PIPointd PIVariant::value() const {return toPoint();}
template<> inline PIRectd PIVariant::value() const {return toRect();} 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 bool & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const char & 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);} template<> inline PIVariant PIVariant::fromValue(const uchar & v) {return PIVariant(v);}

View File

@@ -25,7 +25,7 @@
#ifndef PIVARIANTYPES_H #ifndef PIVARIANTYPES_H
#define PIVARIANTYPES_H #define PIVARIANTYPES_H
#include "pistring.h" #include "pistringlist.h"
class PIPropertyStorage; class PIPropertyStorage;
@@ -33,125 +33,125 @@ class PIPropertyStorage;
namespace PIVariantTypes { namespace PIVariantTypes {
/** /**
* @brief name-value pair * @brief name-value pair
*/ */
struct PIP_EXPORT Enumerator { struct PIP_EXPORT Enumerator {
Enumerator(int v = 0, const PIString & n = PIString()): value(v), name(n) {} Enumerator(int v = 0, const PIString & n = PIString()): value(v), name(n) {}
int value; int value;
PIString name; 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 {
Enum(const PIString & n = PIString()): enum_name(n) {}
PIString toString() const {return selected;} // obsolete
/** /**
* @brief Collection of PIVariantTypes::Enumerator. It's replace classic c-style enum. * @brief Find selected value.
* Contains elements with unique name and not uniqueue values. * @return selected value, otherwrise 0
*/ */
struct PIP_EXPORT Enum { int selectedValue() const;
Enum(const PIString & n = PIString()): enum_name(n) {}
PIString toString() const {return selected;} // obsolete
/** /**
* @brief Find selected value. * @brief Get selected name
* @return selected value, otherwrise 0 * @return selected name, otherwrise empty PIString
*/ */
int selectedValue() const; PIString selectedName() const {return selected;}
/** /**
* @brief Get selected name * @brief Select value if exists in Enum. If Enum contains several PIVariantTypes::Enumerator with same values,
* @return selected name, otherwrise empty PIString * first PIVariantTypes::Enumerator will selected
*/ * @param v value for selection
PIString selectedName() const {return selected;} * @return true if value exists in Enum, false otherwrise
*/
bool selectValue(int v);
/** /**
* @brief Select value if exists in Enum. If Enum contains several PIVariantTypes::Enumerator with same values, * @brief Select name if exists in enum
* first PIVariantTypes::Enumerator will selected * @param n name for selection
* @param v value for selection * @return true if name exists in Enum, false otherwrise
* @return true if value exists in Enum, false otherwrise */
*/ bool selectName(const PIString & n);
bool selectValue(int v);
/** /**
* @brief Select name if exists in enum * @brief Find PIVariantTypes::Enumerator with specific name and return it value
* @param n name for selection * @param n name for search
* @return true if name exists in Enum, false otherwrise * @return value of founded PIVariantTypes::Enumerator, 0 otherwrise
*/ */
bool selectName(const PIString & n); int value(const PIString & n) const;
/** /**
* @brief Find PIVariantTypes::Enumerator with specific name and return it value * @brief Find first PIVariantTypes::Enumerator with specific value and return it name
* @param n name for search * @param v value for search
* @return value of founded PIVariantTypes::Enumerator, 0 otherwrise * @return name of founded PIVariantTypes::Enumerator, empty string otherwrise
*/ */
int value(const PIString & n) const; PIString name(int v) const;
/** /**
* @brief Find first PIVariantTypes::Enumerator with specific value and return it name * @brief Make vector of Enum values
* @param v value for search */
* @return name of founded PIVariantTypes::Enumerator, empty string otherwrise PIVector<int> values() const;
*/
PIString name(int v) const;
/** /**
* @brief Make vector of Enum values * @brief Make vector of Enum names
*/ */
PIVector<int> values() const; PIStringList names() const;
PIString enum_name;
PIString selected;
PIVector<Enumerator> enum_list;
/** /**
* @brief Make vector of Enum names * @brief Add PIVariantTypes::Enumerator to Enum
*/ */
PIStringList names() const; Enum & operator <<(const Enumerator & v);
PIString enum_name;
PIString selected;
PIVector<Enumerator> enum_list;
/** /**
* @brief Add PIVariantTypes::Enumerator to Enum * @brief Add PIVariantTypes::Enumerator element to Enum. Element contains specific name and value more per
*/ * unit then last element. If the is no elements, contains zero value.
Enum & operator <<(const Enumerator & v); * @param v name for new PIVariantTypes::Enumerator element
*/
Enum & operator <<(const PIString & v);
/** /**
* @brief Add PIVariantTypes::Enumerator element to Enum. Element contains specific name and value more per * @brief Add PIVariantTypes::Enumerator element for each name in vector
* unit then last element. If the is no elements, contains zero value. */
* @param v name for new PIVariantTypes::Enumerator element Enum & operator <<(const PIStringList & v);
*/ };
Enum & operator <<(const PIString & v);
/** struct PIP_EXPORT File {
* @brief Add PIVariantTypes::Enumerator element for each name in vector File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
*/ PIString toString() const {return file;}
Enum & operator <<(const PIStringList & v); PIString file;
}; PIString filter;
bool is_abs;
};
struct PIP_EXPORT File { struct PIP_EXPORT Dir {
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {} Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {}
PIString toString() const {return file;} PIString toString() const {return dir;}
PIString file; PIString dir;
PIString filter; bool is_abs;
bool is_abs; };
};
struct PIP_EXPORT Dir { struct PIP_EXPORT Color {
Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {} Color(uint v = 0) {rgba = v;}
PIString toString() const {return dir;} uint rgba;
PIString dir; };
bool is_abs;
};
struct PIP_EXPORT Color { struct PIP_EXPORT IODevice {
Color(uint v = 0) {rgba = v;} IODevice();
uint rgba; void set(const PIPropertyStorage & ps);
}; PIPropertyStorage get() const;
PIString toPICout() const;
struct PIP_EXPORT IODevice { PIString prefix;
IODevice(); int mode; // PIIODevice::DeviceMode
void set(const PIPropertyStorage & ps); int options; // PIIODevice::DeviceOptions
PIPropertyStorage get() const; PIByteArray props;
PIString toPICout() const; };
PIString prefix;
int mode; // PIIODevice::DeviceMode
int options; // PIIODevice::DeviceOptions
PIByteArray props;
};
} }

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PIP Authentication API 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 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 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 //! Server event on check client password
EVENT1(passwordCheck, bool, result) EVENT1(passwordCheck, bool, result)
//EVENT_HANDLER1(void, received, PIByteArray, data);
private: private:
State disconnect(PIByteArray & ba, const PIString & error = PIString()); State disconnect(PIByteArray & ba, const PIString & error = PIString());
bool isAuthorizedKey(const PIByteArray & pkey); bool isAuthorizedKey(const PIByteArray & pkey);

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Cryptographic class using lib Sodium 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 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 it under the terms of the GNU Lesser General Public License as published by

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes 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 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 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" #include "piellipsoidmodel.h"

View File

@@ -2,22 +2,22 @@
* \brief Contains geo ellipsoid models * \brief Contains geo ellipsoid models
*/ */
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Contains geo ellipsoid models 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 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIELLIPSOIDMODEL_H #ifndef PIELLIPSOIDMODEL_H

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Module includes 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 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 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" #include "pigeoposition.h"
const double PIGeoPosition::one_cm_tolerance = 0.01; // One centimeter tolerance. 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) { PIGeoPosition &PIGeoPosition::operator=(const PIMathVectorT3d &v) {
*((PIMathVectorT3d*)(this)) = v; *((PIMathVectorT3d*)(this)) = v;
return *this; return *this;

View File

@@ -4,7 +4,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Class for geo position storage and conversions 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 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 it under the terms of the GNU Lesser General Public License as published by
@@ -141,7 +141,6 @@ public:
/// Returns as PIMathVectorT3d /// Returns as PIMathVectorT3d
const PIMathVectorT3d & vector() const {return *this;} const PIMathVectorT3d & vector() const {return *this;}
// PIGeoPosition &operator=(const PIGeoPosition & v);
PIGeoPosition &operator=(const PIMathVectorT3d & v); PIGeoPosition &operator=(const PIMathVectorT3d & v);
PIGeoPosition &operator-=(const PIGeoPosition &right); PIGeoPosition &operator-=(const PIGeoPosition &right);
PIGeoPosition &operator+=(const PIGeoPosition &right); PIGeoPosition &operator+=(const PIGeoPosition &right);

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Introspection module - base macros and types Introspection module - base macros and types
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIINTROSPECTION_BASE_H #ifndef PIINTROSPECTION_BASE_H

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Introspection module - interface for containers Introspection module - interface for containers
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "piintrospection_containers.h" #include "piintrospection_containers.h"

View File

@@ -1,20 +1,20 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Introspection module - interface for containers Introspection module - interface for containers
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify 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 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PIINTROSPECTION_CONTAINERS_H #ifndef PIINTROSPECTION_CONTAINERS_H

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