BIG deep clean
This commit is contained in:
@@ -43,20 +43,6 @@ endif()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
|
||||
# Apple crosscompiling rpath patch
|
||||
# macro(apple_rpath_patch _T)
|
||||
# if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
|
||||
# foreach(_RP ${CMAKE_INSTALL_RPATH})
|
||||
# add_custom_command(TARGET ${_T} POST_BUILD
|
||||
# COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
|
||||
# "-add_rpath" "${_RP}"
|
||||
# "$<TARGET_FILE_DIR:${_T}>/$<TARGET_FILE_NAME:${_T}>"
|
||||
# COMMENT "Add to ${_T} rpath \"${_RP}\"")
|
||||
# endforeach()
|
||||
# endif()
|
||||
# endmacro()
|
||||
|
||||
|
||||
# Basic
|
||||
macro(gather_src DIR CPP H H_P)
|
||||
set(CS)
|
||||
@@ -175,7 +161,6 @@ endif()
|
||||
|
||||
# Compiler
|
||||
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
|
||||
#link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
#message("${C_COMPILER}")
|
||||
|
||||
|
||||
@@ -183,10 +168,6 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
|
||||
|
||||
# Main lib
|
||||
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
|
||||
if(PIP_FREERTOS)
|
||||
#list(REMOVE_ITEM PIP_FOLDERS "console")
|
||||
#include_directories("${PIP_SRC_MAIN}/console")
|
||||
endif()
|
||||
include_directories("${PIP_SRC_MAIN}")
|
||||
set(PIP_MAIN_FOLDERS)
|
||||
foreach(F ${PIP_FOLDERS})
|
||||
@@ -350,7 +331,6 @@ if(APPLE)
|
||||
endif()
|
||||
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
||||
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include)
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${ANDROID_NDK}/sysroot/usr/include")
|
||||
#message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include")
|
||||
#message("${ANDROID_NDK}/sysroot/usr/include")
|
||||
endif()
|
||||
@@ -679,9 +659,6 @@ if(LIB)
|
||||
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif()
|
||||
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
# Precompiled header
|
||||
#add_custom_target(pip_pch ALL COMMAND ${CMAKE_CXX_COMPILER} -O2 -fPIC -g3 ${CMAKE_INSTALL_PREFIX}/include/pip/pip.h DEPENDS pip SOURCES ${HDRS})
|
||||
#list(APPEND HDRS "pip.h.gch")
|
||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
|
||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
else()
|
||||
@@ -697,10 +674,6 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# foreach(_T ${PIP_LIBS_TARGETS})
|
||||
# apple_rpath_patch(${_T})
|
||||
# endforeach()
|
||||
|
||||
if(NOT PIP_FREERTOS)
|
||||
|
||||
# Auxiliary
|
||||
@@ -745,27 +718,6 @@ endif()
|
||||
#
|
||||
# Build Documentation
|
||||
#
|
||||
|
||||
# find_package(Doxygen QUIET)
|
||||
# if(Doxygen_FOUND)
|
||||
# message(STATUS "Building PIP with documentation via Doxygen")
|
||||
|
||||
# #set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in)
|
||||
# set(DOXYFILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
|
||||
# #configure_file(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
|
||||
|
||||
# add_custom_target(DOC
|
||||
# COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# COMMENT "Generating API documentation with Doxygen"
|
||||
# VERBATIM)
|
||||
|
||||
# add_custom_command(TARGET DOC
|
||||
# POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/source/doc/Documentation.html ${CMAKE_SOURCE_DIR}/doc
|
||||
# )
|
||||
# install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
|
||||
# endif()
|
||||
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
include(PIPDocumentation)
|
||||
find_package(Doxygen)
|
||||
|
||||
@@ -388,16 +388,14 @@ macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
|
||||
else()
|
||||
set(_p "${_RELPATH}/${_PATH}")
|
||||
endif()
|
||||
#if (EXISTS "${_p}")
|
||||
if ("${_p}" MATCHES ".*/$")
|
||||
string(LENGTH "${_p}" __sl)
|
||||
math(EXPR __sl ${__sl}-1)
|
||||
string(SUBSTRING "${_p}" 0 ${__sl} _p)
|
||||
list(APPEND ${_DIR_VAR} "${_p}")
|
||||
else()
|
||||
list(APPEND ${_FILE_VAR} "${_p}")
|
||||
endif()
|
||||
#endif()
|
||||
if ("${_p}" MATCHES ".*/$")
|
||||
string(LENGTH "${_p}" __sl)
|
||||
math(EXPR __sl ${__sl}-1)
|
||||
string(SUBSTRING "${_p}" 0 ${__sl} _p)
|
||||
list(APPEND ${_DIR_VAR} "${_p}")
|
||||
else()
|
||||
list(APPEND ${_FILE_VAR} "${_p}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(__win_host 0)
|
||||
@@ -617,7 +615,6 @@ macro(deploy_target _T)
|
||||
foreach (_L ${DEPLOY_ADD_LIBPATH})
|
||||
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
|
||||
endforeach()
|
||||
#set(_add_search_path "${_add_search_path}")
|
||||
#message("app depend ${_T} libpath ${_add_search_path}")
|
||||
set(_CMD_)
|
||||
set(_deployed)
|
||||
@@ -643,8 +640,6 @@ macro(deploy_target _T)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
#execute_process(COMMAND "lsb_release -si" OUTPUT_VARIABLE _os_id)
|
||||
#execute_process(COMMAND "lsb_release -sr" OUTPUT_VARIABLE _os_ver)
|
||||
set(_build "${${_T}_VERSION_BUILD}")
|
||||
if (NOT "x${_build}" STREQUAL "x")
|
||||
set(_build "-${_build}")
|
||||
@@ -770,7 +765,6 @@ macro(deploy_target _T)
|
||||
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
|
||||
${_CMD_}
|
||||
|
||||
#COMMAND -l "${CMAKE_LDD}" -P xcb -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib;${_add_search_path}\"" -o ${_AGD}/usr/lib -p ${_AGD}/usr/ ${_AGD}/Contents/MacOS/${_T}
|
||||
# generate deb
|
||||
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
@@ -826,7 +820,6 @@ macro(deploy_target _T)
|
||||
${_CMD_}
|
||||
|
||||
# generate deb
|
||||
#COMMAND cd ${_AGD} "&&" md5deep -rl * ">" DEBIAN/md5sums
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
|
||||
VERBATIM
|
||||
@@ -893,13 +886,8 @@ macro(deploy_target _T)
|
||||
endif()
|
||||
set(_dmg_name "${_TV}_macosx_x64.dmg")
|
||||
set(_cmd_gen_dmg COMMAND genisoimage -quiet -V "${MACOSX_BUNDLE_BUNDLE_NAME}" -D -R -apple -no-pad -o ${_DESTINATION}/${_dmg_name} ${_DMG})
|
||||
#set(_cmd_int)
|
||||
if (__mac_host)
|
||||
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG})
|
||||
#set(_rpathes "@executable_path/../Frameworks" "@executable_path/lib" "@loader_path/../lib")
|
||||
#foreach (_r ${_rpathes})
|
||||
# set(_cmd_int ${_cmd_int} COMMAND install_name_tool -add_rpath "${_r}" \"${_AGD}/Contents/MacOS/${_T}\")
|
||||
#endforeach()
|
||||
endif()
|
||||
if (_ZIP_DMG)
|
||||
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"")
|
||||
@@ -915,10 +903,7 @@ macro(deploy_target _T)
|
||||
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Frameworks
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
${_CMD_}
|
||||
#COMMAND cp ${_ICON_FN} ${_AGD}/Contents/Resources
|
||||
#COMMAND cp -r ${_DEPLOY_DIR}/lang ${_AGD}/Contents/Resources
|
||||
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -M "${CMAKE_OTOOL}" -P cocoa,minimal -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib${_add_search_path}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_ADD_DEPS}
|
||||
#${_cmd_int}
|
||||
# prepare dmg dir
|
||||
COMMAND rm -rf ${_DMG}
|
||||
COMMAND mkdir ${_VERB} -p ${_DMG}
|
||||
@@ -949,8 +934,6 @@ macro(deploy_target _T)
|
||||
endforeach()
|
||||
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
|
||||
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>")
|
||||
#__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}/res")
|
||||
#__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}/Contents/MacOS")
|
||||
set(_AT ${_T}_lib)
|
||||
set(_ATA ${_AT}_${ANDROID_ABI})
|
||||
get_target_property(_sources ${_T} SOURCES)
|
||||
@@ -976,9 +959,7 @@ macro(deploy_target _T)
|
||||
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
|
||||
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
|
||||
__make_copy(_CMD_ _dir _file "${_AGD}")
|
||||
#__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/")
|
||||
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
#get_target_property(_LL ${_T} )
|
||||
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
|
||||
if("x${SDK_ROOT}" STREQUAL "x")
|
||||
set(SDK_ROOT "$ENV{ANDROID_HOME}")
|
||||
@@ -1059,7 +1040,6 @@ macro(deploy_target _T)
|
||||
if (NOT __win_host)
|
||||
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
#set(_CMD_ ${_CMD_} COMMAND "${SDK_ROOT}/tools/android" update project --path "\"${_AGD}\"" --target android-${ANDROID_TARGET_SDK} --name QtApp)
|
||||
set(_CMD_ ${_CMD_} COMMAND "${Qt5_BIN}/androiddeployqt" --aux-mode --android-platform ${ANDROID_PLATFORM} --output "\"${_AGD}\"" --input "\"${_out_json}\"")
|
||||
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" assembleDebug)
|
||||
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# 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
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# The gtest/gtest_main targets carry header search path
|
||||
# dependencies automatically when using CMake 2.8.11 or
|
||||
# later. Otherwise we have to add them here ourselves.
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
endif()
|
||||
@@ -12,7 +12,6 @@ if(${MINGW})
|
||||
PATH_SUFFIXES
|
||||
include)
|
||||
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
|
||||
#if(NOT ${MINGW_INCLUDE}) MINGW_INCLUDE = ${MINGW_DIR}/include
|
||||
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
|
||||
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
|
||||
if (NOT _MGW_MSG)
|
||||
|
||||
@@ -16,7 +16,6 @@ main library
|
||||
]]
|
||||
|
||||
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
|
||||
#set(_PIP_MODULES pip pip_usb pip_crypt pip_fftw)
|
||||
if(WIN32)
|
||||
find_package(MinGW REQUIRED)
|
||||
endif()
|
||||
@@ -33,10 +32,6 @@ endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
|
||||
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
|
||||
#if (DEFINED ANDROID_PLATFORM)
|
||||
# list(APPEND _PIP_INCDIR ${CMAKE_PREFIX_PATH}/include/pip)
|
||||
# list(APPEND _PIP_LIBDIR ${CMAKE_PREFIX_PATH}/lib)
|
||||
#endif()
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
|
||||
@@ -60,9 +55,6 @@ else()
|
||||
endif()
|
||||
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
|
||||
set(_pip_suffix "")
|
||||
#if(DEFINED ANDROID_PLATFORM)
|
||||
# set(_pip_suffix "_${ANDROID_ABI}")
|
||||
#endif()
|
||||
|
||||
find_library(PIP_LIBRARY pip${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_USB_LIBRARY pip_usb${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
@@ -73,11 +65,7 @@ find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR
|
||||
find_library(PIP_CONCURRENT_LIBRARY pip_concurrent${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
|
||||
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
|
||||
#if (DEFINED ANDROID_PLATFORM)
|
||||
# set(PIP_INCLUDES ${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include/pip)
|
||||
#else()
|
||||
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
|
||||
#endif()
|
||||
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
|
||||
set(__ext "")
|
||||
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
|
||||
set(__ext ".exe")
|
||||
|
||||
@@ -86,17 +86,11 @@ macro(pip_resources RESULT INPUT)
|
||||
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
|
||||
set(${RESULT} ${${RESULT}} ${RC_OUT})
|
||||
set(CCM_FILES)
|
||||
#if (ABS)
|
||||
if(IS_ABSOLUTE "${INPUT}")
|
||||
set(RC_FILES "${INPUT}")
|
||||
else()
|
||||
set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
|
||||
endif()
|
||||
#else()
|
||||
# foreach(csrc ${CCM_SRC})
|
||||
# list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
|
||||
# endforeach()
|
||||
#endif()
|
||||
#message(STATUS "CCM = ${RESULT}")
|
||||
if(NOT DEFINED PIP_DLL_DIR)
|
||||
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -16,7 +16,6 @@ list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/system")
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/thread")
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/introspection")
|
||||
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs)
|
||||
#set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
|
||||
register_component()
|
||||
set(PIP_FREERTOS ON)
|
||||
set(LIB OFF)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Client
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Server
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud TCP transport
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Cryptographic class using lib Sodium
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Compress class using zlib
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
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.
|
||||
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/>.
|
||||
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 "picompress.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
Stephan Fomenko
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piconditionlock.h"
|
||||
#ifdef WINDOWS
|
||||
#include "synchapi.h"
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
Stephan Fomenko
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piplatform.h"
|
||||
#include "piconditionvar.h"
|
||||
#include "pithread.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP Authentication API
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Cryptographic class using lib Sodium
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Terminal client for windows, used by PITerminal and pisd
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#ifndef WINDOWS
|
||||
int main (int argc, char * argv[]) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Client
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -23,13 +23,13 @@
|
||||
#ifndef PICCLOUDCLIENT_H
|
||||
#define PICCLOUDCLIENT_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "piiodevice.h"
|
||||
|
||||
|
||||
class PIP_EXPORT PICloudClient {
|
||||
public:
|
||||
//!
|
||||
PICloudClient();
|
||||
|
||||
explicit PICloudClient();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Server
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -23,12 +23,13 @@
|
||||
#ifndef PICCLOUDSERVER_H
|
||||
#define PICCLOUDSERVER_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "piiodevice.h"
|
||||
|
||||
|
||||
class PIP_EXPORT PICloudServer {
|
||||
public:
|
||||
//!
|
||||
PICloudServer();
|
||||
explicit PICloudServer();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud TCP transport
|
||||
Copyright (C) 2020 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
C++ code info structs
|
||||
PIP - Platform Independent Primitives
|
||||
C++ code info structs
|
||||
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 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.
|
||||
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/>.
|
||||
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 "picodeinfo.h"
|
||||
|
||||
@@ -2,29 +2,29 @@
|
||||
* \brief C++ code info structs
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
C++ code info structs
|
||||
PIP - Platform Independent Primitives
|
||||
C++ code info structs
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICODEINFO_H
|
||||
#define PICODEINFO_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
class PIVariant;
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICODEMODULE_H
|
||||
|
||||
@@ -207,13 +207,6 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
||||
if (c == '"' && !mlc && pc != '\'') {
|
||||
if (i > 0) if (fc[i - 1] == '\\') continue;
|
||||
cc = !cc;
|
||||
/*if (cc) ccs = i;
|
||||
if (!cc) {
|
||||
ccmn = "$" + PIString::fromNumber(cchars.size());
|
||||
cchars[ccmn] = fc.mid(ccs, i - ccs + 1);
|
||||
fc.replace(ccs, i - ccs + 1, ccmn);
|
||||
i = ccs - 1 + ccmn.size_s();
|
||||
}*/
|
||||
continue;
|
||||
}
|
||||
if (i > 0)
|
||||
@@ -227,7 +220,6 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
||||
if (fc.mid(i, 2) == "*/" && mlc) {mlc = false; fc.cutMid(mls, i - mls + 2); i = mls - 1; continue;}
|
||||
if (fc.mid(i, 2) == "//" && !mlc) {ole = fc.find('\n', i); fc.cutMid(i, ole < 0 ? -1 : ole - i); --i; continue;}
|
||||
}
|
||||
//PICout(PICoutManipulators::DefaultControls) << fc;
|
||||
pfc = procMacros(fc);
|
||||
|
||||
replaceMeta(pfc);
|
||||
@@ -374,7 +366,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
||||
Entity * e = new Entity();
|
||||
e->meta = meta;
|
||||
e->name = cur_namespace + cn;
|
||||
e->type = typename_;//(is_class ? "class" : "struct");
|
||||
e->type = typename_;
|
||||
e->has_name = has_name;
|
||||
e->parents = parents;
|
||||
e->file = cur_file;
|
||||
@@ -444,7 +436,7 @@ PIString PICodeParser::parseClass(Entity * parent, PIString & fc) {
|
||||
parseMember(ce, tmp);
|
||||
if (def) fc.takeRange("{", "}");
|
||||
else fc.takeSymbol();
|
||||
if (ps == fc.size_s()) {/*cur_namespace = prev_namespace;*/ fc.cutLeft(1);/*return false*/;}
|
||||
if (ps == fc.size_s()) {fc.cutLeft(1);}
|
||||
ps = fc.size_s();
|
||||
}
|
||||
cur_def_vis = prev_vis;
|
||||
@@ -948,8 +940,8 @@ PIString PICodeParser::procMacros(PIString fc) {
|
||||
ifcnt = 0;
|
||||
nfc.clear();
|
||||
} else {
|
||||
/*if (!*/parseDirective(line.cutLeft(1).trim())/*)*/
|
||||
;//return false; /// WARNING: now skip errors
|
||||
parseDirective(line.cutLeft(1).trim());
|
||||
//return false; /// WARNING: now skip errors
|
||||
}
|
||||
} else {
|
||||
if (grab) nfc << line << "\n";
|
||||
@@ -982,7 +974,6 @@ bool PICodeParser::parseDirective(PIString d) {
|
||||
macros << Macro(mname, d.trim(), args);
|
||||
} else { // define
|
||||
d.trim();
|
||||
//if (mname == d) d.clear();
|
||||
defines << Define(mname, d);
|
||||
evaluator.setVariable(mname, complexd_1);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ private:
|
||||
int macros_iter, anon_num;
|
||||
bool with_includes;
|
||||
PIEvaluator evaluator;
|
||||
//PIVector<Entity * > tree;
|
||||
PISet<PIString> proc_files;
|
||||
PIString cur_file, main_file;
|
||||
PIStringList includes;
|
||||
|
||||
@@ -731,14 +731,11 @@ void PIConsole::fillLabels() {
|
||||
newLine();
|
||||
}
|
||||
status();
|
||||
//couts(fstr(Normal));
|
||||
//fflush(0);
|
||||
}
|
||||
|
||||
|
||||
void PIConsole::status() {
|
||||
Tab * ctab;
|
||||
//clearLine();
|
||||
for (uint i = 0; i < tabsCount(); ++i) {
|
||||
ctab = &tabs[i];
|
||||
if (ctab->key == 0) continue;
|
||||
|
||||
@@ -436,19 +436,6 @@ public:
|
||||
bool server_mode, pause_;
|
||||
ConnectedState state;
|
||||
|
||||
/*struct RemoteData {
|
||||
RemoteData() {msg_count = msg_rec = msg_send = 0;}
|
||||
void clear() {msg_count = msg_rec = msg_send = 0; data.clear();}
|
||||
bool isEmpty() const {return msg_count == 0;}
|
||||
bool isReadyRec() const {return msg_count == msg_rec;}
|
||||
bool isReadySend() const {return msg_count == msg_send;}
|
||||
void setData(const PIByteArray & ba) {data = ba; msg_rec = msg_send = 0; msg_count = (data.size_s() - 1) / 4096 + 1;}
|
||||
PIByteArray data;
|
||||
int msg_count;
|
||||
int msg_rec;
|
||||
int msg_send;
|
||||
};*/
|
||||
|
||||
struct RemoteClient {
|
||||
RemoteClient(const PIString & n = "") {name = n; state = Disconnected;}
|
||||
PIString name;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICONSOLEMODULE_H
|
||||
|
||||
@@ -267,10 +267,8 @@ void PIKbdListener::readKeyboard() {
|
||||
case MOUSE_EVENT: {
|
||||
MOUSE_EVENT_RECORD mer = ir.Event.MouseEvent;
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||
//height = PRIVATE->sbi.srWindow.Bottom - ;
|
||||
me.modifiers = getModifiers(mer.dwControlKeyState);
|
||||
MouseButtons mb = getButtons(mer.dwButtonState);
|
||||
//me.action = getButtons(mer.dwButtonState);
|
||||
if (mer.dwEventFlags & MOUSE_WHEELED) {
|
||||
memcpy((void*)(&we), (const void*)(&me), sizeof(me));
|
||||
we.action = MouseWheel;
|
||||
@@ -317,16 +315,6 @@ void PIKbdListener::readKeyboard() {
|
||||
piMSleep(10);
|
||||
return;
|
||||
}
|
||||
/*if (lc == 0) {
|
||||
ReadConsole(hIn, &rc, 1, &(PRIVATE->ret), 0);
|
||||
//cout << "read console" << endl;
|
||||
lc = char(rc);
|
||||
}*/
|
||||
/*if (PRIVATE->ret < 0 || PRIVATE->ret > 3) return;
|
||||
lc = char(((uchar * )&rc)[PRIVATE->ret - 1]);
|
||||
for (int i = 0; i < PRIVATE->ret; ++i)
|
||||
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
|
||||
cout << endl << std::hex << rc << endl;*/
|
||||
#else
|
||||
tcsetattr(0, TCSANOW, &PRIVATE->tterm);
|
||||
PRIVATE->ret = read(0, rc, 8);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Console output/input
|
||||
PIP - Platform Independent Primitives
|
||||
Console output/input
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piscreen.h"
|
||||
#include "piincludes_p.h"
|
||||
@@ -162,7 +162,6 @@ void PIScreen::SystemConsole::print() {
|
||||
///cells[mouse_y][mouse_x].format.flags ^= Inverse;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
//static int cnt = 0;
|
||||
PRIVATE->srect = PRIVATE->sbi.srWindow;
|
||||
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
|
||||
for (int j = 0; j < height; ++j) {
|
||||
@@ -189,11 +188,8 @@ void PIScreen::SystemConsole::print() {
|
||||
Cell & c(cells[j + dy0][i + dx0]);
|
||||
PRIVATE->chars[k].Char.UnicodeChar = 0;
|
||||
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toConsole1Byte();
|
||||
//PRIVATE->chars[k].Char.UnicodeChar = c.symbol.toInt();
|
||||
PRIVATE->chars[k].Attributes = attributes(c);
|
||||
}
|
||||
//PRIVATE->bc.X = dx0;
|
||||
//PRIVATE->bc.Y = dy0;
|
||||
//piCout << "draw" << dw << dh;
|
||||
PRIVATE->bs.X = dw;
|
||||
PRIVATE->bs.Y = dh;
|
||||
@@ -235,10 +231,6 @@ void PIScreen::SystemConsole::print() {
|
||||
printf("%s", s.data());
|
||||
s.clear();
|
||||
}
|
||||
/*for (int i = 0; i < width; ++i) {
|
||||
moveTo(i, j);
|
||||
printf("%s", (formatString(cells[j][i]) + cells[j][i].symbol).data());
|
||||
}*/
|
||||
}
|
||||
printf("\e[0m");
|
||||
fflush(0);
|
||||
@@ -420,9 +412,7 @@ PIScreen::~PIScreen() {
|
||||
|
||||
void PIScreen::setMouseEnabled(bool on) {
|
||||
mouse_ = on;
|
||||
//lock();
|
||||
console.mouse_x = console.mouse_y = -1;
|
||||
//unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Console GUI class
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Console GUI
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISCREEN_H
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Tile for PIScreen with PIConsole API
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piscreenconsole.h"
|
||||
|
||||
using namespace PIScreenTypes;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Console output/input
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Console output/input
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piscreendrawer.h"
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Drawer for PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Drawer for PIScreen
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Drawer for PIScreen
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISCREENDRAWER_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piscreentile.h"
|
||||
@@ -111,10 +111,7 @@ void PIScreenTile::setScreen(PIScreenBase * s) {
|
||||
|
||||
|
||||
void PIScreenTile::deleteChildren() {
|
||||
//piCout << this << "deleteChildren";
|
||||
piForeach (PIScreenTile * t, tiles) {
|
||||
//piCout << this << " child" << t;
|
||||
//t->deleteChildren();
|
||||
t->parent = 0;
|
||||
delete t;
|
||||
}
|
||||
@@ -130,7 +127,6 @@ void PIScreenTile::setFocus() {
|
||||
|
||||
void PIScreenTile::drawEventInternal(PIScreenDrawer * d) {
|
||||
if (!visible) {
|
||||
//d->clearRect(x, y, x + width, y + height);
|
||||
return;
|
||||
}
|
||||
d->fillRect(x_, y_, x_ + width_, y_ + height_, back_symbol, (Color)back_format.color_char, (Color)back_format.color_back, back_format.flags);
|
||||
@@ -232,7 +228,7 @@ void PIScreenTile::layout() {
|
||||
}
|
||||
int cx = x_ + marginLeft, cy = y_ + marginTop;
|
||||
for (int i = 0; i < tiles.size_s(); ++i) {
|
||||
PIScreenTile * t(tiles[i]);
|
||||
PIScreenTile * t = tiles[i];
|
||||
if (!t->visible || !t->needLayout()) continue;
|
||||
t->x_ = cx;
|
||||
t->y_ = cy;
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Basic PIScreen tile
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISCREENTILE_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piscreentiles.h"
|
||||
@@ -154,7 +154,6 @@ void TileList::resizeEvent(int w, int h) {
|
||||
|
||||
void TileList::drawEvent(PIScreenDrawer * d) {
|
||||
lhei = height_ - 2;
|
||||
//int osp = piMini(3, lhei / 4);
|
||||
int is = piClampi(offset, 0, piMaxi(0, content.size_s() - 1)), ie = piClampi(offset + lhei, 0, content.size_s());
|
||||
if (is > 0) d->drawText(x_, y_, PIString(" /\\ ").repeat(width_ / 4), Green, Default, Bold);
|
||||
if (ie < content.size_s()) d->drawText(x_, y_ + height_ - 1, PIString(" \\/ ").repeat(width_ / 4), Green, Default, Bold);
|
||||
@@ -182,11 +181,6 @@ void TileList::drawEvent(PIScreenDrawer * d) {
|
||||
}
|
||||
scroll->setMaximum(piMaxi(0, content.size_s() - 1));
|
||||
scroll->setValue(cur);
|
||||
/*int cx = x_ + width_ - 1;
|
||||
d->drawLine(cx, y_ + 1, cx, y_ + height_ - 2, vert_line, Green);
|
||||
if (content.size_s() > 1)
|
||||
d->drawPixel(cx, y_ + piRound(float(cur) / (content.size_s() - 1) * (lhei - 1)) + 1, ' ', Green, Green);
|
||||
if (ie < content.size_s()) d->drawText(x_, y_ + height_ - 1, PIString(" \\/ ").repeat(width_ / 4), Green, Default, Bold);*/
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +283,6 @@ bool TileList::mouseEvent(PIKbdListener::MouseEvent me) {
|
||||
break;
|
||||
case PIKbdListener::MouseButtonDblClick:
|
||||
keyEvent(PIKbdListener::KeyEvent(PIKbdListener::Return));
|
||||
//raiseEvent(TileEvent(RowPressed, cur));
|
||||
return true;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Various tiles for PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISCREENTILES_H
|
||||
@@ -196,9 +196,6 @@ class PIP_EXPORT TileInput: public PIScreenTile {
|
||||
public:
|
||||
TileInput(const PIString & n = PIString());
|
||||
virtual ~TileInput() {}
|
||||
/*enum EventType {
|
||||
EditFinished
|
||||
};*/
|
||||
PIScreenTypes::CellFormat format;
|
||||
PIString text;
|
||||
int max_length;
|
||||
@@ -212,34 +209,5 @@ protected:
|
||||
PITimeMeasurer tm_blink;
|
||||
};
|
||||
|
||||
/*
|
||||
class PIP_EXPORT TileTabs: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileTabs, PIScreenTile)
|
||||
public:
|
||||
TileTabs(const PIString & n = PIString());
|
||||
enum EventType {
|
||||
TabChanged
|
||||
};
|
||||
struct Tab {
|
||||
Tab(const PIString & l = PIString(), int k = 0, PIScreenTile * t = 0) {
|
||||
label = l;
|
||||
key = k;
|
||||
tile = t;
|
||||
}
|
||||
PIString label;
|
||||
int key;
|
||||
PIScreenTile * tile;
|
||||
};
|
||||
PIScreenTypes::CellFormat format_tab;
|
||||
PIScreenTypes::CellFormat format_tab_selected;
|
||||
PIDeque<Tab> tabs;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
void selectTab(int index);
|
||||
int cur;
|
||||
};
|
||||
*/
|
||||
|
||||
#endif // PISCREENTILES_H
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Types for PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Types for PIScreen
|
||||
PIP - Platform Independent Primitives
|
||||
Types for PIScreen
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISCREENTYPES_H
|
||||
@@ -72,14 +72,6 @@ namespace PIScreenTypes {
|
||||
Vertical /** Vertical */
|
||||
};
|
||||
|
||||
//! Position
|
||||
enum PIP_EXPORT Position {
|
||||
//Left /** Left */ ,
|
||||
//Right /** Right */ ,
|
||||
//Top /** Top */ ,
|
||||
//Bottom /** Bottom */
|
||||
};
|
||||
|
||||
//! Focus flags
|
||||
enum PIP_EXPORT FocusFlag {
|
||||
CanHasFocus /** Tile can has focus */ = 0x1,
|
||||
@@ -150,8 +142,5 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v)
|
||||
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.format.raw_format >> v.symbol; return s;}
|
||||
|
||||
//__PICONTAINERS_SIMPLE_TYPE__(PIScreenTypes::Cell)
|
||||
//__PIBYTEARRAY_SIMPLE_TYPE__(PIScreenTypes::Cell)
|
||||
|
||||
|
||||
#endif // PISCREENTYPES_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Virtual terminal
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piterminal.h"
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Virtual terminal
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Virtual terminal
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 PITERMINAL_H
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Generic containers
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Generic containers
|
||||
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 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.
|
||||
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/>.
|
||||
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/>.
|
||||
*/
|
||||
|
||||
// * This class based on std::vector, expanding his functionality
|
||||
|
||||
/** \class PIVector
|
||||
* \brief Dynamic array of any type
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
* to use them
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
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
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICONTAINERS_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICONTAINERSMODULE_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Dynamic array of any type
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -97,7 +97,6 @@ public:
|
||||
size_t pos;
|
||||
public:
|
||||
inline const_iterator(): parent(0), pos(0) {}
|
||||
//inline T & operator *() {return (*parent)[pos];}
|
||||
inline const T & operator *() const {return (*parent)[pos];}
|
||||
inline void operator ++() {++pos;}
|
||||
inline void operator ++(int) {++pos;}
|
||||
@@ -133,7 +132,6 @@ public:
|
||||
size_t pos;
|
||||
public:
|
||||
inline const_reverse_iterator(): parent(0), pos(0) {}
|
||||
//inline T & operator *() {return (*parent)[pos];}
|
||||
inline const T & operator *() const {return (*parent)[pos];}
|
||||
inline void operator ++() {--pos;}
|
||||
inline void operator ++(int) {--pos;}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declares PIMap
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
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
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIMAP_H
|
||||
@@ -201,11 +201,6 @@ public:
|
||||
if (other.isEmpty()) return *this;
|
||||
if (other.size() == 1) {insert(other.pim_index[0].key, other.pim_content[0]); return *this;}
|
||||
if (other.size() == 2) {insert(other.pim_index[0].key, other.pim_content[0]); insert(other.pim_index[1].key, other.pim_content[1]); return *this;}
|
||||
/*pim_content << other.pim_content;
|
||||
size_t si = pim_index.size();
|
||||
for (int i = 0; i < other.pim_index.size_s(); ++i)
|
||||
pim_index << MapIndex(other.pim_index[i].key, other.pim_index[i].index + si);
|
||||
_sort();*/
|
||||
for (int i = 0; i < other.pim_index.size_s(); ++i)
|
||||
insert(other.pim_index[i].key, other.pim_content[other.pim_index[i].index]);
|
||||
return *this;
|
||||
@@ -214,11 +209,9 @@ public:
|
||||
bool operator ==(const PIMap<Key, T> & t) const {return (pim_content == t.pim_content && pim_index == t.pim_index);}
|
||||
bool operator !=(const PIMap<Key, T> & t) const {return (pim_content != t.pim_content || pim_index != t.pim_index);}
|
||||
bool contains(const Key & key) const {bool f(false); _find(key, f); return f;}
|
||||
//int etries(const T & v) const {int ec = 0; for (size_t i = 0; i < pim_size; ++i) if (v == pim_data[i]) ++ec; return ec;}
|
||||
|
||||
PIMap<Key, T> & reserve(size_t new_size) {pim_content.reserve(new_size); pim_index.reserve(new_size); return *this;}
|
||||
|
||||
//PIMap<Key, T> & removeAll(const T & v) {for (llong i = 0; i < pim_size; ++i) if (pim_data[i] == v) {remove(i); --i;} return *this;}
|
||||
PIMap<Key, T> & removeOne(const Key & key) {bool f(false); ssize_t i = _find(key, f); if (f) _remove(i); return *this;}
|
||||
PIMap<Key, T> & remove(const Key & key) {return removeOne(key);}
|
||||
PIMap<Key, T> & erase(const Key & key) {return removeOne(key);}
|
||||
@@ -230,7 +223,6 @@ public:
|
||||
}
|
||||
|
||||
PIMap<Key, T> & insert(const Key & key, const T & value) {
|
||||
//MapIndex * i = _find(key);
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
//piCout << "insert key=" << key << "found=" << f << "index=" << i << "value=" << value;
|
||||
@@ -239,11 +231,9 @@ public:
|
||||
} else {
|
||||
pim_content.push_back(value);
|
||||
pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
|
||||
//_sort();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
//const T value(const Key & key, const T & default_ = T()) const {MapIndex * i = _find(key); if (i == 0) return default_; return pim_content[i->index];}
|
||||
const T value(const Key & key, const T & default_ = T()) const {bool f(false); ssize_t i = _find(key, f); if (!f) return default_; return pim_content[pim_index[i].index];}
|
||||
PIVector<T> values() const {return pim_content;}
|
||||
Key key(const T & value_, const Key & default_ = Key()) const {for (int i = 0; i < pim_index.size_s(); ++i) if (pim_content[pim_index[i].index] == value_) return pim_index[i].key; return default_;}
|
||||
@@ -289,12 +279,6 @@ protected:
|
||||
}
|
||||
void _sort() {piQuickSort<MapIndex>(pim_index.data(), pim_index.size_s() - 1);}
|
||||
ssize_t _find(const Key & k, bool & found) const {
|
||||
/*for (size_t i = 0; i < pim_index.size(); ++i)
|
||||
if (pim_index[i].key == k) {
|
||||
return (MapIndex * )&(pim_index[i]);
|
||||
}
|
||||
return 0;*/
|
||||
//piCout << "find for" << k << pim_index.size_s();
|
||||
if (pim_index.isEmpty()) {
|
||||
found = false;
|
||||
return 0;
|
||||
@@ -325,62 +309,8 @@ protected:
|
||||
PIVector<T> pim_content;
|
||||
PIDeque<MapIndex> pim_index;
|
||||
};
|
||||
//template <typename Key, typename T> bool operator <(const typename PIMap<Key, T>::MapIndex & f, const typename PIMap<Key, T>::MapIndex & s) {return f.key < s.key;}
|
||||
//template <typename Key, typename T> bool operator >(const typename PIMap<Key, T>::MapIndex & f, const typename PIMap<Key, T>::MapIndex & s) {return f.key > s.key;}
|
||||
|
||||
|
||||
/*#define __PIMAP_SIMPLE_FUNCTIONS__(T)
|
||||
template<> inline PIMap<Key, T>::~PIMap() {dealloc(); _reset();} \
|
||||
template<> inline PIMap<Key, T> & PIMap<Key, T>::push_back(const T & v) {alloc(pim_size + 1); pim_data[pim_size - 1] = v; return *this;} \
|
||||
template<> inline PIMap<Key, T> & PIMap<Key, T>::fill(const T & f) { \
|
||||
for (size_t i = 0; i < pim_size; ++i) \
|
||||
pim_data[i] = f; \
|
||||
return *this; \
|
||||
} \
|
||||
template<> inline PIMap<Key, T> & PIMap<Key, T>::resize(size_t new_size, const T & f) { \
|
||||
if (new_size < pim_size) \
|
||||
pim_size = new_size; \
|
||||
if (new_size > pim_size) { \
|
||||
size_t os = pim_size; \
|
||||
alloc(new_size); \
|
||||
for (size_t i = os; i < new_size; ++i) pim_data[i] = f; \
|
||||
} \
|
||||
return *this; \
|
||||
} \
|
||||
template<> inline PIMap<Key, T> & PIMap<Key, T>::insert(size_t index, const T & v) { \
|
||||
alloc(pim_size + 1); \
|
||||
if (index < pim_size - 1) { \
|
||||
size_t os = pim_size - index - 1; \
|
||||
memmove(&(pim_data[index + 1]), &(pim_data[index]), os * sizeof(T)); \
|
||||
} \
|
||||
pim_data[index] = v; \
|
||||
return *this; \
|
||||
} \
|
||||
template<> inline PIMap<Key, T> & PIMap<Key, T>::remove(size_t index, size_t count) { \
|
||||
if (index + count >= pim_size) { \
|
||||
resize(index); \
|
||||
return *this; \
|
||||
} \
|
||||
size_t os = pim_size - index - count; \
|
||||
memmove(&(pim_data[index]), &(pim_data[index + count]), os * sizeof(T)); \
|
||||
pim_size -= count; \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(char)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(uchar)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(short)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(ushort)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(int)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(uint)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(long)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(ulong)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(llong)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(ullong)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(float)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(double)
|
||||
__PIMAP_SIMPLE_FUNCTIONS__(ldouble)*/
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declare PIQueue
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Queue container
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Queue container
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIQUEUE_H
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declare PISet
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Set container
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Set container
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISET_H
|
||||
@@ -59,27 +59,17 @@ public:
|
||||
//! Contructs set from vector of elements
|
||||
PISet(const PIVector<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
//_CSet::pim_content.resize(values.size_s());
|
||||
//_CSet::pim_index.resize(values.size_s());
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
//_CSet::pim_index[i].index = i;
|
||||
//_CSet::pim_index[i].key = values[i];
|
||||
_CSet::insert(values[i], 0);
|
||||
}
|
||||
//_CSet::_sort();
|
||||
}
|
||||
|
||||
//! Contructs set from deque of elements
|
||||
PISet(const PIDeque<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
//_CSet::pim_content.resize(values.size_s());
|
||||
//_CSet::pim_index.resize(values.size_s());
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
//_CSet::pim_index[i].index = i;
|
||||
//_CSet::pim_index[i].key = values[i];
|
||||
_CSet::insert(values[i], 0);
|
||||
}
|
||||
//_CSet::_sort();
|
||||
}
|
||||
|
||||
typedef T key_type;
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declare PIStack
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Stack container
|
||||
PIP - Platform Independent Primitives
|
||||
Stack container
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISTACK_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Dynamic array of any type
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Bit array
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pibitarray.h"
|
||||
#include "picout.h"
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Bit array
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Bit array
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIBITARRAY_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Byte array
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "pibytearray.h"
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
#include <iostream>
|
||||
|
||||
/*! \class PIByteArray
|
||||
|
||||
@@ -301,7 +301,6 @@ inline bool operator !=(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.s
|
||||
|
||||
__PIBYTEARRAY_SIMPLE_TYPE__(bool)
|
||||
__PIBYTEARRAY_SIMPLE_TYPE__(char)
|
||||
//__PIBYTEARRAY_SIMPLE_TYPE__(uchar)
|
||||
__PIBYTEARRAY_SIMPLE_TYPE__(short)
|
||||
__PIBYTEARRAY_SIMPLE_TYPE__(ushort)
|
||||
__PIBYTEARRAY_SIMPLE_TYPE__(int)
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Unicode char
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unicode char
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Unicode char
|
||||
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 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.
|
||||
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/>.
|
||||
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"
|
||||
@@ -75,7 +75,6 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t
|
||||
if (ret <= 0) return 0;
|
||||
if (taken) *taken = ret;
|
||||
return buffer;
|
||||
//printf("request %d\n", sz);
|
||||
# else
|
||||
wchar_t wc(0);
|
||||
mbtowc(0, 0, 0); // reset mbtowc
|
||||
@@ -378,10 +377,7 @@ PICout operator <<(PICout s, const PIChar & v) {
|
||||
} else
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
//if (PICout::isBufferActive())
|
||||
s << v.toSystem();
|
||||
//else
|
||||
// s << v.toConsole1Byte();
|
||||
#else
|
||||
{
|
||||
char tc[8];
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Unicode char
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unicode char
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Unicode char
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICHAR_H
|
||||
@@ -57,37 +57,14 @@ public:
|
||||
//! Contructs symbol from no more than 4 bytes of string
|
||||
PIChar(const char * c, int * bytes = 0);
|
||||
|
||||
//inline operator const int() {return static_cast<const int>(ch);}
|
||||
//inline operator const char() {return toAscii();}
|
||||
|
||||
//! Copy operator
|
||||
PIChar & operator =(const char v) {ch = v; return *this;}
|
||||
/*inline PIChar & operator =(const short v) {ch = v; return *this;}
|
||||
inline PIChar & operator =(const int v) {ch = v; return *this;}
|
||||
inline PIChar & operator =(const uchar v) {ch = v; return *this;}
|
||||
inline PIChar & operator =(const ushort v) {ch = v; return *this;}
|
||||
inline PIChar & operator =(const uint v) {ch = v; return *this;}*/
|
||||
|
||||
//! Compare operator
|
||||
bool operator ==(const PIChar & o) const;
|
||||
/*inline bool operator ==(const PIChar & o) const {if (o.isAscii() ^ isAscii()) return false;
|
||||
if (isAscii()) return (o.toAscii() == toAscii());
|
||||
return (o.toInt() == toInt());}
|
||||
inline bool operator ==(const char o) const {return (PIChar(o) == *this);}
|
||||
inline bool operator ==(const short o) const {return (PIChar(o) == *this);}
|
||||
inline bool operator ==(const int o) const {return (PIChar(o) == *this);}
|
||||
inline bool operator ==(const uchar o) const {return (PIChar(o) == *this);}
|
||||
inline bool operator ==(const ushort o) const {return (PIChar(o) == *this);}
|
||||
inline bool operator ==(const uint o) const {return (PIChar(o) == *this);}*/
|
||||
|
||||
//! Compare operator
|
||||
bool operator !=(const PIChar & o) const {return !(o == *this);}
|
||||
/*inline bool operator !=(const char o) const {return (PIChar(o) != *this);}
|
||||
inline bool operator !=(const short o) const {return (PIChar(o) != *this);}
|
||||
inline bool operator !=(const int o) const {return (PIChar(o) != *this);}
|
||||
inline bool operator !=(const uchar o) const {return (PIChar(o) != *this);}
|
||||
inline bool operator !=(const ushort o) const {return (PIChar(o) != *this);}
|
||||
inline bool operator !=(const uint o) const {return (PIChar(o) != *this);}*/
|
||||
|
||||
//! Compare operator
|
||||
bool operator >(const PIChar & o) const;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Binary markup serializator
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pichunkstream.h"
|
||||
|
||||
/*! \class PIChunkStream
|
||||
@@ -99,7 +118,6 @@ uint PIChunkStream::readVInt(PIByteArray & s) {
|
||||
for (abc = 0; abc < 3; ++abc) {
|
||||
uchar mask = (0x80 >> abc);
|
||||
if ((bytes[0] & mask) == mask) {
|
||||
//if (s.isEmpty()) return 0;
|
||||
bytes[0] &= (mask - 1);
|
||||
s >> bytes[abc + 1];
|
||||
} else break;
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Binary markup serializator
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
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
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICHUNKSTREAM_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Command-Line Parser
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Command-Line Parser
|
||||
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 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.
|
||||
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/>.
|
||||
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 "picli.h"
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Command-Line parser
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Command-Line Parser
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Command-Line Parser
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICLI_H
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Custom elements collection
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Peer - named I/O ethernet node, forming self-organized peering network
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICOLLECTION_H
|
||||
@@ -72,7 +72,6 @@ public:
|
||||
protected:
|
||||
struct Group {
|
||||
Group(const PIString & name_ = PIString()) {name = name_;}
|
||||
//~Group() {piCout << "delete group" << name << this; piForeach (const PIObject * o, elements) delete o; elements.clear();}
|
||||
PIString name;
|
||||
PIVector<const PIObject * > elements;
|
||||
};
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
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 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.
|
||||
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/>.
|
||||
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 PICOREMODULE_H
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "picollection.h"
|
||||
#include "piobject.h"
|
||||
#include "pistatemachine.h"
|
||||
#include "pitime.h"
|
||||
#include "picli.h"
|
||||
#include "pichunkstream.h"
|
||||
|
||||
@@ -226,13 +226,6 @@ PICout PICout::operator <<(const PICoutAction v) {
|
||||
if (isOutputDeviceActive(StdOut)) {
|
||||
#ifdef WINDOWS
|
||||
/// TODO : wondows ClearScreen !!!
|
||||
/*GetConsoleCursorInfo(__Private__::hOut, &curinfo);
|
||||
curinfo.bVisible = false;
|
||||
SetConsoleCursorInfo(__Private__::hOut, &curinfo);
|
||||
|
||||
SetConsoleCursorPosition(__Private__::hOut, ulcoord);
|
||||
FillConsoleOutputAttribute(__Private__::hOut, __Private__::dattr, width * (height + 1), ulcoord, &written);
|
||||
FillConsoleOutputCharacter(__Private__::hOut, ' ', width * (height + 1), ulcoord, &written);*/
|
||||
#else
|
||||
printf("\e[H\e[J");
|
||||
#endif
|
||||
@@ -262,14 +255,11 @@ PICout PICout::operator <<(const PICoutAction v) {
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v);\
|
||||
}\
|
||||
}
|
||||
//#define PICOUTTOTARGETS(v) {if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v); else printf("%s", (v).dataConsole());}
|
||||
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_))
|
||||
|
||||
|
||||
PICout PICout::operator <<(const char * v) {if (!act_) return *this; if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
||||
|
||||
//PICout PICout::operator <<(const std::string & v) {space(); quote(); if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << StdString2PIString(v); else std::cout << (v); quote(); return *this;}
|
||||
|
||||
PICout PICout::operator <<(const bool v) {if (!act_) return *this; space(); if (v) PICOUTTOTARGET("true") else PICOUTTOTARGET("false") return *this;}
|
||||
|
||||
PICout PICout::operator <<(const char v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief General flags class
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
General flags class
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
General flags class
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIFLAGS_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Global includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Global includes
|
||||
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 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.
|
||||
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/>.
|
||||
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.h"
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Minimal PIP includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Minimal PIP includes
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIINCLUDES_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Private PIP includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Initialization
|
||||
PIP - Platform Independent Primitives
|
||||
Initialization
|
||||
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 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.
|
||||
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/>.
|
||||
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"
|
||||
@@ -33,20 +33,20 @@
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
# include <winsock2.h>
|
||||
extern FILETIME __pi_ftjan1970;
|
||||
extern PINtQueryTimerResolution getTimerResolutionAddr;
|
||||
extern PINtSetTimerResolution setTimerResolutionAddr;
|
||||
void __PISetTimerResolution() {
|
||||
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
|
||||
return;
|
||||
ULONG _max(0), _min(0), _cur(0);
|
||||
//printf("getTimerResolution ...\n");
|
||||
LONG q = getTimerResolutionAddr(&_max, &_min, &_cur);
|
||||
//printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur);
|
||||
if (q == 0)
|
||||
setTimerResolutionAddr(_min, TRUE, &_cur);
|
||||
//printf("setTimerResolution %lu\n", cur);
|
||||
}
|
||||
extern FILETIME __pi_ftjan1970;
|
||||
extern PINtQueryTimerResolution getTimerResolutionAddr;
|
||||
extern PINtSetTimerResolution setTimerResolutionAddr;
|
||||
void __PISetTimerResolution() {
|
||||
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
|
||||
return;
|
||||
ULONG _max(0), _min(0), _cur(0);
|
||||
//printf("getTimerResolution ...\n");
|
||||
LONG q = getTimerResolutionAddr(&_max, &_min, &_cur);
|
||||
//printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur);
|
||||
if (q == 0)
|
||||
setTimerResolutionAddr(_min, TRUE, &_cur);
|
||||
//printf("setTimerResolution %lu\n", cur);
|
||||
}
|
||||
#else
|
||||
# include <pwd.h>
|
||||
# ifndef FREERTOS
|
||||
@@ -64,24 +64,13 @@
|
||||
# include <mach/mach.h>
|
||||
# include <mach/clock.h>
|
||||
//# include <crt_externs.h>
|
||||
extern clock_serv_t __pi_mac_clock;
|
||||
extern clock_serv_t __pi_mac_clock;
|
||||
#endif
|
||||
#ifdef PIP_ICU
|
||||
# define U_NOEXCEPT
|
||||
# include <unicode/uclean.h>
|
||||
# include <unicode/ucnv.h>
|
||||
#endif
|
||||
/*
|
||||
#ifdef WINDOWS
|
||||
# include <conio.h>
|
||||
# include <io.h>
|
||||
# include <windows.h>
|
||||
# include <wincon.h>
|
||||
#else
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <pthread.h>
|
||||
#endif*/
|
||||
|
||||
|
||||
#ifdef HAS_LOCALE
|
||||
@@ -90,10 +79,10 @@ static locale_t currentLocale_t = 0;
|
||||
|
||||
PRIVATE_DEFINITION_START(PIInit)
|
||||
#ifdef WINDOWS
|
||||
HMODULE ntlib;
|
||||
ULONG prev_res;
|
||||
HMODULE ntlib;
|
||||
ULONG prev_res;
|
||||
#endif
|
||||
bool delete_locs;
|
||||
bool delete_locs;
|
||||
PRIVATE_DEFINITION_END(PIInit)
|
||||
|
||||
#ifndef FREERTOS
|
||||
@@ -133,12 +122,12 @@ PIInit::PIInit() {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
PIStringList ifpathes;
|
||||
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)
|
||||
if (fileExists(i)) {
|
||||
sinfo->ifconfigPath = i;
|
||||
piBreak;
|
||||
}
|
||||
if (fileExists(i)) {
|
||||
sinfo->ifconfigPath = i;
|
||||
piBreak;
|
||||
}
|
||||
# else
|
||||
// OS version
|
||||
DWORD dwVersion = GetVersion();
|
||||
@@ -165,9 +154,7 @@ PIInit::PIInit() {
|
||||
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
||||
__PISetTimerResolution();
|
||||
}
|
||||
/*if (setTimerResolution) setTimerResolutionAddr(1, TRUE, &(PRIVATE->prev_res));*/
|
||||
# endif
|
||||
//piDebug = true;
|
||||
# ifdef HAS_LOCALE
|
||||
//cout << "has locale" << endl;
|
||||
if (currentLocale_t != 0) {
|
||||
@@ -241,12 +228,12 @@ PIInit::PIInit() {
|
||||
GetSystemInfo(&sysinfo);
|
||||
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
|
||||
switch (sysinfo.wProcessorArchitecture) {
|
||||
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
|
||||
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
|
||||
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
|
||||
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
|
||||
case PROCESSOR_ARCHITECTURE_UNKNOWN:
|
||||
default: sinfo->architecture = PIStringAscii("unknown"); break;
|
||||
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
|
||||
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
|
||||
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
|
||||
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
|
||||
case PROCESSOR_ARCHITECTURE_UNKNOWN:
|
||||
default: sinfo->architecture = PIStringAscii("unknown"); break;
|
||||
}
|
||||
int argc_(0);
|
||||
wchar_t ** argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);
|
||||
@@ -284,25 +271,25 @@ PIInit::PIInit() {
|
||||
sinfo->OS_version = esp_get_idf_version();
|
||||
#endif
|
||||
sinfo->OS_name =
|
||||
#ifdef WINDOWS
|
||||
PIStringAscii("Windows");
|
||||
#ifdef WINDOWS
|
||||
PIStringAscii("Windows");
|
||||
#else
|
||||
# ifdef QNX
|
||||
PIStringAscii("QNX");
|
||||
# ifdef QNX
|
||||
PIStringAscii("QNX");
|
||||
# else
|
||||
# ifdef MAC_OS
|
||||
PIStringAscii("MacOS");
|
||||
# ifdef MAC_OS
|
||||
PIStringAscii("MacOS");
|
||||
# else
|
||||
# ifdef ANDROID
|
||||
PIStringAscii("Android");
|
||||
# ifdef ANDROID
|
||||
PIStringAscii("Android");
|
||||
# else
|
||||
# ifdef FREE_BSD
|
||||
PIStringAscii("FreeBSD");
|
||||
# ifdef FREE_BSD
|
||||
PIStringAscii("FreeBSD");
|
||||
# else
|
||||
# ifdef FREERTOS
|
||||
PIStringAscii("FreeRTOS");
|
||||
# ifdef FREERTOS
|
||||
PIStringAscii("FreeRTOS");
|
||||
# else
|
||||
uns.sysname;
|
||||
uns.sysname;
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
@@ -318,7 +305,6 @@ PIInit::~PIInit() {
|
||||
PIResourcesStorage::instance()->clear();
|
||||
#ifdef WINDOWS
|
||||
WSACleanup();
|
||||
//if (setTimerResolution) setTimerResolutionAddr(PRIVATE->prev_res, TRUE, &(PRIVATE->prev_res));
|
||||
if (PRIVATE->ntlib) FreeLibrary(PRIVATE->ntlib);
|
||||
PRIVATE->ntlib = 0;
|
||||
#endif
|
||||
@@ -332,67 +318,66 @@ PIInit::~PIInit() {
|
||||
#ifdef PIP_ICU
|
||||
u_cleanup();
|
||||
#endif
|
||||
//if (currentLocale_t != 0) freelocale(currentLocale_t);
|
||||
}
|
||||
|
||||
|
||||
bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) {
|
||||
switch (o) {
|
||||
case ICU: return
|
||||
#ifdef PIP_ICU
|
||||
case ICU: return
|
||||
#ifdef PIP_ICU
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case USB: return
|
||||
#ifdef PIP_USB
|
||||
case USB: return
|
||||
#ifdef PIP_USB
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case STL: return
|
||||
#ifdef PIP_CONTAINERS_STL
|
||||
case STL: return
|
||||
#ifdef PIP_CONTAINERS_STL
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case Crypt: return
|
||||
#ifdef PIP_CRYPT
|
||||
case Crypt: return
|
||||
#ifdef PIP_CRYPT
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case Introspection: return
|
||||
#ifdef PIP_INTROSPECTION
|
||||
case Introspection: return
|
||||
#ifdef PIP_INTROSPECTION
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case FFTW: return
|
||||
#ifdef PIP_FFTW
|
||||
case FFTW: return
|
||||
#ifdef PIP_FFTW
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case Compress: return
|
||||
#ifdef PIP_COMPRESS
|
||||
case Compress: return
|
||||
#ifdef PIP_COMPRESS
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case OpenCL: return
|
||||
#ifdef PIP_OPENCL
|
||||
case OpenCL: return
|
||||
#ifdef PIP_OPENCL
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
case Cloud: return
|
||||
#ifdef PIP_CLOUD
|
||||
true;
|
||||
case Cloud: return
|
||||
#ifdef PIP_CLOUD
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
false;
|
||||
#endif
|
||||
default: return false;
|
||||
default: return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Initialization
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Initialization
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Initialization
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIINIT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
|
||||
PIP - Platform Independent Primitives
|
||||
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
|
||||
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 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.
|
||||
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/>.
|
||||
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 "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) {
|
||||
//__PIVariantInitBuiltin__();
|
||||
setName(name);
|
||||
setDebug(true);
|
||||
mutexObjects().lock();
|
||||
@@ -181,14 +180,6 @@ void PIObject::piConnect(const PIString & src, const PIString & sig, const PIStr
|
||||
d->connectors << s;
|
||||
}
|
||||
|
||||
/*
|
||||
PIStringList PIObject::events() {
|
||||
PIStringList l;
|
||||
for (PIMap<NamedFunction, PIString>::const_iterator i = signals_.begin(); i != signals_.end(); i++)
|
||||
l << (*i).first;
|
||||
return l;
|
||||
}
|
||||
*/
|
||||
|
||||
PIStringList PIObject::scopeList() const {
|
||||
PIMutexLocker ml(__meta_mutex());
|
||||
@@ -580,8 +571,6 @@ bool PIObject::isPIObject(const PIObject * o) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void PIObject::dump(const PIString & line_prefix) const {
|
||||
//printf("dump %s \"%s\"\n", className(), name().data());
|
||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << "class " << className() << " (" << (const void*)this << ", \"" << name() << "\") {";
|
||||
@@ -627,8 +616,6 @@ void PIObject::dump(const PIString & line_prefix) const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void dumpApplication() {
|
||||
PIMutexLocker _ml(PIObject::mutexObjects());
|
||||
//printf("dump application ...\n");
|
||||
@@ -654,6 +641,7 @@ void dumpApplication() {
|
||||
//printf("dump application done\n");
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
bool dumpApplicationToFile(const PIString & path) {
|
||||
PIFile f(path + "_tmp");
|
||||
@@ -672,8 +660,6 @@ bool dumpApplicationToFile(const PIString & path) {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
|
||||
if (!scope_id.contains(shash)) {
|
||||
scope_list << s;
|
||||
@@ -682,8 +668,6 @@ void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void PIObject::__Connection::destroy() {
|
||||
#ifdef PIP_CXX11_SUPPORT
|
||||
if (functor) delete functor;
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declare PIObject class and associated macros
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
|
||||
PIP - Platform Independent Primitives
|
||||
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIOBJECT_H
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -1,23 +1,25 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
String
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
String
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
#ifdef PIP_ICU
|
||||
# define U_NOEXCEPT
|
||||
# include "unicode/ucnv.h"
|
||||
@@ -216,7 +218,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
|
||||
else base = 10;
|
||||
} else
|
||||
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
|
||||
//v.reverse();
|
||||
if (ok) *ok = true;
|
||||
PIVector<int> digits;
|
||||
llong ret = 0, m = 1;
|
||||
@@ -236,14 +237,6 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
|
||||
m *= base;
|
||||
}
|
||||
if (neg) ret = -ret;
|
||||
/*piForeachC (PIChar & i, v) {
|
||||
if (i == PIChar('-')) {ret = -ret; continue;}
|
||||
cs = fromBaseN[int(i.toAscii())];
|
||||
cout << i << " = " << cs << endl;
|
||||
if (cs < 0 || cs >= base) return ret;
|
||||
ret += cs * m;
|
||||
m *= base;
|
||||
}*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -494,29 +487,6 @@ PIString & PIString::operator +=(const char * str) {
|
||||
|
||||
PIString & PIString::operator +=(const wchar_t * str) {
|
||||
if (!str) return *this;
|
||||
//cout << "wc" << endl;
|
||||
/*int l = 0, sz;
|
||||
char * c = new char[MB_CUR_MAX];
|
||||
while (str[l] != 0) ++l;
|
||||
for (int i = 0; i < l; ++i) {
|
||||
sz = wctomb(c, str[i]);
|
||||
switch (sz) {
|
||||
case 4:
|
||||
push_back(PIChar(*(int*)c));
|
||||
continue;
|
||||
case 3:
|
||||
push_back(PIChar(*(int*)c));
|
||||
back().ch &= 0xFFFFFF;
|
||||
continue;
|
||||
case 2:
|
||||
push_back(PIChar(*(short * )c));
|
||||
continue;
|
||||
default:
|
||||
push_back(PIChar(c[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete[] c;*/
|
||||
int i = -1;
|
||||
while (str[++i])
|
||||
push_back(PIChar(ushort(str[i])));
|
||||
@@ -589,9 +559,6 @@ PIString PIString::mid(const int start, const int len) const {
|
||||
} else {
|
||||
if (l > length() - s)
|
||||
l = length() - s;
|
||||
//for (int i = s; i < s + l; ++i)
|
||||
// str += at(i);
|
||||
// std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
|
||||
return PIString(&(at(s)), l);
|
||||
}
|
||||
return PIString();
|
||||
@@ -668,8 +635,6 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
||||
|
||||
|
||||
PIString & PIString::insert(int index, const PIString & str) {
|
||||
//uint c = str.length();
|
||||
//for (uint i = 0; i < c; ++i) insert(index + i, str[i]);
|
||||
PIDeque<PIChar>::insert(index, *((const PIDeque<PIChar>*)&str));
|
||||
return *this;
|
||||
}
|
||||
@@ -1094,46 +1059,6 @@ ldouble PIString::toLDouble() const {
|
||||
return atof(toNativeDecimalPoints().data());
|
||||
}
|
||||
|
||||
/*
|
||||
short PIString::toShort() const {
|
||||
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
||||
short v;
|
||||
if (s.left(2) == "0x") {sscanf(s.data(), "%hx", &v); return v;}
|
||||
if (s.left(1) == "0") {sscanf(s.data(), "%ho", &v); return v;}
|
||||
sscanf(s.data(), "%hd", &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
int PIString::toInt() const {
|
||||
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
||||
int v;
|
||||
if (s.left(2) == "0x") {sscanf(s.data(), "%x", &v); return v;}
|
||||
if (s.left(1) == "0") {sscanf(s.data(), "%o", &v); return v;}
|
||||
sscanf(s.data(), "%d", &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
long PIString::toLong() const {
|
||||
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
||||
long v;
|
||||
if (s.left(2) == "0x") {sscanf(s.data(), "%lx", &v); return v;}
|
||||
if (s.left(1) == "0") {sscanf(s.data(), "%lo", &v); return v;}
|
||||
sscanf(s.data(), "%ld", &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
llong PIString::toLLong() const {
|
||||
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
||||
llong v;
|
||||
if (s.left(2) == "0x") {sscanf(s.data(), "%llx", &v); return v;}
|
||||
if (s.left(1) == "0") {sscanf(s.data(), "%llo", &v); return v;}
|
||||
sscanf(s.data(), "%lld", &v);
|
||||
return v;
|
||||
}
|
||||
*/
|
||||
|
||||
PIString & PIString::setReadableSize(llong bytes) {
|
||||
clear();
|
||||
@@ -1164,20 +1089,19 @@ PIString & PIString::setReadableSize(llong bytes) {
|
||||
|
||||
inline char chrUpr(char c) {
|
||||
if (c >= 'a' && c <= 'z') return c + 'A' - 'a';
|
||||
//if (c >= 'а' && c <= 'я') return c + 'А' - 'а';
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
inline char chrLwr(char c) {
|
||||
if (c >= 'A' && c <= 'Z') return c + 'a' - 'A';
|
||||
//if (c >= 'А' && c <= 'Я') return c + 'а' - 'А';
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
const static PIString _versionDelims_ = PIStringAscii("._-+");
|
||||
|
||||
|
||||
void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
|
||||
s.trim();
|
||||
if (s.isEmpty()) {
|
||||
@@ -1220,6 +1144,7 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
|
||||
//piCout << codes << strs;
|
||||
}
|
||||
|
||||
|
||||
int versionLabelValue(PIString s) {
|
||||
int ret = -10000;
|
||||
if (s.isEmpty()) return 0;
|
||||
@@ -1240,6 +1165,7 @@ int versionLabelValue(PIString s) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int versionCompare(const PIString & v0, const PIString & v1, int components) {
|
||||
PIStringList strs[2]; PIVector<int> codes[2];
|
||||
parseVersion(v0.toLowerCase(), codes[0], strs[0]);
|
||||
@@ -1291,35 +1217,9 @@ PICout operator <<(PICout s, const PIString & v) {
|
||||
s.space();
|
||||
s.quote();
|
||||
s.setControl(0, true);
|
||||
//if (PICout::isBufferActive())
|
||||
s << v.data();
|
||||
//else {
|
||||
// s << v.dataConsole();
|
||||
//}
|
||||
s << v.data();
|
||||
s.restoreControl();
|
||||
s.quote();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PIStringList& PIStringList::removeDuplicates() {
|
||||
PIStringList l;
|
||||
PIString s;
|
||||
bool ae;
|
||||
for (int i = 0; i < size_s(); ++i) {
|
||||
ae = false;
|
||||
s = at(i);
|
||||
for (int j = 0; j < l.size_s(); ++j) {
|
||||
if (s != l[j]) continue;
|
||||
ae = true; break;
|
||||
}
|
||||
if (!ae) {
|
||||
l << s;
|
||||
continue;
|
||||
}
|
||||
remove(i);
|
||||
--i;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
* This file declare string and string list classes
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
String
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
String
|
||||
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 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.
|
||||
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/>.
|
||||
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 PISTRING_H
|
||||
@@ -43,14 +43,12 @@ public:
|
||||
static const float ElideCenter;
|
||||
static const float ElideRight ;
|
||||
|
||||
//inline PIString & operator +=(const char c) {push_back(c); return *this;}
|
||||
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
|
||||
PIString & operator +=(const char * str);
|
||||
PIString & operator +=(const wchar_t * str);
|
||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
||||
PIString & operator +=(const PIString & str);
|
||||
|
||||
//PIString(const char c) {*this += c;}
|
||||
PIString(const PIString & o): PIDeque<PIChar>() {*this += o;}
|
||||
|
||||
|
||||
@@ -86,19 +84,6 @@ public:
|
||||
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
|
||||
PIString(const int len, const PIChar & c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
|
||||
|
||||
|
||||
// PIString(const short & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const ushort & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const int & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const uint & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const long & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const ulong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const llong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const ullong & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const float & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
// PIString(const double & value): PIDeque<PIChar>() {*this = fromNumber(value);}
|
||||
|
||||
|
||||
~PIString() {}
|
||||
|
||||
|
||||
@@ -122,7 +107,6 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator ==(const PIChar c) const {return *this == PIString(c);}
|
||||
//inline bool operator ==(const char c) const {return *this == PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator ==(const char * str) const {return *this == PIString(str);}
|
||||
@@ -132,7 +116,6 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator !=(const PIChar c) const {return *this != PIString(c);}
|
||||
//inline bool operator !=(const char c) const {return *this != PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator !=(const char * str) const {return *this != PIString(str);}
|
||||
@@ -142,7 +125,6 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator <(const PIChar c) const {return *this < PIString(c);}
|
||||
//inline bool operator <(const char c) const {return *this < PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator <(const char * str) const {return *this < PIString(str);}
|
||||
@@ -152,7 +134,6 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator >(const PIChar c) const {return *this > PIString(c);}
|
||||
//inline bool operator >(const char c) const {return *this > PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator >(const char * str) const {return *this > PIString(str);}
|
||||
@@ -162,7 +143,6 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator <=(const PIChar c) const {return *this <= PIString(c);}
|
||||
//inline bool operator <=(const char c) const {return *this <= PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator <=(const char * str) const {return *this <= PIString(str);}
|
||||
@@ -172,29 +152,13 @@ public:
|
||||
|
||||
//! Compare operator
|
||||
bool operator >=(const PIChar c) const {return *this >= PIString(c);}
|
||||
//inline bool operator >=(const char c) const {return *this >= PIString(c);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
||||
|
||||
|
||||
// operator bool() const {return toBool();}
|
||||
// operator short() const {return toShort();}
|
||||
// operator ushort() const {return toUShort();}
|
||||
// operator int() const {return toInt();}
|
||||
// operator uint() const {return toUInt();}
|
||||
// operator long() const {return toLong();}
|
||||
// operator ulong() const {return toULong();}
|
||||
// operator llong() const {return toLLong();}
|
||||
// operator ullong() const {return toULLong();}
|
||||
// operator float() const {return toFloat();}
|
||||
// operator double() const {return toDouble();}
|
||||
|
||||
|
||||
/*! \brief Append string "str" at the end of string
|
||||
* \details Example: \snippet pistring.cpp PIString::<<(PIString) */
|
||||
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
||||
// inline PIString & operator <<(const char c) {*this += c; return *this;}
|
||||
|
||||
/*! \brief Append symbol "c" at the end of string
|
||||
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
|
||||
@@ -633,8 +597,6 @@ public:
|
||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
||||
ldouble toLDouble() const;
|
||||
|
||||
//inline PIString & setNumber(const char value) {clear(); *this += itos(value); return *this;}
|
||||
|
||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
||||
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
@@ -683,8 +645,6 @@ public:
|
||||
//! \details Example: \snippet pistring.cpp PIString::setReadableSize
|
||||
PIString & setReadableSize(llong bytes);
|
||||
|
||||
//inline static PIString fromNumber(const char value) {return PIString(itos(value));}
|
||||
|
||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
||||
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
||||
@@ -793,13 +753,9 @@ inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.clear(); s >>
|
||||
//! \relatesalso PIString \brief Return concatenated string
|
||||
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
|
||||
|
||||
//inline PIString operator +(const PIString & f, const char c) {PIString s(f); s.push_back(c); return s;}
|
||||
|
||||
//! \relatesalso PIString \brief Return concatenated string
|
||||
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
|
||||
|
||||
//inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
|
||||
|
||||
//! \relatesalso PIString \brief Return concatenated string
|
||||
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
|
||||
|
||||
@@ -812,79 +768,6 @@ int versionCompare(const PIString & v0, const PIString & v1, int components = 6)
|
||||
PIString versionNormalize(const PIString & v);
|
||||
|
||||
|
||||
/*!\brief Strings array class
|
||||
* \details This class is based on \a PIDeque<PIString> and
|
||||
* expand it functionality. */
|
||||
class PIP_EXPORT PIStringList: public PIDeque<PIString>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Contructs empty strings list
|
||||
PIStringList() {;}
|
||||
|
||||
~PIStringList() {;}
|
||||
|
||||
//! Contructs strings list with one string "str"
|
||||
PIStringList(const PIString & str) {push_back(str);}
|
||||
|
||||
//! Contructs empty strings list with strings "s0" and "s1"
|
||||
PIStringList(const PIString & s0, const PIString & s1) {push_back(s0); push_back(s1);}
|
||||
|
||||
//! Contructs empty strings list with strings "s0", "s1" and "s2"
|
||||
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2) {push_back(s0); push_back(s1); push_back(s2);}
|
||||
|
||||
//! Contructs empty strings list with strings "s0", "s1", "s2" and "s3"
|
||||
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2, const PIString & s3) {push_back(s0); push_back(s1); push_back(s2); push_back(s3);}
|
||||
|
||||
PIStringList(const PIStringList & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
|
||||
PIStringList(const PIVector<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
|
||||
PIStringList(const PIDeque<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
|
||||
|
||||
|
||||
//! \brief Join all strings in one with delimiter "delim" and return it
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::join
|
||||
PIString join(const PIString & delim) const {PIString s; for (uint i = 0; i < size(); ++i) {s += at(i); if (i < size() - 1) s += delim;} return s;}
|
||||
|
||||
//! \brief Remove all strings equal "value" and return this
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::removeStrings
|
||||
PIStringList & removeStrings(const PIString & value) {for (uint i = 0; i < size(); ++i) {if (at(i) == value) {remove(i); --i;}} return *this;}
|
||||
|
||||
PIStringList & remove(uint num) {PIDeque<PIString>::remove(num); return *this;}
|
||||
PIStringList & remove(uint num, uint count) {PIDeque<PIString>::remove(num, count); return *this;}
|
||||
|
||||
//! \brief Remove duplicated strings and return this
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::removeDuplicates
|
||||
PIStringList & removeDuplicates();
|
||||
|
||||
//! \brief Trim all strings
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::trim
|
||||
PIStringList & trim() {for (uint i = 0; i < size(); ++i) at(i).trim(); return *this;}
|
||||
|
||||
//! Return sum of lengths of all strings
|
||||
uint contentSize() {uint s = 0; for (uint i = 0; i < size(); ++i) s += at(i).size(); return s;}
|
||||
|
||||
//! Compare operator
|
||||
bool operator ==(const PIStringList & o) const {if (size() != o.size()) return false; for (size_t i = 0; i < size(); ++i) if (o[i] != (*this)[i]) return false; return true;}
|
||||
|
||||
//! Compare operator
|
||||
bool operator !=(const PIStringList & o) const {return !(o == (*this));}
|
||||
|
||||
PIStringList & operator =(const PIStringList & o) {PIDeque<PIString>::operator=(o); return *this;}
|
||||
|
||||
PIStringList & operator <<(const PIString & str) {append(str); return *this;}
|
||||
PIStringList & operator <<(const PIStringList & sl) {append(sl); return *this;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Output operator to PIByteArray
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s << int(v.size_s()); for (int i = 0; i < v.size_s(); ++i) s << v[i]; return s;}
|
||||
|
||||
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Input operator from PIByteArray
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
||||
|
||||
//! \relatesalso PIStringList \relatesalso PICout \brief Output operator to PICout
|
||||
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
|
||||
|
||||
template<> inline uint piHash(const PIString & s) {return s.hash();}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
STD for PIString
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
STD for PIString
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -28,7 +28,7 @@
|
||||
typedef std::basic_string<wchar_t> wstring;
|
||||
#endif
|
||||
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
|
||||
inline std::string PIString2StdString(const PIString & v) {
|
||||
@@ -42,12 +42,6 @@ inline std::string PIString2StdString(const PIString & v) {
|
||||
s.push_back(char(tc));
|
||||
wc >>= 8;
|
||||
}
|
||||
/*if (at(i).isAscii())
|
||||
s.push_back(at(i).toAscii());
|
||||
else {
|
||||
s.push_back(at(i).toCharPtr()[0]);
|
||||
s.push_back(at(i).toCharPtr()[1]);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
42
src_main/core/pistringlist.cpp
Normal file
42
src_main/core/pistringlist.cpp
Normal 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;
|
||||
}
|
||||
100
src_main/core/pistringlist.h
Normal file
100
src_main/core/pistringlist.h
Normal 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
|
||||
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Timer
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Timer
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#include "pitime.h"
|
||||
#include "pisystemtests.h"
|
||||
@@ -244,8 +245,6 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
|
||||
return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U);
|
||||
}
|
||||
//long t_cur = GetCurrentTime();
|
||||
//return PISystemTime(t_cur / 1000, (t_cur % 1000) * 1000000);
|
||||
#else
|
||||
# ifdef MAC_OS
|
||||
mach_timespec_t t_cur;
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Time structs
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Time structs
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Time structs
|
||||
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 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.
|
||||
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/>.
|
||||
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 PITIME_H
|
||||
|
||||
@@ -31,11 +31,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
//inline PISystemTime SYSTEMTIME2PISystemTime(SYSTEMTIME &t) {
|
||||
// PISystemTime st;
|
||||
|
||||
//}
|
||||
|
||||
inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) {
|
||||
PISystemTime st;
|
||||
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime);
|
||||
|
||||
@@ -82,8 +82,6 @@ struct PIP_EXPORT __PIVariantTypeInfo__ {
|
||||
__TYPEINFO_SINGLE(T, T &) \
|
||||
__TYPEINFO_SINGLE(T, const T) \
|
||||
__TYPEINFO_SINGLE(T, const T &)
|
||||
//__TYPEINFO_SINGLE(T, T *)
|
||||
//__TYPEINFO_SINGLE(T, const T *)
|
||||
|
||||
|
||||
class PIP_EXPORT __PIVariantInfoStorage__ {
|
||||
@@ -465,31 +463,6 @@ public:
|
||||
* Otherwise returns content as type T. */
|
||||
template<typename T>
|
||||
T value() const {return getAsValue<T>(*this);}
|
||||
/*
|
||||
operator bool() const {return toBool();}
|
||||
operator char() const {return toInt();}
|
||||
operator uchar() const {return toInt();}
|
||||
operator short() const {return toInt();}
|
||||
operator ushort() const {return toInt();}
|
||||
operator int() const {return toInt();}
|
||||
operator uint() const {return toInt();}
|
||||
operator long() const {return toInt();}
|
||||
operator ulong() const {return toInt();}
|
||||
operator llong() const {return toLLong();}
|
||||
operator ullong() const {return (ullong)toLLong();}
|
||||
operator float() const {return toFloat();}
|
||||
operator double() const {return toDouble();}
|
||||
operator ldouble() const {return toLDouble();}
|
||||
operator PITime() const {return toTime();}
|
||||
operator PIDate() const {return toDate();}
|
||||
operator PIDateTime() const {return toDateTime();}
|
||||
operator PIString() const {return toString();}
|
||||
operator PIStringList() const {return toStringList();}
|
||||
operator PIBitArray() const {return toBitArray();}
|
||||
operator PIByteArray() const {return toByteArray();}
|
||||
operator const char*() const {return toString().data();}
|
||||
operator void*() const {return (void*)(toLLong());}
|
||||
*/
|
||||
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const PIVariant & v);
|
||||
@@ -683,7 +656,6 @@ template<> inline PIVariantTypes::IODevice PIVariant::value() const {return toIO
|
||||
template<> inline PIPointd PIVariant::value() const {return toPoint();}
|
||||
template<> inline PIRectd PIVariant::value() const {return toRect();}
|
||||
|
||||
//template<> inline PIVariant PIVariant::fromValue(const char * v) {return PIVariant(PIString(v));}
|
||||
template<> inline PIVariant PIVariant::fromValue(const bool & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const char & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const uchar & v) {return PIVariant(v);}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef PIVARIANTYPES_H
|
||||
#define PIVARIANTYPES_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
|
||||
class PIPropertyStorage;
|
||||
@@ -33,125 +33,125 @@ class PIPropertyStorage;
|
||||
|
||||
namespace PIVariantTypes {
|
||||
|
||||
/**
|
||||
* @brief name-value pair
|
||||
*/
|
||||
struct PIP_EXPORT Enumerator {
|
||||
Enumerator(int v = 0, const PIString & n = PIString()): value(v), name(n) {}
|
||||
int value;
|
||||
PIString name;
|
||||
};
|
||||
/**
|
||||
* @brief name-value pair
|
||||
*/
|
||||
struct PIP_EXPORT Enumerator {
|
||||
Enumerator(int v = 0, const PIString & n = PIString()): value(v), name(n) {}
|
||||
int value;
|
||||
PIString name;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Collection of PIVariantTypes::Enumerator. It's replace classic c-style enum.
|
||||
* Contains elements with unique name and not uniqueue values.
|
||||
*/
|
||||
struct PIP_EXPORT Enum {
|
||||
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.
|
||||
* Contains elements with unique name and not uniqueue values.
|
||||
* @brief Find selected value.
|
||||
* @return selected value, otherwrise 0
|
||||
*/
|
||||
struct PIP_EXPORT Enum {
|
||||
Enum(const PIString & n = PIString()): enum_name(n) {}
|
||||
PIString toString() const {return selected;} // obsolete
|
||||
int selectedValue() const;
|
||||
|
||||
/**
|
||||
* @brief Find selected value.
|
||||
* @return selected value, otherwrise 0
|
||||
*/
|
||||
int selectedValue() const;
|
||||
/**
|
||||
* @brief Get selected name
|
||||
* @return selected name, otherwrise empty PIString
|
||||
*/
|
||||
PIString selectedName() const {return selected;}
|
||||
|
||||
/**
|
||||
* @brief Get selected name
|
||||
* @return selected name, otherwrise empty PIString
|
||||
*/
|
||||
PIString selectedName() const {return selected;}
|
||||
/**
|
||||
* @brief Select value if exists in Enum. If Enum contains several PIVariantTypes::Enumerator with same values,
|
||||
* first PIVariantTypes::Enumerator will selected
|
||||
* @param v value for selection
|
||||
* @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,
|
||||
* first PIVariantTypes::Enumerator will selected
|
||||
* @param v value for selection
|
||||
* @return true if value exists in Enum, false otherwrise
|
||||
*/
|
||||
bool selectValue(int v);
|
||||
/**
|
||||
* @brief Select name if exists in enum
|
||||
* @param n name for selection
|
||||
* @return true if name exists in Enum, false otherwrise
|
||||
*/
|
||||
bool selectName(const PIString & n);
|
||||
|
||||
/**
|
||||
* @brief Select name if exists in enum
|
||||
* @param n name for selection
|
||||
* @return true if name exists in Enum, false otherwrise
|
||||
*/
|
||||
bool selectName(const PIString & n);
|
||||
/**
|
||||
* @brief Find PIVariantTypes::Enumerator with specific name and return it value
|
||||
* @param n name for search
|
||||
* @return value of founded PIVariantTypes::Enumerator, 0 otherwrise
|
||||
*/
|
||||
int value(const PIString & n) const;
|
||||
|
||||
/**
|
||||
* @brief Find PIVariantTypes::Enumerator with specific name and return it value
|
||||
* @param n name for search
|
||||
* @return value of founded PIVariantTypes::Enumerator, 0 otherwrise
|
||||
*/
|
||||
int value(const PIString & n) const;
|
||||
/**
|
||||
* @brief Find first PIVariantTypes::Enumerator with specific value and return it name
|
||||
* @param v value for search
|
||||
* @return name of founded PIVariantTypes::Enumerator, empty string otherwrise
|
||||
*/
|
||||
PIString name(int v) const;
|
||||
|
||||
/**
|
||||
* @brief Find first PIVariantTypes::Enumerator with specific value and return it name
|
||||
* @param v value for search
|
||||
* @return name of founded PIVariantTypes::Enumerator, empty string otherwrise
|
||||
*/
|
||||
PIString name(int v) const;
|
||||
/**
|
||||
* @brief Make vector of Enum values
|
||||
*/
|
||||
PIVector<int> values() const;
|
||||
|
||||
/**
|
||||
* @brief Make vector of Enum values
|
||||
*/
|
||||
PIVector<int> values() const;
|
||||
/**
|
||||
* @brief Make vector of Enum names
|
||||
*/
|
||||
PIStringList names() const;
|
||||
PIString enum_name;
|
||||
PIString selected;
|
||||
PIVector<Enumerator> enum_list;
|
||||
|
||||
/**
|
||||
* @brief Make vector of Enum names
|
||||
*/
|
||||
PIStringList names() const;
|
||||
PIString enum_name;
|
||||
PIString selected;
|
||||
PIVector<Enumerator> enum_list;
|
||||
/**
|
||||
* @brief Add PIVariantTypes::Enumerator to Enum
|
||||
*/
|
||||
Enum & operator <<(const Enumerator & v);
|
||||
|
||||
/**
|
||||
* @brief Add PIVariantTypes::Enumerator to Enum
|
||||
*/
|
||||
Enum & operator <<(const Enumerator & v);
|
||||
/**
|
||||
* @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.
|
||||
* @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
|
||||
* unit then last element. If the is no elements, contains zero value.
|
||||
* @param v name for new PIVariantTypes::Enumerator element
|
||||
*/
|
||||
Enum & operator <<(const PIString & v);
|
||||
/**
|
||||
* @brief Add PIVariantTypes::Enumerator element for each name in vector
|
||||
*/
|
||||
Enum & operator <<(const PIStringList & v);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Add PIVariantTypes::Enumerator element for each name in vector
|
||||
*/
|
||||
Enum & operator <<(const PIStringList & v);
|
||||
};
|
||||
struct PIP_EXPORT File {
|
||||
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
|
||||
PIString toString() const {return file;}
|
||||
PIString file;
|
||||
PIString filter;
|
||||
bool is_abs;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT File {
|
||||
File(const PIString & p = PIString(), const PIString & f = PIString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
|
||||
PIString toString() const {return file;}
|
||||
PIString file;
|
||||
PIString filter;
|
||||
bool is_abs;
|
||||
};
|
||||
struct PIP_EXPORT Dir {
|
||||
Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {}
|
||||
PIString toString() const {return dir;}
|
||||
PIString dir;
|
||||
bool is_abs;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT Dir {
|
||||
Dir(const PIString & d = PIString(), bool abs = false): dir(d), is_abs(abs) {}
|
||||
PIString toString() const {return dir;}
|
||||
PIString dir;
|
||||
bool is_abs;
|
||||
};
|
||||
struct PIP_EXPORT Color {
|
||||
Color(uint v = 0) {rgba = v;}
|
||||
uint rgba;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT Color {
|
||||
Color(uint v = 0) {rgba = v;}
|
||||
uint rgba;
|
||||
};
|
||||
|
||||
struct PIP_EXPORT IODevice {
|
||||
IODevice();
|
||||
void set(const PIPropertyStorage & ps);
|
||||
PIPropertyStorage get() const;
|
||||
PIString toPICout() const;
|
||||
PIString prefix;
|
||||
int mode; // PIIODevice::DeviceMode
|
||||
int options; // PIIODevice::DeviceOptions
|
||||
PIByteArray props;
|
||||
};
|
||||
struct PIP_EXPORT IODevice {
|
||||
IODevice();
|
||||
void set(const PIPropertyStorage & ps);
|
||||
PIPropertyStorage get() const;
|
||||
PIString toPICout() const;
|
||||
PIString prefix;
|
||||
int mode; // PIIODevice::DeviceMode
|
||||
int options; // PIIODevice::DeviceOptions
|
||||
PIByteArray props;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP Authentication API
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -87,9 +87,6 @@ public:
|
||||
//! Server event on check client password
|
||||
EVENT1(passwordCheck, bool, result)
|
||||
|
||||
|
||||
//EVENT_HANDLER1(void, received, PIByteArray, data);
|
||||
|
||||
private:
|
||||
State disconnect(PIByteArray & ba, const PIString & error = PIString());
|
||||
bool isAuthorizedKey(const PIByteArray & pkey);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Cryptographic class using lib Sodium
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Contains geo ellipsoid models
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Contains geo ellipsoid models
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIELLIPSOIDMODEL_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for geo position storage and conversions
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pigeoposition.h"
|
||||
|
||||
const double PIGeoPosition::one_cm_tolerance = 0.01; // One centimeter tolerance.
|
||||
@@ -382,12 +401,6 @@ double PIGeoPosition::radiusEarth(double geolat, PIEllipsoidModel ell) {
|
||||
}
|
||||
|
||||
|
||||
//PIGeoPosition &PIGeoPosition::operator=(const PIGeoPosition &v) {
|
||||
// *((PIMathVectorT3d*)(this)) = *((PIMathVectorT3d*)&v);
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
|
||||
PIGeoPosition &PIGeoPosition::operator=(const PIMathVectorT3d &v) {
|
||||
*((PIMathVectorT3d*)(this)) = v;
|
||||
return *this;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for geo position storage and conversions
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -141,7 +141,6 @@ public:
|
||||
/// Returns as PIMathVectorT3d
|
||||
const PIMathVectorT3d & vector() const {return *this;}
|
||||
|
||||
// PIGeoPosition &operator=(const PIGeoPosition & v);
|
||||
PIGeoPosition &operator=(const PIMathVectorT3d & v);
|
||||
PIGeoPosition &operator-=(const PIGeoPosition &right);
|
||||
PIGeoPosition &operator+=(const PIGeoPosition &right);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Introspection module - base macros and types
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIINTROSPECTION_BASE_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Introspection module - interface for containers
|
||||
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 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.
|
||||
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/>.
|
||||
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 "piintrospection_containers.h"
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP - Platform Independent Primitives
|
||||
Introspection module - interface for containers
|
||||
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 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.
|
||||
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/>.
|
||||
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 PIINTROSPECTION_CONTAINERS_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user