diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f3cc8b7..0844598c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(pip) set(pip_MAJOR 2) set(pip_MINOR 28) -set(pip_REVISION 0) +set(pip_REVISION 1) set(pip_SUFFIX ) set(pip_COMPANY SHS) set(pip_DOMAIN org.SHS) diff --git a/cmake/PIPMacros.cmake b/cmake/PIPMacros.cmake index 32b6822b..81a1972d 100644 --- a/cmake/PIPMacros.cmake +++ b/cmake/PIPMacros.cmake @@ -1,6 +1,6 @@ #[[ - pip_code_model( file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ]) + pip_code_model( file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ] [NAME name]) Generate code model files for source files file0 [file1 ...] @@ -8,6 +8,8 @@ Relative files pathes read from CMAKE_CURRENT_SOURCE_DIR You should add ${} to your target + If NAME specified then ".h" and ".cpp" files will be generated instead + of default "ccm_" @@ -19,30 +21,32 @@ ]] -macro(PIP_EXTRACT_OPTIONS _pip_files _pip_options _abs) +macro(PIP_EXTRACT_OPTIONS _pip_files _pip_options _name _abs) set(${_pip_files}) set(${_pip_options}) - set(_PIP_DOING_OPTIONS FALSE) + set(_cur_opt 0) foreach(_currentArg ${ARGN}) - if("x${_currentArg}" STREQUAL "xABSOLUTE") + if ("x${_currentArg}" STREQUAL "xABSOLUTE") set(${_abs} TRUE) + elseif ("x${_currentArg}" STREQUAL "xOPTIONS") + set(_cur_opt 1) + elseif ("x${_currentArg}" STREQUAL "xNAME") + set(_cur_opt 2) + elseif (_cur_opt EQUAL 1) + list(APPEND ${_pip_options} "${_currentArg}") + elseif (_cur_opt EQUAL 2) + set(${_name} "${_currentArg}") + set(_cur_opt 0) else() - if("x${_currentArg}" STREQUAL "xOPTIONS") - set(_PIP_DOING_OPTIONS TRUE) - else() - if(_PIP_DOING_OPTIONS) - list(APPEND ${_pip_options} "${_currentArg}") - else() - list(APPEND ${_pip_files} "${_currentArg}") - endif() - endif() + list(APPEND ${_pip_files} "${_currentArg}") endif() endforeach() endmacro() macro(pip_code_model RESULT) - PIP_EXTRACT_OPTIONS(CCM_SRC OPTS ABS ${ARGN}) + set(_name "ccm_${PROJECT_NAME}") + PIP_EXTRACT_OPTIONS(CCM_SRC OPTS _name ABS ${ARGN}) #message(STATUS "src = ${CCM_SRC}") #message(STATUS "result = ${RESULT}") #message(STATUS "options = \"${CCM_OPTS}\"") @@ -50,7 +54,7 @@ macro(pip_code_model RESULT) foreach(pi ${PIP_INCLUDES}) list(APPEND CMG_INCLUDES "-I${pi}") endforeach() - set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME}.cpp) + set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.cpp) set(${RESULT} ${${RESULT}} ${CCM_OUT}) set(CCM_FILES) foreach(csrc ${CCM_SRC}) @@ -66,10 +70,10 @@ macro(pip_code_model RESULT) endif() add_custom_command(OUTPUT ${CCM_OUT} COMMAND ${PIP_CMG} - ARGS -q ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME} ${CMG_INCLUDES} ${CCM_FILES} + ARGS -q ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${CMG_INCLUDES} ${CCM_FILES} DEPENDS ${CCM_SRC} WORKING_DIRECTORY ${PIP_DLL_DIR} - COMMENT "Generating ccm_${PROJECT_NAME}.h, ccm_${PROJECT_NAME}.cpp" + COMMENT "Generating ${_name}.h, ${_name}.cpp" VERBATIM) endmacro() diff --git a/libs/main/core/pibytearray.h b/libs/main/core/pibytearray.h index aadfe784..6a48ade5 100644 --- a/libs/main/core/pibytearray.h +++ b/libs/main/core/pibytearray.h @@ -555,10 +555,27 @@ inline PIByteArray & operator >>(PIByteArray & s, T & ) { return s; } + template<> inline uint piHash(const PIByteArray & ba) {return ba.hash();} template<> inline void piSwap(PIByteArray & f, PIByteArray & s) {f.swap(s);} +template PIByteArray piSerialize(const T & value) { + PIByteArray ret; + ret << value; + return ret; +} + +template T piDeserialize(const PIByteArray & data) { + T ret; + if (!data.isEmpty()) { + PIByteArray ba(data); + ba >> ret; + } + return ret; +} + + #undef _TYPENAME_