Skip to content

Commit b4d2c0c

Browse files
authored
Merge pull request #39 from kimkulling/feature/refactor_string
New string concept
2 parents dc9135c + c1e0622 commit b4d2c0c

File tree

13 files changed

+480
-232
lines changed

13 files changed

+480
-232
lines changed

CMakeLists.txt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CMAKE_MINIMUM_REQUIRED( VERSION 3.10 )
22
PROJECT( cppcore )
3-
SET ( CPPCORE_VERSION_MAJOR 0 )
4-
SET ( CPPCORE_VERSION_MINOR 1 )
5-
SET ( CPPCORE_VERSION_PATCH 0 )
6-
SET ( CPPCORE_VERSION ${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}.${CPPCORE_VERSION_PATCH} )
7-
SET ( PROJECT_VERSION "${CPPCORE_VERSION}" )
3+
SET( CPPCORE_VERSION_MAJOR 0 )
4+
SET( CPPCORE_VERSION_MINOR 1 )
5+
SET( CPPCORE_VERSION_PATCH 0 )
6+
SET( CPPCORE_VERSION ${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}.${CPPCORE_VERSION_PATCH} )
7+
SET( PROJECT_VERSION "${CPPCORE_VERSION}" )
88

99
find_package(GTest)
1010

@@ -17,11 +17,11 @@ option( CPPCORE_BUILD_UNITTESTS
1717
"Build unit tests."
1818
ON
1919
)
20-
option( CPPCORE_ASAN
20+
option(CPPCORE_ASAN
2121
"Enable AddressSanitizer."
2222
OFF
2323
)
24-
option( CPPCORE_UBSAN
24+
option(CPPCORE_UBSAN
2525
"Enable Undefined Behavior sanitizer."
2626
OFF
2727
)
@@ -38,9 +38,9 @@ link_directories(
3838
${CMAKE_HOME_DIRECTORY}/
3939
)
4040

41-
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
42-
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
43-
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
41+
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
42+
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
43+
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
4444

4545
if( WIN32 AND NOT CYGWIN )
4646
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" ) # Force to always compile with W4
@@ -56,38 +56,39 @@ elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
5656
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -g -pedantic -std=c++11")
5757
endif()
5858

59-
IF (ASSIMP_ASAN)
59+
IF(CPPCORE_ASAN)
6060
MESSAGE(STATUS "AddressSanitizer enabled")
6161
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
6262
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
6363
ENDIF()
6464

65-
IF (ASSIMP_UBSAN)
65+
IF(CPPCORE_UBSAN)
6666
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
67-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
68-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
67+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
68+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
6969
ENDIF()
7070

71-
SET ( cppcore_src
71+
SET(cppcore_src
7272
code/cppcore.cpp
7373
include/cppcore/CPPCoreCommon.h
7474
)
7575

76-
SET ( cppcore_common_src
76+
SET(cppcore_common_src
7777
include/cppcore/Common/Hash.h
7878
include/cppcore/Common/TStringBase.h
79+
include/cppcore/Common/TStringView.h
7980
include/cppcore/Common/Variant.h
8081
include/cppcore/Common/Sort.h
8182
include/cppcore/Common/TBitField.h
8283
include/cppcore/Common/TOptional.h
8384
)
8485

85-
SET( cppcore_random_src
86+
SET(cppcore_random_src
8687
include/cppcore/Random/RandomGenerator.h
8788
code/Random/RandomGenerator.cpp
8889
)
8990

90-
SET ( cppcore_container_src
91+
SET(cppcore_container_src
9192
include/cppcore/Container/THashMap.h
9293
include/cppcore/Container/TArray.h
9394
include/cppcore/Container/TStaticArray.h
@@ -96,7 +97,7 @@ SET ( cppcore_container_src
9697
include/cppcore/Container/TStaticArray.h
9798
)
9899

99-
SET ( cppcore_memory_src
100+
SET(cppcore_memory_src
100101
include/cppcore/Memory/MemUtils.h
101102
include/cppcore/Memory/TDefaultAllocator.h
102103
include/cppcore/Memory/TStackAllocator.h
@@ -137,6 +138,8 @@ IF( CPPCORE_BUILD_UNITTESTS )
137138
test/common/SortTest.cpp
138139
test/common/TBitFieldTest.cpp
139140
test/common/TOptionalTest.cpp
141+
test/common/TStringViewTest.cpp
142+
test/common/TStringBaseTest.cpp
140143
)
141144

142145
SET( cppcore_container_test_src

include/cppcore/CPPCoreCommon.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ namespace cppcore {
4545
#endif
4646

4747
#ifdef CPPCORE_WINDOWS
48-
# define CPPCORE_TAG_DLL_EXPORT __declspec(dllexport)
49-
# define CPPCORE_TAG_DLL_IMPORT __declspec(dllimport )
48+
# define CPPCORE_TAG_DLL_EXPORT __declspec(dllexport)
49+
# define CPPCORE_TAG_DLL_IMPORT __declspec(dllimport )
5050
# ifdef CPPCORE_BUILD
51-
# define DLL_CPPCORE_EXPORT CPPCORE_TAG_DLL_EXPORT
51+
# define DLL_CPPCORE_EXPORT CPPCORE_TAG_DLL_EXPORT
5252
# else
53-
# define DLL_CPPCORE_EXPORT CPPCORE_TAG_DLL_IMPORT
53+
# define DLL_CPPCORE_EXPORT CPPCORE_TAG_DLL_IMPORT
5454
# endif
5555
// All disabled warnings for windows
5656
# pragma warning( disable : 4251 ) // <class> needs to have dll-interface to be used by clients of class <class>
57-
# define CPPCORE_STACK_ALLOC(size) ::alloca(size)
57+
# define CPPCORE_STACK_ALLOC(size) ::alloca(size)
5858
#else
59-
# define DLL_CPPCORE_EXPORT __attribute__((visibility("default")))
60-
# define CPPCORE_STACK_ALLOC(size) __builtin_alloca(size)
59+
# define DLL_CPPCORE_EXPORT __attribute__((visibility("default")))
60+
# define CPPCORE_STACK_ALLOC(size) __builtin_alloca(size)
6161
#endif
6262

6363
//-------------------------------------------------------------------------------------------------
@@ -107,4 +107,6 @@ public: \
107107
//-------------------------------------------------------------------------------------------------
108108
#define CPPCORE_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
109109

110+
using HashId = uint64_t;
111+
110112
} // Namespace cppcore

include/cppcore/Common/Sort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ namespace cppcore {
177177
}
178178

179179
/// @brief Implements a binary search algorithm.
180-
/// @tparam T The type of the value
180+
/// @tparam T The type of the value
181181
/// @param key The key to search for
182182
/// @param array The data to search in
183183
/// @param num The number of elements to search

0 commit comments

Comments
 (0)