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
e8a6df12
Commit
e8a6df12
authored
Feb 14, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSON utility improvement
parent
4dc22ffc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
17 deletions
+66
-17
src/gnb/types.cpp
src/gnb/types.cpp
+26
-2
src/gnb/types.hpp
src/gnb/types.hpp
+3
-0
src/utils/common_types.cpp
src/utils/common_types.cpp
+6
-4
src/utils/common_types.hpp
src/utils/common_types.hpp
+1
-0
src/utils/json.cpp
src/utils/json.cpp
+0
-9
src/utils/json.hpp
src/utils/json.hpp
+30
-2
No files found.
src/gnb/types.cpp
View file @
e8a6df12
...
@@ -37,10 +37,14 @@ Json ToJson(const GnbConfig &v)
...
@@ -37,10 +37,14 @@ Json ToJson(const GnbConfig &v)
Json
ToJson
(
const
NgapAmfContext
&
v
)
Json
ToJson
(
const
NgapAmfContext
&
v
)
{
{
return
Json
::
Obj
({
return
Json
::
Obj
({
{
"ctx-id"
,
v
.
ctxId
},
{
"name"
,
v
.
amfName
},
{
"name"
,
v
.
amfName
},
{
"capacity"
,
v
.
relativeCapacity
},
{
"state"
,
ToJson
(
v
.
state
).
str
()},
{
"address"
,
v
.
address
+
":"
+
std
::
to_string
(
v
.
port
)},
{
"address"
,
v
.
address
+
":"
+
std
::
to_string
(
v
.
port
)},
{
"state"
,
ToJson
(
v
.
state
).
str
()},
{
"capacity"
,
v
.
relativeCapacity
},
{
"association"
,
ToJson
(
v
.
association
)},
{
"served-guami"
,
::
ToJson
(
v
.
servedGuamiList
)},
{
"served-plmn"
,
::
ToJson
(
v
.
plmnSupportList
)},
});
});
}
}
...
@@ -76,4 +80,24 @@ Json ToJson(const EPagingDrx &v)
...
@@ -76,4 +80,24 @@ Json ToJson(const EPagingDrx &v)
}
}
}
}
Json
ToJson
(
const
SctpAssociation
&
v
)
{
return
Json
::
Obj
({{
"id"
,
v
.
associationId
},
{
"rx-num"
,
v
.
inStreams
},
{
"tx-num"
,
v
.
outStreams
}});
}
Json
ToJson
(
const
ServedGuami
&
v
)
{
return
Json
::
Obj
({{
"guami"
,
ToJson
(
v
.
guami
)},
{
"backup-amf"
,
v
.
backupAmfName
}});
}
Json
ToJson
(
const
Guami
&
v
)
{
return
Json
::
Obj
({
{
"plmn"
,
ToJson
(
v
.
plmn
)},
{
"region-id"
,
::
ToJson
(
v
.
amfRegionId
)},
{
"set-id"
,
::
ToJson
(
v
.
amfSetId
)},
{
"pointer"
,
::
ToJson
(
v
.
amfPointer
)},
});
}
}
// namespace nr::gnb
}
// namespace nr::gnb
src/gnb/types.hpp
View file @
e8a6df12
...
@@ -303,5 +303,8 @@ Json ToJson(const GnbConfig &v);
...
@@ -303,5 +303,8 @@ Json ToJson(const GnbConfig &v);
Json
ToJson
(
const
NgapAmfContext
&
v
);
Json
ToJson
(
const
NgapAmfContext
&
v
);
Json
ToJson
(
const
EAmfState
&
v
);
Json
ToJson
(
const
EAmfState
&
v
);
Json
ToJson
(
const
EPagingDrx
&
v
);
Json
ToJson
(
const
EPagingDrx
&
v
);
Json
ToJson
(
const
SctpAssociation
&
v
);
Json
ToJson
(
const
ServedGuami
&
v
);
Json
ToJson
(
const
Guami
&
v
);
}
// namespace nr::gnb
}
// namespace nr::gnb
\ No newline at end of file
src/utils/common_types.cpp
View file @
e8a6df12
...
@@ -40,8 +40,10 @@ Json ToJson(const Plmn &v)
...
@@ -40,8 +40,10 @@ Json ToJson(const Plmn &v)
Json
ToJson
(
const
SliceSupport
&
v
)
Json
ToJson
(
const
SliceSupport
&
v
)
{
{
return
Json
::
Obj
({
return
Json
::
Obj
({{
"sst"
,
ToJson
(
v
.
sst
)},
{
"sd"
,
ToJson
(
v
.
sd
)}});
{
"sst"
,
ToJson
(
v
.
sst
)},
}
{
"sd"
,
ToJson
(
v
.
sd
)}
});
Json
ToJson
(
const
PlmnSupport
&
v
)
{
return
Json
::
Obj
({{
"plmn"
,
ToJson
(
v
.
plmn
)},
{
"nssai"
,
ToJson
(
v
.
sliceSupportList
)}});
}
}
src/utils/common_types.hpp
View file @
e8a6df12
...
@@ -121,3 +121,4 @@ struct Supi
...
@@ -121,3 +121,4 @@ struct Supi
Json
ToJson
(
const
Supi
&
v
);
Json
ToJson
(
const
Supi
&
v
);
Json
ToJson
(
const
Plmn
&
v
);
Json
ToJson
(
const
Plmn
&
v
);
Json
ToJson
(
const
SliceSupport
&
v
);
Json
ToJson
(
const
SliceSupport
&
v
);
Json
ToJson
(
const
PlmnSupport
&
v
);
src/utils/json.cpp
View file @
e8a6df12
...
@@ -208,10 +208,6 @@ Json::Json(std::string str) : m_type{Type::STRING}, m_strVal(std::move(str))
...
@@ -208,10 +208,6 @@ Json::Json(std::string str) : m_type{Type::STRING}, m_strVal(std::move(str))
{
{
}
}
Json
::
Json
(
const
char
*
str
)
:
m_type
{
Type
::
STRING
},
m_strVal
(
str
)
{
}
Json
::
Json
(
bool
v
)
:
m_type
{
Type
::
BOOL
},
m_strVal
(
v
?
"true"
:
"false"
),
m_intVal
{
v
}
Json
::
Json
(
bool
v
)
:
m_type
{
Type
::
BOOL
},
m_strVal
(
v
?
"true"
:
"false"
),
m_intVal
{
v
}
{
{
}
}
...
@@ -391,11 +387,6 @@ Json ToJson(const std::string &v)
...
@@ -391,11 +387,6 @@ Json ToJson(const std::string &v)
return
v
;
return
v
;
}
}
Json
ToJson
(
const
char
*
v
)
{
return
v
;
}
Json
ToJson
(
uint8_t
v
)
Json
ToJson
(
uint8_t
v
)
{
{
return
v
;
return
v
;
...
...
src/utils/json.hpp
View file @
e8a6df12
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <initializer_list>
#include <initializer_list>
#include <map>
#include <map>
#include <memory>
#include <optional>
#include <optional>
#include <string>
#include <string>
#include <utility>
#include <utility>
...
@@ -44,7 +45,6 @@ class Json
...
@@ -44,7 +45,6 @@ class Json
Json
();
Json
();
/* no-explicit */
Json
(
nullptr_t
v
);
/* no-explicit */
Json
(
nullptr_t
v
);
/* no-explicit */
Json
(
std
::
string
str
);
/* no-explicit */
Json
(
std
::
string
str
);
/* no-explicit */
Json
(
const
char
*
str
);
/* no-explicit */
Json
(
bool
v
);
/* no-explicit */
Json
(
bool
v
);
/* no-explicit */
Json
(
uint8_t
v
);
/* no-explicit */
Json
(
uint8_t
v
);
/* no-explicit */
Json
(
int8_t
v
);
/* no-explicit */
Json
(
int8_t
v
);
...
@@ -55,6 +55,14 @@ class Json
...
@@ -55,6 +55,14 @@ class Json
/* no-explicit */
Json
(
int64_t
v
);
/* no-explicit */
Json
(
int64_t
v
);
/* no-explicit */
Json
(
uint64_t
v
)
=
delete
;
/* no-explicit */
Json
(
uint64_t
v
)
=
delete
;
template
<
std
::
size_t
N
>
inline
/* no-explicit */
Json
(
const
char
(
&
v
)[
N
])
:
Json
(
std
::
string
(
v
))
{
}
template
<
typename
T
>
Json
(
T
)
=
delete
;
public:
public:
static
Json
Arr
(
std
::
initializer_list
<
Json
>
&&
elements
);
static
Json
Arr
(
std
::
initializer_list
<
Json
>
&&
elements
);
static
Json
Obj
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
Json
>>
&&
elements
);
static
Json
Obj
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
Json
>>
&&
elements
);
...
@@ -94,7 +102,6 @@ class Json
...
@@ -94,7 +102,6 @@ class Json
Json
ToJson
(
nullptr_t
);
Json
ToJson
(
nullptr_t
);
Json
ToJson
(
bool
v
);
Json
ToJson
(
bool
v
);
Json
ToJson
(
const
std
::
string
&
v
);
Json
ToJson
(
const
std
::
string
&
v
);
Json
ToJson
(
const
char
*
v
);
Json
ToJson
(
uint8_t
v
);
Json
ToJson
(
uint8_t
v
);
Json
ToJson
(
int8_t
v
);
Json
ToJson
(
int8_t
v
);
Json
ToJson
(
uint16_t
v
);
Json
ToJson
(
uint16_t
v
);
...
@@ -109,6 +116,24 @@ inline Json ToJson(const std::optional<T> &v)
...
@@ -109,6 +116,24 @@ inline Json ToJson(const std::optional<T> &v)
return
v
.
has_value
()
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
return
v
.
has_value
()
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
}
template
<
typename
T
>
inline
Json
ToJson
(
T
*
v
)
{
return
v
!=
nullptr
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
template
<
typename
T
>
inline
Json
ToJson
(
const
std
::
unique_ptr
<
T
>
&
v
)
{
return
v
!=
nullptr
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
template
<
typename
T
>
inline
Json
ToJson
(
const
T
*
v
)
{
return
v
!=
nullptr
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
template
<
typename
T
>
template
<
typename
T
>
inline
Json
ToJson
(
const
std
::
vector
<
T
>
&
v
)
inline
Json
ToJson
(
const
std
::
vector
<
T
>
&
v
)
{
{
...
@@ -117,3 +142,6 @@ inline Json ToJson(const std::vector<T> &v)
...
@@ -117,3 +142,6 @@ inline Json ToJson(const std::vector<T> &v)
j
.
push
(
ToJson
(
item
));
j
.
push
(
ToJson
(
item
));
return
j
;
return
j
;
}
}
template
<
typename
T
>
Json
ToJson
(
T
)
=
delete
;
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