Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Libraries
UERANSIM
Commits
adbafa53
Commit
adbafa53
authored
Feb 14, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLI improvements
parent
e0f1de6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
src/utils/json.cpp
src/utils/json.cpp
+9
-1
src/utils/json.hpp
src/utils/json.hpp
+5
-3
No files found.
src/utils/json.cpp
View file @
adbafa53
...
...
@@ -349,7 +349,15 @@ void Json::put(std::string key, Json value)
if
(
m_type
!=
Type
::
OBJECT
)
return
;
// Replace if the key is already present
for
(
auto
&
item
:
m_children
)
{
if
(
item
.
first
==
key
)
{
item
.
second
=
std
::
move
(
value
);
return
;
}
}
m_children
.
emplace_back
(
std
::
move
(
key
),
std
::
move
(
value
));
}
...
...
src/utils/json.hpp
View file @
adbafa53
...
...
@@ -34,9 +34,11 @@ class Json
std
::
string
m_strVal
{};
int64_t
m_intVal
{};
// Holding children via vector instead of map/unordered_map (because insertion order is needed to be preserved).
// Therefore remove operation will be O(n), but performance is not a concern for JSONs. (and add operation is also
// O(n) if we compare to check the key is already present)
// - Holding children via vector instead of map/unordered_map (because insertion order is needed to be preserved).
// Therefore add/remove operation is O(n), but performance is not a concern for JSONs. (Add operation is also
// O(n) since we compare to check the key is already present)
// - NOTE: We're using Json type itself here which is incomplete herein. But C++17 allows std::vector, std::list,
// and std::forward_list to have incomplete types. For older versions we would need pointer etc.
std
::
vector
<
std
::
pair
<
std
::
string
,
Json
>>
m_children
{};
private:
...
...
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