Skip to content

Commit f595ef1

Browse files
committed
Starting to migrate to producing new version of daw_json_link
1 parent ce300cb commit f595ef1

12 files changed

Lines changed: 560 additions & 284 deletions

File tree

.clang-format

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
BasedOnStyle: LLVM
2+
AccessModifierOffset: -2
3+
AlignAfterOpenBracket: true
4+
AlignEscapedNewlinesLeft: false
5+
AlignOperands: true
6+
AlignTrailingComments: true
7+
AllowAllParametersOfDeclarationOnNextLine: true
8+
AllowShortBlocksOnASingleLine: true
9+
AllowShortCaseLabelsOnASingleLine: false
10+
AllowShortFunctionsOnASingleLine: Empty
11+
AllowShortIfStatementsOnASingleLine: false
12+
AllowShortLoopsOnASingleLine: false
13+
AlwaysBreakAfterDefinitionReturnType: false
14+
AlwaysBreakBeforeMultilineStrings: true
15+
AlwaysBreakTemplateDeclarations: true
16+
SpaceAfterTemplateKeyword: false
17+
BinPackArguments: true
18+
BinPackParameters: true
19+
BreakBeforeBinaryOperators: None
20+
BreakBeforeBraces: Attach
21+
BreakBeforeTernaryOperators: true
22+
BreakConstructorInitializersBeforeComma: true
23+
ColumnLimit: 80
24+
CommentPragmas: '^ IWYU pragma:'
25+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
26+
ConstructorInitializerIndentWidth: 2
27+
ContinuationIndentWidth: 2
28+
Cpp11BracedListStyle: true
29+
DerivePointerAlignment: false
30+
DisableFormat: false
31+
ExperimentalAutoDetectBinPacking: false
32+
IndentCaseLabels: false
33+
IndentWidth: 2
34+
IndentWrappedFunctionNames: false
35+
KeepEmptyLinesAtTheStartOfBlocks: true
36+
Language: Cpp
37+
MaxEmptyLinesToKeep: 1
38+
NamespaceIndentation: All
39+
ObjCBlockIndentWidth: 2
40+
ObjCSpaceAfterProperty: false
41+
ObjCSpaceBeforeProtocolList: true
42+
PenaltyBreakBeforeFirstCallParameter: 19
43+
PenaltyBreakComment: 300
44+
PenaltyBreakFirstLessLess: 80
45+
PenaltyBreakString: 1000
46+
PenaltyExcessCharacter: 1000000
47+
PenaltyReturnTypeOnItsOwnLine: 60
48+
PointerAlignment: Right
49+
SpaceAfterCStyleCast: false
50+
SpaceBeforeAssignmentOperators: true
51+
SpaceBeforeParens: Never
52+
SpaceInEmptyParentheses: true
53+
SpacesBeforeTrailingComments: 1
54+
SpacesInAngles: false
55+
SpacesInCStyleCastParentheses: false
56+
SpacesInContainerLiterals: true
57+
SpacesInParentheses: true
58+
SpacesInSquareBrackets: false
59+
Standard: Cpp11
60+
TabWidth: 2
61+
UseTab: ForIndentation
62+

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root=true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
indent_size = 2
7+
trim_trailing_whitespace = true
8+
max_line_length = 80

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ obj/
2727
_ReSharper*/
2828
[Tt]est[Rr]esult*
2929
.idea/
30-
/cmake-build-*/
3130
*.opensdf
3231
## Ignore Visual Studio temporary files, build results, and
3332
## files generated by popular Visual Studio add-ons.
@@ -192,3 +191,4 @@ nbproject/*
192191
*.cd
193192
*.cd
194193
a.out
194+
cmake-build-*/*

CMakeLists.txt

Lines changed: 27 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,36 @@ include( ExternalProject )
77
find_package( Boost 1.58.0 COMPONENTS system date_time iostreams program_options filesystem regex unit_test_framework REQUIRED )
88

99
find_package( CURL )
10+
find_package( Threads REQUIRED )
1011

1112
enable_testing( )
1213
add_definitions( -DBOOST_TEST_DYN_LINK )
1314

14-
find_package( Threads REQUIRED )
15+
include( "${CMAKE_SOURCE_DIR}/dependent_projects/CMakeListsCompiler.txt" )
1516

16-
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL 'MSVC' )
17-
add_compile_options( -D_WIN32_WINNT=0x0601 /std:c++latest )
18-
else( )
19-
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" )
20-
add_compile_options(-std=c++14 -march=native -pthread -Weverything -Wno-c++98-compat -Wno-covered-switch-default -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-unused-parameter -Wno-missing-noreturn -Wno-missing-prototypes -Wno-disabled-macro-expansion)
21-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
22-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
23-
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )
24-
add_compile_options(-std=c++14 -march=native -pthread -Wall -Wno-deprecated-declarations)
25-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
26-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
27-
endif( )
17+
include_directories( "./include" )
18+
set( DEP_ROOT_DIR_BASE "${CMAKE_SOURCE_DIR}/dependent_projects/build" )
19+
if( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
20+
set( DEP_ROOT_DIR "${DEP_ROOT_DIR_BASE}/debug" )
21+
elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" )
22+
set( DEP_ROOT_DIR "${DEP_ROOT_DIR_BASE}/release" )
23+
elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
24+
set( DEP_ROOT_DIR "${DEP_ROOT_DIR_BASE}/release" )
2825
endif( )
2926

30-
externalproject_add(
31-
header_libraries_prj
32-
GIT_REPOSITORY "https://github.com/beached/header_libraries.git"
33-
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/header_libraries"
34-
GIT_TAG "master"
35-
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
36-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
37-
)
38-
39-
externalproject_add(
40-
parse_json_prj
41-
GIT_REPOSITORY "https://github.com/beached/parse_json.git"
42-
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/parse_json"
43-
GIT_TAG "master"
44-
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
45-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
46-
)
47-
48-
externalproject_add(
49-
char_range_prj
50-
GIT_REPOSITORY "https://github.com/beached/char_range.git"
51-
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/char_range"
52-
GIT_TAG "master"
53-
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
54-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
55-
)
56-
57-
externalproject_add(
58-
date_prj
59-
GIT_REPOSITORY "https://github.com/beached/date.git"
60-
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/date"
61-
GIT_TAG "master"
62-
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
63-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
64-
)
65-
66-
externalproject_add(
67-
temp_file_prj
68-
GIT_REPOSITORY "https://github.com/beached/libtemp_file.git"
69-
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/temp_file"
70-
GIT_TAG "master"
71-
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
72-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
73-
)
27+
message( "Building for: ${CMAKE_BUILD_TYPE}" )
28+
if( EXISTS "${DEP_ROOT_DIR}" )
29+
message( "${DEP_ROOT_DIR}" )
30+
message( "using dependency folder" )
31+
add_custom_target( dependency_stub )
32+
include_directories( SYSTEM "${DEP_ROOT_DIR}/install/include" )
33+
link_directories( "${DEP_ROOT_DIR}/install/lib" )
34+
else( )
35+
message( "downloading and building deps" )
36+
include( "${CMAKE_SOURCE_DIR}/dependent_projects/dependencies.txt" )
37+
add_library( dependency_stub STATIC "${CMAKE_SOURCE_DIR}/dependent_projects/stub.cpp" )
38+
add_dependencies( dependency_stub ${DEP_PROJECT_DEPS} )
39+
endif( )
7440

7541
set( HEADER_FOLDER "include" )
7642
set( SOURCE_FOLDER "src" )
@@ -94,13 +60,14 @@ set( SOURCE_FILES
9460
)
9561

9662
add_library( json_to_cpp ${HEADER_FILES} ${SOURCE_FILES} )
97-
add_dependencies( json_to_cpp header_libraries_prj parse_json_prj char_range_prj date_prj )
98-
target_link_libraries( json_to_cpp parse_json tz char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
63+
add_dependencies( json_to_cpp dependency_stub )
64+
target_link_libraries( json_to_cpp tz char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
9965

10066
add_executable( json_to_cpp_bin ${HEADER_FILES} ${SOURCE_FOLDER}/main.cpp )
101-
add_dependencies( json_to_cpp_bin temp_file_prj )
67+
add_dependencies( json_to_cpp_bin dependency_stub )
10268
target_link_libraries( json_to_cpp_bin json_to_cpp parse_json char_range temp_file ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} )
10369

10470
install( TARGETS json_to_cpp DESTINATION lib )
10571
install( TARGETS json_to_cpp_bin DESTINATION bin )
10672
install( DIRECTORY ${HEADER_FOLDER}/ DESTINATION include/daw/json_to_cpp )
73+

dependent_projects/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required( VERSION 2.8.12 )
2+
3+
project( dependency_prj )
4+
5+
find_package( Boost 1.58.0 COMPONENTS system iostreams filesystem regex unit_test_framework REQUIRED )
6+
find_package( OpenSSL REQUIRED )
7+
find_package( CURL REQUIRED )
8+
9+
add_definitions( -DBOOST_TEST_DYN_LINK -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK )
10+
11+
include( "CMakeListsCompiler.txt" )
12+
13+
include_directories( "./include" )
14+
include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
15+
16+
include( "dependencies.txt" )
17+
18+
add_library( dependency_stub STATIC stub.cpp )
19+
add_dependencies( dependency_stub ${DEP_PROJECT_DEPS} )
20+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set( CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested.")
2+
3+
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL 'MSVC' )
4+
add_definitions( -DNOMINMAX -DD_WIN32_WINNT=0x0601 )
5+
else( )
6+
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" )
7+
add_compile_options( -march=native -ffast-math -ftemplate-backtrace-limit=0 -Wall -Wextra -pedantic -Weverything -Wno-c++98-compat -Wno-covered-switch-default -Wnull-dereference -Wno-padded -Wno-exit-time-destructors -Wno-c++98-compat-pedantic -Wno-unused-parameter -Wno-missing-noreturn -Wno-missing-prototypes -Wno-disabled-macro-expansion -Wno-missing-braces)
8+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DDEBUG -fsanitize=undefined")
9+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DNDEBUG")
10+
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )
11+
add_compile_options( -march=native -Wall -ffast-math -Wextra -pedantic -Wno-deprecated-declarations -Wduplicated-cond -Wlogical-op -Wnull-dereference -Wold-style-cast -Wshadow)
12+
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O3 -g -fsanitize=undefined -DDEBUG")
13+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
14+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG" )
15+
endif( )
16+
endif( )
17+
18+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include( ExternalProject )
2+
externalproject_add(
3+
header_libraries_prj
4+
GIT_REPOSITORY "https://github.com/beached/header_libraries.git"
5+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/header_libraries"
6+
GIT_TAG "master"
7+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
8+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
9+
)
10+
11+
externalproject_add(
12+
char_range_prj
13+
GIT_REPOSITORY "https://github.com/beached/char_range.git"
14+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/char_range"
15+
GIT_TAG "master"
16+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
17+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
18+
)
19+
20+
externalproject_add(
21+
date_prj
22+
GIT_REPOSITORY "https://github.com/howardhinnant/date.git"
23+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/date"
24+
GIT_TAG "master"
25+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
26+
CMAKE_ARGS -DTZ_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
27+
)
28+
29+
externalproject_add(
30+
temp_file_prj
31+
GIT_REPOSITORY "https://github.com/beached/libtemp_file.git"
32+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/temp_file"
33+
GIT_TAG "master"
34+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
35+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
36+
)
37+
38+
include_directories( SYSTEM "${CMAKE_BINARY_DIR}/install/include" )
39+
link_directories( "${CMAKE_BINARY_DIR}/install/lib" )
40+
41+
set( DEP_PROJECT_DEPS header_libraries_prj date_prj char_range_prj date_prj temp_file_prj )

dependent_projects/stub.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2018 Darrell Wright
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files( the "Software" ), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
int main( int, char** ) {
24+
return 0;
25+
}
26+
27+

include/json_to_cpp.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,26 @@
2222

2323
#pragma once
2424

25-
#include <boost/utility/string_view.hpp>
2625
#include <boost/filesystem/path.hpp>
2726
#include <ostream>
2827

29-
#include <daw/json/daw_json_link.h>
28+
#include <daw/daw_string_view.h>
3029

3130
namespace daw {
3231
namespace json_to_cpp {
3332
struct config_t final {
3433
bool enable_jsonlink;
35-
std::ostream * header_stream;
36-
std::ostream * cpp_stream;
34+
std::ostream *header_stream;
35+
std::ostream *cpp_stream;
3736
boost::filesystem::path cpp_path;
3837
boost::filesystem::path header_path;
3938
boost::filesystem::path json_path;
4039
bool separate_files;
4140

42-
config_t( ) = default;
43-
~config_t( ) = default;
44-
config_t( config_t const & ) = default;
45-
config_t( config_t && ) = default;
46-
config_t & operator=( config_t const & ) = default;
47-
config_t & operator=( config_t && ) = default;
48-
49-
std::ostream & header_file( );
50-
std::ostream & cpp_file( );
51-
52-
}; // config_t
53-
54-
void generate_cpp( boost::string_view json_string, config_t & config );
55-
} // namespace json_to_cpp
56-
} // namespace daw
41+
std::ostream &header_file( );
42+
std::ostream &cpp_file( );
43+
}; // config_t
5744

45+
void generate_cpp( daw::string_view json_string, config_t &config );
46+
} // namespace json_to_cpp
47+
} // namespace daw

make_deps.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
#version 2018_11_17
3+
4+
[[ -d ./dependent_projects/build ]] || mkdir ./dependent_projects/build
5+
[[ -d ./dependent_projects/build/release ]] || mkdir ./dependent_projects/build/release
6+
[[ -d ./dependent_projects/build/debug ]] || mkdir ./dependent_projects/build/debug
7+
8+
cd ./dependent_projects/build/release
9+
cmake ../.. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
10+
make clean
11+
make -j2
12+
cd ../debug
13+
cmake ../.. -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
14+
make clean
15+
make -j2

0 commit comments

Comments
 (0)