Skip to content

Commit 34973b3

Browse files
committed
Able to expose first level of object tree.
1 parent 67337b7 commit 34973b3

5 files changed

Lines changed: 620 additions & 26 deletions

File tree

.gitignore

Lines changed: 191 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,194 @@
1-
# Compiled Object files
2-
*.slo
3-
*.lo
4-
*.o
1+
#ignore thumbnails created by windows
2+
Thumbs.db
3+
#Ignore files build by Visual Studio
54
*.obj
6-
7-
# Precompiled Headers
8-
*.gch
5+
*.exe
6+
*.pdb
7+
*.user
8+
*.aps
99
*.pch
10-
11-
# Compiled Dynamic libraries
12-
*.so
13-
*.dylib
14-
*.dll
15-
16-
# Fortran module files
17-
*.mod
18-
*.smod
19-
20-
# Compiled Static libraries
21-
*.lai
22-
*.la
23-
*.a
10+
*.vspscc
11+
*_i.c
12+
*_p.c
13+
*.ncb
14+
*.suo
15+
*.tlb
16+
*.tlh
17+
*.bak
18+
*.cache
19+
*.ilk
20+
*.log
21+
[Bb]in
22+
[Dd]ebug*/
2423
*.lib
25-
26-
# Executables
27-
*.exe
28-
*.out
29-
*.app
24+
*.sbr
25+
obj/
26+
[Rr]elease*/
27+
_ReSharper*/
28+
[Tt]est[Rr]esult*
29+
.idea/
30+
/cmake-build-*/
31+
*.opensdf
32+
## Ignore Visual Studio temporary files, build results, and
33+
## files generated by popular Visual Studio add-ons.
34+
# User-specific files
35+
*.suo
36+
*.user
37+
*.userosscache
38+
*.sln.docstates
39+
# User-specific folders
40+
*.sln.ide/
41+
# Build results
42+
[Dd]ebug/
43+
[Dd]ebugPublic/
44+
[Rr]elease/
45+
[Rr]eleases/
46+
x64/
47+
x86/
48+
build/
49+
bld/
50+
[Bb]in/
51+
[Oo]bj/
52+
# Roslyn cache directories
53+
*.ide/
54+
# MSTest test Results
55+
[Tt]est[Rr]esult*/
56+
[Bb]uild[Ll]og.*
57+
#NUNIT
58+
*.VisualState.xml
59+
TestResult.xml
60+
# Build Results of an ATL Project
61+
[Dd]ebugPS/
62+
[Rr]eleasePS/
63+
dlldata.c
64+
*_i.c
65+
*_p.c
66+
*_i.h
67+
*.ilk
68+
*.meta
69+
*.obj
70+
*.pch
71+
*.pdb
72+
*.pgc
73+
*.pgd
74+
*.rsp
75+
*.sbr
76+
*.tlb
77+
*.tli
78+
*.tlh
79+
*.tmp
80+
*.tmp_proj
81+
*.log
82+
*.vspscc
83+
*.vssscc
84+
.builds
85+
*.pidb
86+
*.svclog
87+
*.scc
88+
# Chutzpah Test files
89+
_Chutzpah*
90+
# Visual C++ cache files
91+
ipch/
92+
*.aps
93+
*.ncb
94+
*.opensdf
95+
*.sdf
96+
*.cachefile
97+
# Visual Studio profiler
98+
*.psess
99+
*.vsp
100+
*.vspx
101+
# TFS 2012 Local Workspace
102+
$tf/
103+
# Guidance Automation Toolkit
104+
*.gpState
105+
# ReSharper is a .NET coding add-in
106+
_ReSharper*/
107+
*.[Rr]e[Ss]harper
108+
*.DotSettings.user
109+
# JustCode is a .NET coding addin-in
110+
.JustCode
111+
# TeamCity is a build add-in
112+
_TeamCity*
113+
# DotCover is a Code Coverage Tool
114+
*.dotCover
115+
# NCrunch
116+
_NCrunch_*
117+
.*crunch*.local.xml
118+
# MightyMoose
119+
*.mm.*
120+
AutoTest.Net/
121+
# Web workbench (sass)
122+
.sass-cache/
123+
# Installshield output folder
124+
[Ee]xpress/
125+
# DocProject is a documentation generator add-in
126+
DocProject/buildhelp/
127+
DocProject/Help/*.HxT
128+
DocProject/Help/*.HxC
129+
DocProject/Help/*.hhc
130+
DocProject/Help/*.hhk
131+
DocProject/Help/*.hhp
132+
DocProject/Help/Html2
133+
DocProject/Help/html
134+
# Click-Once directory
135+
publish/
136+
# Publish Web Output
137+
*.[Pp]ublish.xml
138+
*.azurePubxml
139+
# TODO: Comment the next line if you want to checkin your web deploy settings
140+
# but database connection strings (with potential passwords) will be unencrypted
141+
*.pubxml
142+
*.publishproj
143+
# NuGet Packages
144+
*.nupkg
145+
# The packages folder can be ignored because of Package Restore
146+
**/packages/*
147+
# except build/, which is used as an MSBuild target.
148+
!**/packages/build/
149+
# If using the old MSBuild-Integrated Package Restore, uncomment this:
150+
#!**/packages/repositories.config
151+
# Windows Azure Build Output
152+
csx/
153+
*.build.csdef
154+
# Windows Store app package directory
155+
AppPackages/
156+
# Others
157+
sql/
158+
*.Cache
159+
ClientBin/
160+
[Ss]tyle[Cc]op.*
161+
~$*
162+
*~
163+
*.dbmdl
164+
*.dbproj.schemaview
165+
*.pfx
166+
*.publishsettings
167+
node_modules/
168+
bower_components/
169+
# RIA/Silverlight projects
170+
Generated_Code/
171+
# Backup & report files from converting an old project file
172+
# to a newer Visual Studio version. Backup files are not needed,
173+
# because we have git ;-)
174+
_UpgradeReport_Files/
175+
Backup*/
176+
UpgradeLog*.XML
177+
UpgradeLog*.htm
178+
# SQL Server files
179+
*.mdf
180+
*.ldf
181+
# Business Intelligence projects
182+
*.rdl.data
183+
*.bim.layout
184+
*.bim_*.settings
185+
# Microsoft Fakes
186+
FakesAssemblies/
187+
*.suo
188+
*.vcxproj.filters
189+
*.npp
190+
CMakeFiles/*
191+
nbproject/*
192+
*.cd
193+
*.cd
194+
a.out

CMakeLists.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
cmake_minimum_required( VERSION 2.8.12 )
2+
3+
project( json_to_cpp_prj )
4+
5+
include( ExternalProject )
6+
7+
find_package( Boost 1.58.0 COMPONENTS system date_time iostreams program_options filesystem regex unit_test_framework REQUIRED )
8+
9+
enable_testing( )
10+
add_definitions( -DBOOST_TEST_DYN_LINK )
11+
12+
find_package( Threads REQUIRED )
13+
14+
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL 'MSVC' )
15+
add_compile_options( -D_WIN32_WINNT=0x0601 )
16+
else( )
17+
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
18+
add_compile_options(-std=c++14 -Weverything -pthread -Wno-c++98-compat -g -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 -Wno-c99-compat)
19+
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )
20+
add_compile_options(-std=c++14 -ggdb -Wall -pthread -Wno-deprecated-declarations -march=native )
21+
endif( )
22+
endif( )
23+
24+
externalproject_add(
25+
header_libraries_prj
26+
GIT_REPOSITORY "https://github.com/beached/header_libraries.git"
27+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/header_libraries"
28+
GIT_TAG "master"
29+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
30+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
31+
)
32+
33+
externalproject_add(
34+
parse_json_prj
35+
GIT_REPOSITORY "https://github.com/beached/parse_json.git"
36+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/parse_json"
37+
GIT_TAG "master"
38+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
39+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
40+
)
41+
42+
externalproject_add(
43+
char_range_prj
44+
GIT_REPOSITORY "https://github.com/beached/char_range.git"
45+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/char_range"
46+
GIT_TAG "master"
47+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
48+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
49+
)
50+
51+
externalproject_add(
52+
date_prj
53+
GIT_REPOSITORY "https://github.com/beached/date.git"
54+
SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/date"
55+
GIT_TAG "master"
56+
INSTALL_DIR "${CMAKE_BINARY_DIR}/install"
57+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
58+
)
59+
60+
set( HEADER_FOLDER "include" )
61+
set( SOURCE_FOLDER "src" )
62+
set( TEST_FOLDER "tests" )
63+
64+
include_directories( SYSTEM "${CMAKE_BINARY_DIR}/install/include" )
65+
include_directories( ${HEADER_FOLDER} )
66+
include_directories( SYSTEM ${OPENSSL_INCLUDE_DIR} )
67+
68+
include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
69+
70+
link_directories( "${CMAKE_BINARY_DIR}/install/lib" )
71+
link_directories( ${Boost_LIBRARY_DIRS} )
72+
73+
set( HEADER_FILES
74+
${HEADER_FOLDER}/json_to_cpp.h
75+
)
76+
77+
set( SOURCE_FILES
78+
${SOURCE_FOLDER}/json_to_cpp.cpp
79+
)
80+
81+
add_library( json_to_cpp ${HEADER_FILES} ${SOURCE_FILES} )
82+
add_dependencies( json_to_cpp header_libraries_prj parse_json_prj char_range_prj date_prj )
83+
target_link_libraries( json_to_cpp parse_json tz char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
84+
85+
add_executable( json_to_cpp_bin ${HEADER_FILES} ${SOURCE_FOLDER}/main.cpp )
86+
target_link_libraries( json_to_cpp_bin json_to_cpp parse_json char_range ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
87+
88+
install( TARGETS json_to_cpp DESTINATION lib )
89+
install( TARGETS json_to_cpp_bin DESTINATION bin )
90+
install( DIRECTORY ${HEADER_FOLDER}/ DESTINATION include/daw/json_to_cpp )

include/json_to_cpp.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2016 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+
#pragma once
24+
25+
#include <boost/utility/string_view.hpp>
26+
#include <daw/json/daw_json_link.h>
27+
28+
namespace daw {
29+
namespace json_to_cpp {
30+
struct config_t: public daw::json::JsonLink<config_t> {
31+
bool enable_comments;
32+
bool enable_jsonlink;
33+
34+
config_t( );
35+
~config_t( );
36+
config_t( config_t const & other );
37+
config_t( config_t && other );
38+
39+
config_t & operator=( config_t const & ) = default;
40+
config_t & operator=( config_t && ) = default;
41+
private:
42+
void set_links( );
43+
}; // config_t
44+
45+
std::string generate_cpp( boost::string_view json_string, config_t const & config );
46+
} // namespace json_to_cpp
47+
} // namespace daw
48+

0 commit comments

Comments
 (0)