Skip to content

Commit c6b9bf8

Browse files
committed
Initial import
0 parents  commit c6b9bf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+11892
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/build*
2+
/coverage
3+
/.project
4+
/.cproject
5+
/.settings
6+
/lib/gendocs

CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required( VERSION 3.1 )
2+
3+
project( ExtendedLib.Top )
4+
5+
option( COVERAGE "Enable coverage analysis" ON )
6+
7+
if( COVERAGE AND NOT MSVC )
8+
9+
set( CMAKE_CONFIGURATION_TYPES "Debug;Release;Coverage" CACHE STRING "" FORCE )
10+
11+
set( CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -g -O0 -fprofile-arcs -ftest-coverage" )
12+
set( CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -g -O0 -fprofile-arcs -ftest-coverage" )
13+
set( CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_COVERAGE} -fprofile-arcs -ftest-coverage" )
14+
15+
else()
16+
17+
set( CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE )
18+
19+
endif()
20+
21+
if( WIN32 AND NOT MSVC )
22+
add_definitions( -DWIN32 )
23+
endif()
24+
25+
add_custom_target( build )
26+
27+
add_subdirectory( lib )
28+
add_subdirectory( test )

LICENSE.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2003-2016, Jesus Gonzalez <[email protected]>
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

lib/CMakeLists.txt

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
cmake_minimum_required( VERSION 3.1 )
2+
3+
project( ExtendedLib )
4+
set( PROJECT_VERSION_MAJOR 0 )
5+
set( PROJECT_VERSION_MINOR 9 )
6+
set( PROJECT_VERSION_PATCH 0 )
7+
8+
option( BUILD_SHARED_LIBS "Build as a shared library" ON )
9+
10+
if( MSVC )
11+
include( cmake/VSHelper.cmake )
12+
13+
generate_groups( ${CMAKE_CURRENT_SOURCE_DIR} sources )
14+
generate_groups( ${CMAKE_CURRENT_SOURCE_DIR} include )
15+
endif( MSVC )
16+
17+
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DEXTENDEDLIB_DEBUG" )
18+
19+
include_directories( include )
20+
21+
include( CheckFunctionExists )
22+
23+
if( WIN32 )
24+
set( PLATFORM_DIR "msw" )
25+
elseif( UNIX )
26+
set( PLATFORM_DIR "linux" )
27+
endif()
28+
29+
set( SRC_LIST
30+
sources/format_string.cpp
31+
sources/log.cpp
32+
sources/runtime_error.cpp
33+
)
34+
35+
set( INC_LIST
36+
include/ExtendedLib/byte_vector.h
37+
include/ExtendedLib/broadcaster.h
38+
include/ExtendedLib/callback.h
39+
include/ExtendedLib/defs.h
40+
include/ExtendedLib/dispatched_callback.h
41+
include/ExtendedLib/format_string.h
42+
include/ExtendedLib/log.h
43+
include/ExtendedLib/log_common.h
44+
include/ExtendedLib/memory.h
45+
include/ExtendedLib/callback_dispatcher.h
46+
include/ExtendedLib/runtime_error.h
47+
include/ExtendedLib/shared_lib.h
48+
include/ExtendedLib/shared_ptr.h
49+
include/ExtendedLib/thread.h
50+
include/ExtendedLib/${PLATFORM_DIR}/callback_dispatcher.h
51+
)
52+
53+
if( WIN32 )
54+
set( SRC_LIST ${SRC_LIST}
55+
sources/msw/helpers.cpp
56+
sources/msw/callback_dispatcher.cpp
57+
)
58+
59+
set( INC_LIST ${INC_LIST}
60+
sources/msw/helpers.h
61+
)
62+
63+
if( NOT MINGW )
64+
set( SRC_LIST ${SRC_LIST}
65+
sources/msw/thread.cpp
66+
)
67+
endif( NOT MINGW )
68+
endif( WIN32 )
69+
70+
71+
if( BUILD_SHARED_LIBS )
72+
add_definitions( -DEXTENDEDLIB_BUILD_SHARED_LIB )
73+
endif()
74+
75+
set( PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" )
76+
77+
include( cmake/generate_product_version.cmake )
78+
79+
generate_product_version(
80+
PRODUCT_VERSION_FILES
81+
NAME ${PROJECT_NAME}
82+
VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
83+
VERSION_MINOR ${PROJECT_VERSION_MINOR}
84+
VERSION_PATCH ${PROJECT_VERSION_PATCH}
85+
COMPANY_NAME "www.gdr-sistemas.com"
86+
COMPANY_COPYRIGHT "(C) Copyright 2016 Jesus Gonzalez"
87+
)
88+
89+
add_library( ${PROJECT_NAME} ${SRC_LIST} ${INC_LIST} ${PRODUCT_VERSION_FILES} )
90+
91+
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11 )
92+
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED 1 )
93+
94+
set_target_properties( ${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_dbg" )
95+
set_target_properties( ${PROJECT_NAME} PROPERTIES COVERAGE_POSTFIX "_cov" )
96+
set_target_properties( ${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} )
97+
if( WIN32 )
98+
set_target_properties( ${PROJECT_NAME} PROPERTIES PREFIX "" )
99+
set_target_properties( ${PROJECT_NAME} PROPERTIES IMPORT_PREFIX "" )
100+
else()
101+
set_target_properties( ${PROJECT_NAME} PROPERTIES OUTPUT_NAME "Extended" )
102+
endif( WIN32 )
103+
104+
add_dependencies( build ${PROJECT_NAME} )
105+
106+
install( TARGETS ${PROJECT_NAME} DESTINATION lib )
107+
108+
install( DIRECTORY include/ DESTINATION include )
109+
110+
include( DocsTargets.cmake )

lib/DocsTargets.cmake

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# Source code documentation
3+
#
4+
5+
option( CHM_DOCS "Generate CHM documentation" OFF )
6+
option( HTML_DOCS "Generate HTML documentation" OFF )
7+
option( PDF_DOCS "Generate PDF documentation" OFF )
8+
9+
if( CHM_DOCS OR HTML_DOCS OR PDF_DOCS )
10+
find_package(Doxygen)
11+
if( NOT DOXYGEN_FOUND )
12+
message(FATAL_ERROR "Doxygen is not installed")
13+
endif( NOT DOXYGEN_FOUND )
14+
15+
add_custom_target( docs )
16+
endif()
17+
18+
if( CHM_DOCS )
19+
20+
find_package(HTMLHelp)
21+
if( NOT EXISTS ${HTML_HELP_COMPILER} )
22+
message(FATAL_ERROR "HTML Help Compiler is not installed")
23+
endif()
24+
25+
set( DOXYGEN_CHM_INPUT doxygen/chm.doxyfile )
26+
set( DOXYGEN_CHM_FILE ${PROJECT_NAME}.Reference.chm )
27+
set( DOXYGEN_CHM_OUT_PATH doxygen/gendocs/chm )
28+
29+
configure_file( ${DOXYGEN_CHM_INPUT}.in ${DOXYGEN_CHM_INPUT} )
30+
31+
add_custom_target( chm_docs
32+
COMMAND ${CMAKE_COMMAND} -E echo "Building CHM Documentation..."
33+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CHM_INPUT}
34+
COMMAND ${CMAKE_COMMAND} -E copy ${DOXYGEN_CHM_OUT_PATH}/output.chm ${PROJECT_SOURCE_DIR}/gendocs/${DOXYGEN_CHM_FILE}
35+
)
36+
37+
add_dependencies( docs chm_docs )
38+
endif( CHM_DOCS )
39+
40+
if( PDF_DOCS )
41+
42+
find_package(Latex)
43+
if( NOT EXISTS ${PDFLATEX_COMPILER} )
44+
message(FATAL_ERROR "PDFLatex Compiler is not installed")
45+
endif()
46+
47+
set( DOXYGEN_PDF_INPUT doxygen/pdf.doxyfile )
48+
set( DOXYGEN_PDF_FILE ${PROJECT_NAME}.Reference.pdf )
49+
set( DOXYGEN_PDF_OUT_PATH doxygen/gendocs/latex )
50+
51+
configure_file( ${DOXYGEN_PDF_INPUT}.in ${DOXYGEN_PDF_INPUT} )
52+
53+
add_custom_target( pdf_docs
54+
COMMAND ${CMAKE_COMMAND} -E echo "Building PDF Documentation..."
55+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_PDF_INPUT}
56+
COMMAND cd ${PROJECT_BINARY_DIR}/${DOXYGEN_PDF_OUT_PATH} && make.bat
57+
COMMAND ${CMAKE_COMMAND} -E copy ${DOXYGEN_PDF_OUT_PATH}/refman.pdf ${PROJECT_SOURCE_DIR}/gendocs/${DOXYGEN_PDF_FILE}
58+
)
59+
60+
add_dependencies( docs pdf_docs )
61+
endif( PDF_DOCS )
62+
63+
if( HTML_DOCS )
64+
65+
set( DOXYGEN_HTML_INPUT doxygen/html.doxyfile )
66+
set( DOXYGEN_HTML_OUT_PATH doxygen/gendocs/html )
67+
68+
configure_file( ${DOXYGEN_HTML_INPUT}.in ${DOXYGEN_HTML_INPUT} )
69+
70+
add_custom_target( html_docs
71+
COMMAND ${CMAKE_COMMAND} -E echo "Building HTML Documentation..."
72+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/gendocs/html
73+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_HTML_INPUT}
74+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DOXYGEN_HTML_OUT_PATH} ${PROJECT_SOURCE_DIR}/gendocs/html
75+
)
76+
77+
add_dependencies( docs html_docs )
78+
endif( HTML_DOCS )

lib/cmake/VSHelper.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function( generate_groups BASE_DIR CURR_DIR )
2+
string( REPLACE "/" "\\" GROUP_NAME "${CURR_DIR}" )
3+
source_group( "Source Files\\${GROUP_NAME}" REGULAR_EXPRESSION ${BASE_DIR}/${CURR_DIR}.*\\.cpp )
4+
source_group( "Header Files\\${GROUP_NAME}" REGULAR_EXPRESSION ${BASE_DIR}/${CURR_DIR}.*\\.h )
5+
file( GLOB FILE_LIST RELATIVE ${BASE_DIR} ${BASE_DIR}/${CURR_DIR}/* )
6+
foreach( FILE ${FILE_LIST} )
7+
if( IS_DIRECTORY ${BASE_DIR}/${FILE} )
8+
generate_groups( ${BASE_DIR} ${FILE} )
9+
endif()
10+
endforeach()
11+
endfunction()

lib/cmake/VersionInfo.h.in

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2015, by [halex2005](mailto:[email protected])
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
#pragma once
26+
27+
#ifndef PRODUCT_VERSION_MAJOR
28+
#define PRODUCT_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
29+
#endif
30+
31+
#ifndef PRODUCT_VERSION_MINOR
32+
#define PRODUCT_VERSION_MINOR @PRODUCT_VERSION_MINOR@
33+
#endif
34+
35+
#ifndef PRODUCT_VERSION_PATCH
36+
#define PRODUCT_VERSION_PATCH @PRODUCT_VERSION_PATCH@
37+
#endif
38+
39+
#ifndef PRODUCT_VERSION_BUILD
40+
#define PRODUCT_VERSION_BUILD @PRODUCT_VERSION_REVISION@
41+
#endif
42+
43+
#ifndef FILE_VERSION_MAJOR
44+
#define FILE_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
45+
#endif
46+
47+
#ifndef FILE_VERSION_MINOR
48+
#define FILE_VERSION_MINOR @PRODUCT_VERSION_MINOR@
49+
#endif
50+
51+
#ifndef FILE_VERSION_PATCH
52+
#define FILE_VERSION_PATCH @PRODUCT_VERSION_PATCH@
53+
#endif
54+
55+
#ifndef FILE_VERSION_BUILD
56+
#define FILE_VERSION_BUILD @PRODUCT_VERSION_REVISION@
57+
#endif
58+
59+
#ifndef __TO_STRING
60+
#define __TO_STRING_IMPL(x) #x
61+
#define __TO_STRING(x) __TO_STRING_IMPL(x)
62+
#endif
63+
64+
#define PRODUCT_VERSION_MAJOR_MINOR_STR __TO_STRING(PRODUCT_VERSION_MAJOR) "." __TO_STRING(PRODUCT_VERSION_MINOR)
65+
#define PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR PRODUCT_VERSION_MAJOR_MINOR_STR "." __TO_STRING(PRODUCT_VERSION_PATCH)
66+
#define PRODUCT_VERSION_FULL_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(PRODUCT_VERSION_BUILD)
67+
#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,PRODUCT_VERSION_BUILD
68+
#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_FULL_STR "\0"
69+
70+
#define FILE_VERSION_MAJOR_MINOR_STR __TO_STRING(FILE_VERSION_MAJOR) "." __TO_STRING(FILE_VERSION_MINOR)
71+
#define FILE_VERSION_MAJOR_MINOR_PATCH_STR FILE_VERSION_MAJOR_MINOR_STR "." __TO_STRING(FILE_VERSION_PATCH)
72+
#define FILE_VERSION_FULL_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(FILE_VERSION_BUILD)
73+
#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,FILE_VERSION_BUILD
74+
#define FILE_VERSION_RESOURCE_STR FILE_VERSION_FULL_STR "\0"
75+
76+
#ifndef PRODUCT_ICON
77+
#define PRODUCT_ICON "@PRODUCT_ICON@"
78+
#endif
79+
80+
#ifndef PRODUCT_COMMENTS
81+
#define PRODUCT_COMMENTS "@PRODUCT_COMMENTS@\0"
82+
#endif
83+
84+
#ifndef PRODUCT_COMPANY_NAME
85+
#define PRODUCT_COMPANY_NAME "@PRODUCT_COMPANY_NAME@\0"
86+
#endif
87+
88+
#ifndef PRODUCT_COMPANY_COPYRIGHT
89+
#define PRODUCT_COMPANY_COPYRIGHT "@PRODUCT_COMPANY_COPYRIGHT@\0"
90+
#endif
91+
92+
#ifndef PRODUCT_FILE_DESCRIPTION
93+
#define PRODUCT_FILE_DESCRIPTION "@PRODUCT_FILE_DESCRIPTION@\0"
94+
#endif
95+
96+
#ifndef PRODUCT_INTERNAL_NAME
97+
#define PRODUCT_INTERNAL_NAME "@PRODUCT_NAME@\0"
98+
#endif
99+
100+
#ifndef PRODUCT_ORIGINAL_FILENAME
101+
#define PRODUCT_ORIGINAL_FILENAME "@PRODUCT_ORIGINAL_FILENAME@\0"
102+
#endif
103+
104+
#ifndef PRODUCT_BUNDLE
105+
#define PRODUCT_BUNDLE "@PRODUCT_BUNDLE@\0"
106+
#endif

0 commit comments

Comments
 (0)