Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
76b49f9e
Commit
76b49f9e
authored
May 28, 2020
by
Francois Chabot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc formatting fixes
parent
377995f4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
199 additions
and
52 deletions
+199
-52
.clang-format
.clang-format
+137
-0
input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+26
-21
json.hpp
include/nlohmann/json.hpp
+5
-5
json.hpp
single_include/nlohmann/json.hpp
+31
-26
No files found.
.clang-format
0 → 100644
View file @
76b49f9e
---
Language: Cpp
# BasedOnStyle: Mozilla
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 180
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...
include/nlohmann/detail/input/input_adapters.hpp
View file @
76b49f9e
...
@@ -104,7 +104,7 @@ class input_stream_adapter
...
@@ -104,7 +104,7 @@ class input_stream_adapter
{
{
auto
res
=
sb
->
sbumpc
();
auto
res
=
sb
->
sbumpc
();
// set eof manually, as we don't use the istream interface.
// set eof manually, as we don't use the istream interface.
if
(
res
==
EOF
)
if
(
JSON_HEDLEY_UNLIKELY
(
res
==
EOF
)
)
{
{
is
->
clear
(
is
->
rdstate
()
|
std
::
ios
::
eofbit
);
is
->
clear
(
is
->
rdstate
()
|
std
::
ios
::
eofbit
);
}
}
...
@@ -130,7 +130,7 @@ class iterator_input_adapter
...
@@ -130,7 +130,7 @@ class iterator_input_adapter
typename
std
::
char_traits
<
char_type
>::
int_type
get_character
()
typename
std
::
char_traits
<
char_type
>::
int_type
get_character
()
{
{
if
(
current
!=
end
)
if
(
JSON_HEDLEY_LIKELY
(
current
!=
end
)
)
{
{
auto
result
=
std
::
char_traits
<
char_type
>::
to_int_type
(
*
current
);
auto
result
=
std
::
char_traits
<
char_type
>::
to_int_type
(
*
current
);
std
::
advance
(
current
,
1
);
std
::
advance
(
current
,
1
);
...
@@ -171,7 +171,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
...
@@ -171,7 +171,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
{
{
utf8_bytes_index
=
0
;
utf8_bytes_index
=
0
;
if
(
input
.
empty
(
))
if
(
JSON_HEDLEY_UNLIKELY
(
input
.
empty
()
))
{
{
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes_filled
=
1
;
utf8_bytes_filled
=
1
;
...
@@ -229,7 +229,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
...
@@ -229,7 +229,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
{
{
utf8_bytes_index
=
0
;
utf8_bytes_index
=
0
;
if
(
input
.
empty
(
))
if
(
JSON_HEDLEY_UNLIKELY
(
input
.
empty
()
))
{
{
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes_filled
=
1
;
utf8_bytes_filled
=
1
;
...
@@ -331,34 +331,39 @@ struct iterator_input_adapter_factory
...
@@ -331,34 +331,39 @@ struct iterator_input_adapter_factory
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
static
adapter_type
create
(
IteratorType
begin
,
IteratorType
end
)
static
adapter_type
create
(
IteratorType
first
,
IteratorType
last
)
{
{
return
adapter_type
(
std
::
move
(
begin
),
std
::
move
(
end
));
return
adapter_type
(
std
::
move
(
first
),
std
::
move
(
last
));
}
}
};
};
template
<
typename
IteratorType
>
// This test breaks astyle formatting when inlined in a template specialization.
struct
iterator_input_adapter_factory
<
IteratorType
,
template
<
typename
T
>
typename
std
::
enable_if
<
(
sizeof
(
typename
std
::
iterator_traits
<
IteratorType
>::
value_type
)
>
1
)
>::
type
>
inline
constexpr
bool
is_iterator_of_multibyte
()
{
using
iterator_type
=
IteratorType
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
base_adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
wide_string_input_adapter
<
base_adapter_type
,
char_type
>
;
static
adapter_type
create
(
IteratorType
begin
,
IteratorType
end
)
{
{
return
adapter_type
(
base_adapter_type
(
std
::
move
(
begin
),
std
::
move
(
end
)))
;
return
sizeof
(
typename
std
::
iterator_traits
<
T
>::
value_type
)
>
1
;
}
}
};
template
<
typename
IteratorType
>
struct
iterator_input_adapter_factory
<
IteratorType
,
enable_if_t
<
is_iterator_of_multibyte
<
IteratorType
>
()
>>
{
using
iterator_type
=
IteratorType
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
base_adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
wide_string_input_adapter
<
base_adapter_type
,
char_type
>
;
static
adapter_type
create
(
IteratorType
first
,
IteratorType
last
)
{
return
adapter_type
(
base_adapter_type
(
std
::
move
(
first
),
std
::
move
(
last
)));
}
};
// General purpose iterator-based input
// General purpose iterator-based input
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
typename
iterator_input_adapter_factory
<
IteratorType
>::
adapter_type
input_adapter
(
IteratorType
begin
,
IteratorType
end
)
typename
iterator_input_adapter_factory
<
IteratorType
>::
adapter_type
input_adapter
(
IteratorType
first
,
IteratorType
last
)
{
{
using
factory_type
=
iterator_input_adapter_factory
<
IteratorType
>
;
using
factory_type
=
iterator_input_adapter_factory
<
IteratorType
>
;
return
factory_type
::
create
(
begin
,
end
);
return
factory_type
::
create
(
first
,
last
);
}
}
// Convenience shorthand from container to iterator
// Convenience shorthand from container to iterator
...
...
include/nlohmann/json.hpp
View file @
76b49f9e
...
@@ -6623,13 +6623,13 @@ class basic_json
...
@@ -6623,13 +6623,13 @@ class basic_json
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
parse
(
IteratorType
begin
,
static
basic_json
parse
(
IteratorType
first
,
IteratorType
end
,
IteratorType
last
,
const
parser_callback_t
cb
=
nullptr
,
const
parser_callback_t
cb
=
nullptr
,
const
bool
allow_exceptions
=
true
)
const
bool
allow_exceptions
=
true
)
{
{
basic_json
result
;
basic_json
result
;
parser
(
detail
::
input_adapter
(
std
::
move
(
begin
),
std
::
move
(
end
)),
cb
,
allow_exceptions
).
parse
(
true
,
result
);
parser
(
detail
::
input_adapter
(
std
::
move
(
first
),
std
::
move
(
last
)),
cb
,
allow_exceptions
).
parse
(
true
,
result
);
return
result
;
return
result
;
}
}
...
@@ -6650,9 +6650,9 @@ class basic_json
...
@@ -6650,9 +6650,9 @@ class basic_json
}
}
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
static
bool
accept
(
IteratorType
begin
,
IteratorType
end
)
static
bool
accept
(
IteratorType
first
,
IteratorType
last
)
{
{
return
parser
(
detail
::
input_adapter
(
std
::
move
(
begin
),
std
::
move
(
end
))).
accept
(
true
);
return
parser
(
detail
::
input_adapter
(
std
::
move
(
first
),
std
::
move
(
last
))).
accept
(
true
);
}
}
static
bool
accept
(
detail
::
span_input_adapter
&&
i
)
static
bool
accept
(
detail
::
span_input_adapter
&&
i
)
...
...
single_include/nlohmann/json.hpp
View file @
76b49f9e
...
@@ -4526,7 +4526,7 @@ class input_stream_adapter
...
@@ -4526,7 +4526,7 @@ class input_stream_adapter
{
{
auto
res
=
sb
->
sbumpc
();
auto
res
=
sb
->
sbumpc
();
// set eof manually, as we don't use the istream interface.
// set eof manually, as we don't use the istream interface.
if
(
res
==
EOF
)
if
(
JSON_HEDLEY_UNLIKELY
(
res
==
EOF
)
)
{
{
is
->
clear
(
is
->
rdstate
()
|
std
::
ios
::
eofbit
);
is
->
clear
(
is
->
rdstate
()
|
std
::
ios
::
eofbit
);
}
}
...
@@ -4552,7 +4552,7 @@ class iterator_input_adapter
...
@@ -4552,7 +4552,7 @@ class iterator_input_adapter
typename
std
::
char_traits
<
char_type
>::
int_type
get_character
()
typename
std
::
char_traits
<
char_type
>::
int_type
get_character
()
{
{
if
(
current
!=
end
)
if
(
JSON_HEDLEY_LIKELY
(
current
!=
end
)
)
{
{
auto
result
=
std
::
char_traits
<
char_type
>::
to_int_type
(
*
current
);
auto
result
=
std
::
char_traits
<
char_type
>::
to_int_type
(
*
current
);
std
::
advance
(
current
,
1
);
std
::
advance
(
current
,
1
);
...
@@ -4593,7 +4593,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
...
@@ -4593,7 +4593,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
{
{
utf8_bytes_index
=
0
;
utf8_bytes_index
=
0
;
if
(
input
.
empty
(
))
if
(
JSON_HEDLEY_UNLIKELY
(
input
.
empty
()
))
{
{
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes_filled
=
1
;
utf8_bytes_filled
=
1
;
...
@@ -4651,7 +4651,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
...
@@ -4651,7 +4651,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
{
{
utf8_bytes_index
=
0
;
utf8_bytes_index
=
0
;
if
(
input
.
empty
(
))
if
(
JSON_HEDLEY_UNLIKELY
(
input
.
empty
()
))
{
{
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes
[
0
]
=
std
::
char_traits
<
char
>::
eof
();
utf8_bytes_filled
=
1
;
utf8_bytes_filled
=
1
;
...
@@ -4753,34 +4753,39 @@ struct iterator_input_adapter_factory
...
@@ -4753,34 +4753,39 @@ struct iterator_input_adapter_factory
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
static
adapter_type
create
(
IteratorType
begin
,
IteratorType
end
)
static
adapter_type
create
(
IteratorType
first
,
IteratorType
last
)
{
{
return
adapter_type
(
std
::
move
(
begin
),
std
::
move
(
end
));
return
adapter_type
(
std
::
move
(
first
),
std
::
move
(
last
));
}
}
};
};
template
<
typename
IteratorType
>
// This test breaks astyle formatting when inlined in a template specialization.
struct
iterator_input_adapter_factory
<
IteratorType
,
template
<
typename
T
>
typename
std
::
enable_if
<
(
sizeof
(
typename
std
::
iterator_traits
<
IteratorType
>::
value_type
)
>
1
)
>::
type
>
inline
constexpr
bool
is_iterator_of_multibyte
()
{
using
iterator_type
=
IteratorType
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
base_adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
wide_string_input_adapter
<
base_adapter_type
,
char_type
>
;
static
adapter_type
create
(
IteratorType
begin
,
IteratorType
end
)
{
{
return
adapter_type
(
base_adapter_type
(
std
::
move
(
begin
),
std
::
move
(
end
)))
;
return
sizeof
(
typename
std
::
iterator_traits
<
T
>::
value_type
)
>
1
;
}
}
};
template
<
typename
IteratorType
>
struct
iterator_input_adapter_factory
<
IteratorType
,
enable_if_t
<
is_iterator_of_multibyte
<
IteratorType
>
()
>>
{
using
iterator_type
=
IteratorType
;
using
char_type
=
typename
std
::
iterator_traits
<
iterator_type
>::
value_type
;
using
base_adapter_type
=
iterator_input_adapter
<
iterator_type
>
;
using
adapter_type
=
wide_string_input_adapter
<
base_adapter_type
,
char_type
>
;
static
adapter_type
create
(
IteratorType
first
,
IteratorType
last
)
{
return
adapter_type
(
base_adapter_type
(
std
::
move
(
first
),
std
::
move
(
last
)));
}
};
// General purpose iterator-based input
// General purpose iterator-based input
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
typename
iterator_input_adapter_factory
<
IteratorType
>::
adapter_type
input_adapter
(
IteratorType
begin
,
IteratorType
end
)
typename
iterator_input_adapter_factory
<
IteratorType
>::
adapter_type
input_adapter
(
IteratorType
first
,
IteratorType
last
)
{
{
using
factory_type
=
iterator_input_adapter_factory
<
IteratorType
>
;
using
factory_type
=
iterator_input_adapter_factory
<
IteratorType
>
;
return
factory_type
::
create
(
begin
,
end
);
return
factory_type
::
create
(
first
,
last
);
}
}
// Convenience shorthand from container to iterator
// Convenience shorthand from container to iterator
...
@@ -22381,13 +22386,13 @@ class basic_json
...
@@ -22381,13 +22386,13 @@ class basic_json
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_WARN_UNUSED_RESULT
static
basic_json
parse
(
IteratorType
begin
,
static
basic_json
parse
(
IteratorType
first
,
IteratorType
end
,
IteratorType
last
,
const
parser_callback_t
cb
=
nullptr
,
const
parser_callback_t
cb
=
nullptr
,
const
bool
allow_exceptions
=
true
)
const
bool
allow_exceptions
=
true
)
{
{
basic_json
result
;
basic_json
result
;
parser
(
detail
::
input_adapter
(
std
::
move
(
begin
),
std
::
move
(
end
)),
cb
,
allow_exceptions
).
parse
(
true
,
result
);
parser
(
detail
::
input_adapter
(
std
::
move
(
first
),
std
::
move
(
last
)),
cb
,
allow_exceptions
).
parse
(
true
,
result
);
return
result
;
return
result
;
}
}
...
@@ -22408,9 +22413,9 @@ class basic_json
...
@@ -22408,9 +22413,9 @@ class basic_json
}
}
template
<
typename
IteratorType
>
template
<
typename
IteratorType
>
static
bool
accept
(
IteratorType
begin
,
IteratorType
end
)
static
bool
accept
(
IteratorType
first
,
IteratorType
last
)
{
{
return
parser
(
detail
::
input_adapter
(
std
::
move
(
begin
),
std
::
move
(
end
))).
accept
(
true
);
return
parser
(
detail
::
input_adapter
(
std
::
move
(
first
),
std
::
move
(
last
))).
accept
(
true
);
}
}
static
bool
accept
(
detail
::
span_input_adapter
&&
i
)
static
bool
accept
(
detail
::
span_input_adapter
&&
i
)
...
...
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