Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xs-test
Project
Project
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
Patrick Chen
xs-test
Commits
e1b7d7de
Commit
e1b7d7de
authored
Aug 28, 2018
by
Patrick Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support condition in service
parent
27aa4d58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
Service.h
include/test/Service.h
+1
-0
Service.cc
src/test/Service.cc
+14
-1
No files found.
include/test/Service.h
View file @
e1b7d7de
...
...
@@ -32,6 +32,7 @@ namespace xs { namespace test
public
:
std
::
string
name_
;
boost
::
optional
<
nlohmann
::
json
>
condition_
;
boost
::
optional
<
nlohmann
::
json
>
response_
;
};
}
}
...
...
src/test/Service.cc
View file @
e1b7d7de
...
...
@@ -14,6 +14,10 @@ namespace xs { namespace test
{
if
(
object
.
count
(
"command"
))
{
response_
=
object
[
"response"
];
if
(
object
.
count
(
"condition"
))
{
condition_
=
object
[
"condition"
];
}
}
}
...
...
@@ -23,9 +27,18 @@ namespace xs { namespace test
return
false
;
}
static
const
auto
isStringOrObject
=
[](
const
nlohmann
::
json
&
object
)
{
return
object
.
is_string
()
||
object
.
is_object
();
};
if
(
object
.
count
(
"command"
))
{
if
(
object
.
count
(
"condition"
))
{
if
(
!
isStringOrObject
(
object
[
"condition"
]))
{
return
false
;
}
}
return
object
[
"command"
].
is_string
()
&&
(
object
[
"response"
].
is_string
()
||
object
[
"response"
].
is_object
()
)
&&
isStringOrObject
(
object
[
"response"
]
)
;
}
else
if
(
object
.
count
(
"event"
))
{
return
object
[
"event"
].
is_string
();
...
...
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