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
e0f1de6a
Commit
e0f1de6a
authored
Feb 14, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLI improvements
parent
d9ed8194
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
src/gnb/types.cpp
src/gnb/types.cpp
+1
-1
src/utils/json.cpp
src/utils/json.cpp
+10
-9
src/utils/json.hpp
src/utils/json.hpp
+5
-3
No files found.
src/gnb/types.cpp
View file @
e0f1de6a
...
...
@@ -37,7 +37,7 @@ Json ToJson(const GnbConfig &v)
Json
ToJson
(
const
NgapAmfContext
&
v
)
{
return
Json
::
Obj
({
{
"
ctx-
id"
,
v
.
ctxId
},
{
"id"
,
v
.
ctxId
},
{
"name"
,
v
.
amfName
},
{
"address"
,
v
.
address
+
":"
+
std
::
to_string
(
v
.
port
)},
{
"state"
,
ToJson
(
v
.
state
).
str
()},
...
...
src/utils/json.cpp
View file @
e0f1de6a
...
...
@@ -304,9 +304,8 @@ Json Json::Arr(std::initializer_list<Json> &&elements)
{
Json
json
{};
json
.
m_type
=
Type
::
ARRAY
;
int
index
=
0
;
for
(
auto
&
item
:
elements
)
json
.
m_children
[
std
::
to_string
(
index
++
)]
=
item
;
json
.
push
(
item
)
;
return
json
;
}
...
...
@@ -314,9 +313,8 @@ Json Json::Arr(const std::vector<Json> &elements)
{
Json
json
{};
json
.
m_type
=
Type
::
ARRAY
;
int
index
=
0
;
for
(
auto
&
item
:
elements
)
json
.
m_children
[
std
::
to_string
(
index
++
)]
=
item
;
json
.
push
(
item
)
;
return
json
;
}
...
...
@@ -324,9 +322,8 @@ Json Json::Arr(std::vector<Json> &&elements)
{
Json
json
{};
json
.
m_type
=
Type
::
ARRAY
;
int
index
=
0
;
for
(
auto
&
item
:
elements
)
json
.
m_children
[
std
::
to_string
(
index
++
)]
=
std
::
move
(
item
);
json
.
push
(
std
::
move
(
item
)
);
return
json
;
}
...
...
@@ -335,7 +332,7 @@ Json Json::Obj(std::initializer_list<std::pair<std::string, Json>> &&elements)
Json
json
{};
json
.
m_type
=
Type
::
OBJECT
;
for
(
auto
&
item
:
elements
)
json
.
m_children
[
item
.
first
]
=
item
.
second
;
json
.
put
(
item
.
first
,
item
.
second
)
;
return
json
;
}
...
...
@@ -343,14 +340,18 @@ void Json::push(Json element)
{
if
(
m_type
!=
Type
::
ARRAY
)
return
;
m_children
[
std
::
to_string
(
m_children
.
size
())]
=
std
::
move
(
element
);
m_children
.
emplace_back
(
std
::
to_string
(
m_children
.
size
()),
std
::
move
(
element
));
}
void
Json
::
put
(
std
::
string
key
,
Json
value
)
{
if
(
m_type
!=
Type
::
OBJECT
)
return
;
m_children
[
std
::
move
(
key
)]
=
std
::
move
(
value
);
m_children
.
emplace_back
(
std
::
move
(
key
),
std
::
move
(
value
));
}
Json
ToJson
(
nullptr_t
)
...
...
src/utils/json.hpp
View file @
e0f1de6a
...
...
@@ -34,12 +34,14 @@ class Json
std
::
string
m_strVal
{};
int64_t
m_intVal
{};
// TODO: Switch to some ordered map (preserving insertion order)
std
::
map
<
std
::
string
,
Json
>
m_children
{};
// 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)
std
::
vector
<
std
::
pair
<
std
::
string
,
Json
>>
m_children
{};
private:
typedef
decltype
(
m_children
.
begin
())
iterator
;
typedef
decltype
(
const_cast
<
const
std
::
map
<
std
::
string
,
Json
>
&>
(
m_children
).
begin
())
const_iterator
;
typedef
decltype
(
const_cast
<
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Json
>
>
&>
(
m_children
).
begin
())
const_iterator
;
public:
Json
();
...
...
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