Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JsonPP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Karl Herbig
JsonPP
Commits
f5432bef
Commit
f5432bef
authored
Jun 18, 2018
by
Karl Herbig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix const-ness + code formating
parent
0f2552ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
231 additions
and
153 deletions
+231
-153
IDEs/CodeLite/JsonPP.project
IDEs/CodeLite/JsonPP.project
+53
-3
IDEs/CodeLite/JsonPP.workspace
IDEs/CodeLite/JsonPP.workspace
+5
-1
include/JsonPP.h
include/JsonPP.h
+0
-1
include/Value.h
include/Value.h
+9
-7
src/JsonPP.cpp
src/JsonPP.cpp
+1
-1
src/Value.cpp
src/Value.cpp
+163
-140
No files found.
IDEs/CodeLite/JsonPP.project
View file @
f5432bef
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project
Name=
"JsonPP"
InternalType=
"Library"
>
<CodeLite_Project
Name=
"JsonPP"
InternalType=
"Library"
Version=
"10.0.0"
>
<Plugins>
<Plugin
Name=
"qmake"
>
<![CDATA[000
20001N0005Debug0000000000000001N0007Release
000000000000]]>
<![CDATA[000
40001N0005Debug0000000000000001N0007Release0000000000000001N0019Release_RaspberryPi0000000000000001N0014Release_Ubuntu
000000000000]]>
</Plugin>
</Plugins>
<Description/>
...
...
@@ -25,6 +25,51 @@
</Linker>
<ResourceCompiler
Options=
""
/>
</GlobalSettings>
<Configuration
Name=
"Release_RaspberryPi"
CompilerType=
"Cross GCC ( arm-linux-gnueabihf )"
DebuggerType=
"GNU gdb debugger"
Type=
"Dynamic Library"
BuildCmpWithGlobalSettings=
"append"
BuildLnkWithGlobalSettings=
"append"
BuildResWithGlobalSettings=
"append"
>
<Compiler
Options=
"-pedantic-errors;-Wfatal-errors;-g;-O0;-pedantic;-W;-std=c++11;-Wall;-fPIC"
C_Options=
""
Assembler=
""
Required=
"yes"
PreCompiledHeader=
""
PCHInCommandLine=
"no"
PCHFlags=
""
PCHFlagsPolicy=
"0"
>
<IncludePath
Value=
"."
/>
<IncludePath
Value=
"../../include"
/>
</Compiler>
<Linker
Options=
""
Required=
"yes"
/>
<ResourceCompiler
Options=
""
Required=
"no"
/>
<General
OutputFile=
"$(IntermediateDirectory)/$(ProjectName).so"
IntermediateDirectory=
"./Release"
Command=
""
CommandArguments=
""
UseSeparateDebugArgs=
"no"
DebugArguments=
""
WorkingDirectory=
"$(IntermediateDirectory)"
PauseExecWhenProcTerminates=
"yes"
IsGUIProgram=
"no"
IsEnabled=
"yes"
/>
<BuildSystem
Name=
"Default"
/>
<Environment
EnvVarSetName=
"<Use Defaults>"
DbgSetName=
"<Use Defaults>"
>
<![CDATA[]]>
</Environment>
<Debugger
IsRemote=
"no"
RemoteHostName=
""
RemoteHostPort=
""
DebuggerPath=
""
IsExtended=
"yes"
>
<DebuggerSearchPaths/>
<PostConnectCommands/>
<StartupCommands/>
</Debugger>
<PreBuild/>
<PostBuild>
<Command
Enabled=
"yes"
>
cp Release/JsonPP.so /opt/lib/pi
</Command>
<Command
Enabled=
"yes"
>
cp ../../include/JsonPP.h /opt/include
</Command>
<Command
Enabled=
"yes"
>
cp ../../include/Value.h /opt/include
</Command>
<Command
Enabled=
"yes"
>
sshpass -p "raspberry" scp Release/JsonPP.so pi@200.150.100.85:/opt/lib/pi
</Command>
</PostBuild>
<CustomBuild
Enabled=
"no"
>
<RebuildCommand/>
<CleanCommand/>
<BuildCommand/>
<PreprocessFileCommand/>
<SingleFileCommand/>
<MakefileGenerationCommand/>
<ThirdPartyToolName/>
<WorkingDirectory/>
</CustomBuild>
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
<Completion
EnableCpp11=
"no"
EnableCpp14=
"no"
>
<ClangCmpFlagsC/>
<ClangCmpFlags/>
<ClangPP/>
<SearchPaths/>
</Completion>
</Configuration>
<Configuration
Name=
"Release_Ubuntu"
CompilerType=
"GCC"
DebuggerType=
"GNU gdb debugger"
Type=
"Dynamic Library"
BuildCmpWithGlobalSettings=
"append"
BuildLnkWithGlobalSettings=
"append"
BuildResWithGlobalSettings=
"append"
>
<Compiler
Options=
"-O1;-O;-O0;-O2;-std=c++14;-Wall;-fPIC"
C_Options=
""
Assembler=
""
Required=
"yes"
PreCompiledHeader=
""
PCHInCommandLine=
"no"
PCHFlags=
""
PCHFlagsPolicy=
"0"
>
<IncludePath
Value=
"."
/>
...
...
@@ -33,6 +78,7 @@
<Linker
Options=
"-Os"
Required=
"yes"
/>
<ResourceCompiler
Options=
""
Required=
"no"
/>
<General
OutputFile=
"$(IntermediateDirectory)/$(ProjectName).so"
IntermediateDirectory=
"./Release"
Command=
""
CommandArguments=
""
UseSeparateDebugArgs=
"no"
DebugArguments=
""
WorkingDirectory=
"$(IntermediateDirectory)"
PauseExecWhenProcTerminates=
"yes"
IsGUIProgram=
"no"
IsEnabled=
"yes"
/>
<BuildSystem
Name=
"Default"
/>
<Environment
EnvVarSetName=
"<Use Defaults>"
DbgSetName=
"<Use Defaults>"
>
<![CDATA[]]>
</Environment>
...
...
@@ -42,7 +88,11 @@
<StartupCommands/>
</Debugger>
<PreBuild/>
<PostBuild/>
<PostBuild>
<Command
Enabled=
"yes"
>
cp Release/JsonPP.so /opt/lib
</Command>
<Command
Enabled=
"yes"
>
cp ../../include/JsonPP.h /opt/include
</Command>
<Command
Enabled=
"yes"
>
cp ../../include/Value.h /opt/include
</Command>
</PostBuild>
<CustomBuild
Enabled=
"no"
>
<RebuildCommand/>
<CleanCommand/>
...
...
IDEs/CodeLite/JsonPP.workspace
View file @
f5432bef
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace
Name=
"JsonPP"
Database=
""
>
<CodeLite_Workspace
Name=
"JsonPP"
Database=
""
Version=
"10.0.0"
>
<Project
Name=
"JsonPP"
Path=
"JsonPP.project"
Active=
"Yes"
/>
<BuildMatrix>
<WorkspaceConfiguration
Name=
"Release_Ubuntu"
Selected=
"yes"
>
<Environment/>
<Project
Name=
"JsonPP"
ConfigName=
"Release_Ubuntu"
/>
</WorkspaceConfiguration>
<WorkspaceConfiguration
Name=
"Release_RaspberryPi"
Selected=
"no"
>
<Environment/>
<Project
Name=
"JsonPP"
ConfigName=
"Release_RaspberryPi"
/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
include/JsonPP.h
View file @
f5432bef
...
...
@@ -10,7 +10,6 @@ namespace Json {
class
JsonPP
{
JsonPP
();
static
Value
arrayFromString
(
std
::
string
jsonArrayString
);
public:
static
Value
objectFromString
(
std
::
string
jsonString
);
...
...
include/Value.h
View file @
f5432bef
...
...
@@ -58,7 +58,9 @@ public:
Value
&
operator
=
(
Value
&&
other
);
Value
&
operator
[](
const
std
::
string
&
key
);
const
Value
&
operator
[](
const
std
::
string
&
key
)
const
;
Value
&
operator
[](
const
int
key
);
const
Value
&
operator
[](
const
int
key
)
const
;
explicit
operator
double
()
const
{
return
_dobValue
;
}
explicit
operator
int
()
const
{
return
_intValue
;
}
...
...
@@ -69,15 +71,15 @@ public:
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Value
&
val
);
ValueType
type
();
ValueType
type
()
const
;
int
toInt
();
double
toDouble
();
std
::
string
&
toString
()
;
bool
toBool
();
int
toInt
()
const
;
double
toDouble
()
const
;
const
std
::
string
&
toString
()
const
;
bool
toBool
()
const
;
Array
toArray
();
Object
toObject
();
Array
toArray
()
const
;
Object
toObject
()
const
;
};
}
...
...
src/JsonPP.cpp
View file @
f5432bef
...
...
@@ -455,7 +455,7 @@ Value JsonPP::objectFromString(std::string jsonString)
std
::
string
JsonPP
::
stringFromObject
(
Object
&
jsonObject
)
{
auto
jss
=
std
::
stringstream
{}
;
std
::
stringstream
jss
;
jss
<<
jsonObject
;
return
jss
.
str
();
}
...
...
src/Value.cpp
View file @
f5432bef
...
...
@@ -4,11 +4,13 @@
using
namespace
std
;
namespace
Ccd
{
namespace
Json
{
namespace
Ccd
{
namespace
Json
{
Value
::
Value
()
:
_type
(
ValueType
::
Null
)
{}
Value
::
Value
(
const
int
value
)
:
_type
(
ValueType
::
Int
),
_intValue
(
value
)
{
}
Value
::
Value
(
const
double
value
)
:
_type
(
ValueType
::
Double
),
_dobValue
(
value
)
{}
...
...
@@ -23,99 +25,99 @@ Value::Value ( const Array& array ) : _type ( ValueType::Array ), _aryValue ( ar
Value
::
Value
(
const
Object
&
obj
)
:
_type
(
ValueType
::
Object
),
_objValue
(
obj
)
{}
Value
::
Value
(
std
::
string
&&
value
)
:
_type
(
ValueType
::
String
),
_strValue
(
move
(
value
)
)
{}
Value
::
Value
(
std
::
string
&&
value
)
:
_type
(
ValueType
::
String
),
_strValue
(
move
(
value
)
)
{}
Value
::
Value
(
Array
&&
array
)
:
_type
(
ValueType
::
Array
),
_aryValue
(
move
(
array
)
)
{}
Value
::
Value
(
Array
&&
array
)
:
_type
(
ValueType
::
Array
),
_aryValue
(
move
(
array
)
)
{}
Value
::
Value
(
Object
&&
obj
)
:
_type
(
ValueType
::
Object
),
_objValue
(
move
(
obj
)
)
{}
Value
::
Value
(
Object
&&
obj
)
:
_type
(
ValueType
::
Object
),
_objValue
(
move
(
obj
)
)
{}
Value
::
Value
(
std
::
nullptr_t
np
)
:
_type
(
ValueType
::
Null
)
{}
Value
::
Value
(
const
initializer_list
<
Value
>
list
)
:
_type
(
ValueType
::
Array
),
_aryValue
(
list
)
{};
Value
::
Value
(
const
initializer_list
<
Value
>
list
)
:
_type
(
ValueType
::
Array
),
_aryValue
(
list
)
{}
Value
::
Value
(
const
Value
&
other
)
Value
::
Value
(
const
Value
&
other
)
{
_type
=
other
.
_type
;
switch
(
other
.
_type
)
{
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
other
.
_strValue
;
break
;
case
ValueType
::
Object
:
_objValue
=
other
.
_objValue
;
break
;
case
ValueType
::
Array
:
_aryValue
=
other
.
_aryValue
;
break
;
case
ValueType
::
Null
:
default:
break
;
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
other
.
_strValue
;
break
;
case
ValueType
::
Object
:
_objValue
=
other
.
_objValue
;
break
;
case
ValueType
::
Array
:
_aryValue
=
other
.
_aryValue
;
break
;
case
ValueType
::
Null
:
default:
break
;
}
}
Value
::
Value
(
Value
&&
other
)
Value
::
Value
(
Value
&&
other
)
{
_type
=
other
.
_type
;
switch
(
other
.
_type
)
{
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
move
(
other
.
_strValue
);
break
;
case
ValueType
::
Object
:
_objValue
=
move
(
other
.
_objValue
);
break
;
case
ValueType
::
Array
:
_aryValue
=
move
(
other
.
_aryValue
);
break
;
case
ValueType
::
Null
:
default:
break
;
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
move
(
other
.
_strValue
);
break
;
case
ValueType
::
Object
:
_objValue
=
move
(
other
.
_objValue
);
break
;
case
ValueType
::
Array
:
_aryValue
=
move
(
other
.
_aryValue
);
break
;
case
ValueType
::
Null
:
default:
break
;
}
}
Value
&
Value
::
operator
=
(
const
Value
&
other
)
Value
&
Value
::
operator
=
(
const
Value
&
other
)
{
_type
=
other
.
_type
;
switch
(
other
.
_type
)
{
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
other
.
_strValue
;
break
;
case
ValueType
::
Object
:
_objValue
=
other
.
_objValue
;
break
;
case
ValueType
::
Array
:
_aryValue
=
other
.
_aryValue
;
break
;
case
ValueType
::
Null
:
default:
break
;
case
ValueType
::
Int
:
_intValue
=
other
.
_intValue
;
break
;
case
ValueType
::
Double
:
_dobValue
=
other
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
_bolValue
=
other
.
_bolValue
;
break
;
case
ValueType
::
String
:
_strValue
=
other
.
_strValue
;
break
;
case
ValueType
::
Object
:
_objValue
=
other
.
_objValue
;
break
;
case
ValueType
::
Array
:
_aryValue
=
other
.
_aryValue
;
break
;
case
ValueType
::
Null
:
default:
break
;
}
return
*
this
;
}
...
...
@@ -123,94 +125,115 @@ Value& Value::operator = ( Value&& other )
{
_type
=
other
.
_type
;
switch
(
other
.
_type
)
{
case
ValueType
::
Int
:
_intValue
=
move
(
other
.
_intValue
);
break
;
case
ValueType
::
Double
:
_dobValue
=
move
(
other
.
_dobValue
);
break
;
case
ValueType
::
Bool
:
_bolValue
=
move
(
other
.
_bolValue
);
break
;
case
ValueType
::
String
:
_strValue
=
move
(
other
.
_strValue
);
break
;
case
ValueType
::
Object
:
_objValue
=
move
(
other
.
_objValue
);
break
;
case
ValueType
::
Array
:
_aryValue
=
move
(
other
.
_aryValue
);
break
;
case
ValueType
::
Null
:
default:
break
;
case
ValueType
::
Int
:
_intValue
=
move
(
other
.
_intValue
);
break
;
case
ValueType
::
Double
:
_dobValue
=
move
(
other
.
_dobValue
);
break
;
case
ValueType
::
Bool
:
_bolValue
=
move
(
other
.
_bolValue
);
break
;
case
ValueType
::
String
:
_strValue
=
move
(
other
.
_strValue
);
break
;
case
ValueType
::
Object
:
_objValue
=
move
(
other
.
_objValue
);
break
;
case
ValueType
::
Array
:
_aryValue
=
move
(
other
.
_aryValue
);
break
;
case
ValueType
::
Null
:
default:
break
;
}
return
*
this
;
}
Value
&
Value
::
operator
[]
(
const
std
::
string
&
key
)
Value
&
Value
::
operator
[]
(
const
std
::
string
&
key
)
{
if
(
_type
==
ValueType
::
Null
){
if
(
_type
==
ValueType
::
Null
)
{
_type
=
ValueType
::
Object
;
}
if
(
_type
!=
ValueType
::
Object
)
throw
std
::
string
(
"Item is no Object"
);
throw
std
::
string
(
"Item is no Object"
);
return
_objValue
[
key
];
}
Value
&
Value
::
operator
[](
const
int
key
)
const
Value
&
Value
::
operator
[]
(
const
std
::
string
&
key
)
const
{
if
(
_type
!=
ValueType
::
Object
)
throw
std
::
string
(
"Item is no Object"
);
try
{
return
_objValue
.
at
(
key
);
}
catch
(
const
std
::
out_of_range
&
oor
)
{
//std::cerr << "Out of Range error (" << key << "): " << oor.what() << '\n';
return
*
this
;
}
}
Value
&
Value
::
operator
[]
(
const
int
key
)
{
if
(
_type
!=
ValueType
::
Array
)
throw
std
::
string
(
"Item is no Array"
);
throw
std
::
string
(
"Item is no Array"
);
return
_aryValue
[
key
];
}
const
Value
&
Value
::
operator
[]
(
const
int
key
)
const
{
if
(
_type
!=
ValueType
::
Array
)
throw
std
::
string
(
"Item is no Array"
);
return
_aryValue
[
key
];
}
ValueType
Value
::
type
()
ValueType
Value
::
type
()
const
{
return
_type
;
}
int
Value
::
toInt
()
int
Value
::
toInt
()
const
{
return
_intValue
;
}
double
Value
::
toDouble
()
double
Value
::
toDouble
()
const
{
return
_dobValue
;
}
std
::
string
&
Value
::
toString
()
const
std
::
string
&
Value
::
toString
()
const
{
return
_strValue
;
}
bool
Value
::
toBool
()
bool
Value
::
toBool
()
const
{
return
_bolValue
;
}
Array
Value
::
toArray
()
Array
Value
::
toArray
()
const
{
return
_aryValue
;
}
Object
Value
::
toObject
()
Object
Value
::
toObject
()
const
{
return
_objValue
;
}
static
unsigned
int
indentLvl
=
0
;
inline
static
void
indent
(
std
::
ostream
&
os
)
inline
static
void
indent
(
std
::
ostream
&
os
)
{
for
(
auto
indentIdx
=
0u
;
indentIdx
<
indentLvl
;
indentIdx
++
)
{
os
<<
"
\t
"
;
os
<<
"
\t
"
;
}
}
...
...
@@ -218,17 +241,17 @@ std::ostream& operator<< ( std::ostream& os, const Object& obj )
{
os
<<
"{"
<<
std
::
endl
;
indentLvl
++
;
for
(
auto
item
=
obj
.
begin
()
;
item
!=
obj
.
end
();
)
{
indent
(
os
);
indent
(
os
);
os
<<
"
\"
"
+
item
->
first
+
"
\"
:"
<<
item
->
second
;
if
(
++
item
!=
obj
.
end
()
)
os
<<
","
<<
std
::
endl
;
}
os
<<
std
::
endl
;
indentLvl
--
;
indent
(
os
);
indent
(
os
);
os
<<
"}"
;
return
os
;
...
...
@@ -250,29 +273,29 @@ std::ostream & operator<< ( std::ostream & os, const Array& array )
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Value
&
val
)
{
switch
(
val
.
_type
)
{
case
ValueType
::
Int
:
os
<<
val
.
_intValue
;
break
;
case
ValueType
::
Double
:
os
<<
val
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
os
<<
(
val
.
_bolValue
?
"true"
:
"false"
);
break
;
case
ValueType
::
String
:
os
<<
"
\"
"
+
val
.
_strValue
+
"
\"
"
;
break
;
case
ValueType
::
Object
:
os
<<
val
.
_objValue
;
break
;
case
ValueType
::
Array
:
os
<<
val
.
_aryValue
;
break
;
case
ValueType
::
Null
:
os
<<
"null"
;
break
;
default:
break
;
case
ValueType
::
Int
:
os
<<
val
.
_intValue
;
break
;
case
ValueType
::
Double
:
os
<<
val
.
_dobValue
;
break
;
case
ValueType
::
Bool
:
os
<<
(
val
.
_bolValue
?
"true"
:
"false"
);
break
;
case
ValueType
::
String
:
os
<<
"
\"
"
+
val
.
_strValue
+
"
\"
"
;
break
;
case
ValueType
::
Object
:
os
<<
val
.
_objValue
;
break
;
case
ValueType
::
Array
:
os
<<
val
.
_aryValue
;
break
;
case
ValueType
::
Null
:
os
<<
"null"
;
break
;
default:
break
;
}
return
os
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment