Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
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
董子豪
sgxwallet
Commits
36737159
Unverified
Commit
36737159
authored
Sep 05, 2019
by
ac10ef44eb72883e542a963cf52a088fc337b7a0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rpc server spec
parent
962da83f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
201 additions
and
0 deletions
+201
-0
abstractstubserver.h
abstractstubserver.h
+63
-0
spec.json
spec.json
+51
-0
stubclient.h
stubclient.h
+87
-0
No files found.
abstractstubserver.h
0 → 100644
View file @
36737159
/**
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
*/
#ifndef JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#define JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#include <jsonrpccpp/server.h>
class
AbstractStubServer
:
public
jsonrpc
::
AbstractServer
<
AbstractStubServer
>
{
public
:
AbstractStubServer
(
jsonrpc
::
AbstractServerConnector
&
conn
,
jsonrpc
::
serverVersion_t
type
=
jsonrpc
::
JSONRPC_SERVER_V2
)
:
jsonrpc
::
AbstractServer
<
AbstractStubServer
>
(
conn
,
type
)
{
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"sayHello"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_STRING
,
"name"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
sayHelloI
);
this
->
bindAndAddNotification
(
jsonrpc
::
Procedure
(
"notifyServer"
,
jsonrpc
::
PARAMS_BY_NAME
,
NULL
),
&
AbstractStubServer
::
notifyServerI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"addNumbers"
,
jsonrpc
::
PARAMS_BY_POSITION
,
jsonrpc
::
JSON_INTEGER
,
"param1"
,
jsonrpc
::
JSON_INTEGER
,
"param2"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
addNumbersI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"addNumbers2"
,
jsonrpc
::
PARAMS_BY_POSITION
,
jsonrpc
::
JSON_REAL
,
"param1"
,
jsonrpc
::
JSON_REAL
,
"param2"
,
jsonrpc
::
JSON_REAL
,
NULL
),
&
AbstractStubServer
::
addNumbers2I
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"isEqual"
,
jsonrpc
::
PARAMS_BY_POSITION
,
jsonrpc
::
JSON_BOOLEAN
,
"param1"
,
jsonrpc
::
JSON_STRING
,
"param2"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
isEqualI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"buildObject"
,
jsonrpc
::
PARAMS_BY_POSITION
,
jsonrpc
::
JSON_OBJECT
,
"param1"
,
jsonrpc
::
JSON_STRING
,
"param2"
,
jsonrpc
::
JSON_INTEGER
,
NULL
),
&
AbstractStubServer
::
buildObjectI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"methodWithoutParameters"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractStubServer
::
methodWithoutParametersI
);
}
inline
virtual
void
sayHelloI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
sayHello
(
request
[
"name"
].
asString
());
}
inline
virtual
void
notifyServerI
(
const
Json
::
Value
&
request
)
{
(
void
)
request
;
this
->
notifyServer
();
}
inline
virtual
void
addNumbersI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
addNumbers
(
request
[
0u
].
asInt
(),
request
[
1u
].
asInt
());
}
inline
virtual
void
addNumbers2I
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
addNumbers2
(
request
[
0u
].
asDouble
(),
request
[
1u
].
asDouble
());
}
inline
virtual
void
isEqualI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
isEqual
(
request
[
0u
].
asString
(),
request
[
1u
].
asString
());
}
inline
virtual
void
buildObjectI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
response
=
this
->
buildObject
(
request
[
0u
].
asString
(),
request
[
1u
].
asInt
());
}
inline
virtual
void
methodWithoutParametersI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
(
void
)
request
;
response
=
this
->
methodWithoutParameters
();
}
virtual
std
::
string
sayHello
(
const
std
::
string
&
name
)
=
0
;
virtual
void
notifyServer
()
=
0
;
virtual
int
addNumbers
(
int
param1
,
int
param2
)
=
0
;
virtual
double
addNumbers2
(
double
param1
,
double
param2
)
=
0
;
virtual
bool
isEqual
(
const
std
::
string
&
param1
,
const
std
::
string
&
param2
)
=
0
;
virtual
Json
::
Value
buildObject
(
const
std
::
string
&
param1
,
int
param2
)
=
0
;
virtual
std
::
string
methodWithoutParameters
()
=
0
;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
spec.json
0 → 100644
View file @
36737159
[
{
"name"
:
"sayHello"
,
"params"
:
{
"name"
:
"Peter"
},
"returns"
:
"Hello Peter"
},
{
"name"
:
"notifyServer"
},
{
"name"
:
"addNumbers"
,
"params"
:
[
3
,
4
],
"returns"
:
7
},
{
"name"
:
"addNumbers2"
,
"params"
:
[
3.2
,
4.1
],
"returns"
:
7.5
},
{
"name"
:
"isEqual"
,
"params"
:
[
"string1"
,
"string2"
],
"returns"
:
false
},
{
"name"
:
"buildObject"
,
"params"
:
[
"peter"
,
1990
],
"returns"
:
{
"name"
:
"peter"
,
"year"
:
1990
}
},
{
"name"
:
"methodWithoutParameters"
,
"returns"
:
"String"
}
]
\ No newline at end of file
stubclient.h
0 → 100644
View file @
36737159
/**
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
*/
#ifndef JSONRPC_CPP_STUB_STUBCLIENT_H_
#define JSONRPC_CPP_STUB_STUBCLIENT_H_
#include <jsonrpccpp/client.h>
class
StubClient
:
public
jsonrpc
::
Client
{
public
:
StubClient
(
jsonrpc
::
IClientConnector
&
conn
,
jsonrpc
::
clientVersion_t
type
=
jsonrpc
::
JSONRPC_CLIENT_V2
)
:
jsonrpc
::
Client
(
conn
,
type
)
{}
std
::
string
sayHello
(
const
std
::
string
&
name
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
[
"name"
]
=
name
;
Json
::
Value
result
=
this
->
CallMethod
(
"sayHello"
,
p
);
if
(
result
.
isString
())
return
result
.
asString
();
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
void
notifyServer
()
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
=
Json
::
nullValue
;
this
->
CallNotification
(
"notifyServer"
,
p
);
}
int
addNumbers
(
int
param1
,
int
param2
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
.
append
(
param1
);
p
.
append
(
param2
);
Json
::
Value
result
=
this
->
CallMethod
(
"addNumbers"
,
p
);
if
(
result
.
isIntegral
())
return
result
.
asInt
();
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
double
addNumbers2
(
double
param1
,
double
param2
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
.
append
(
param1
);
p
.
append
(
param2
);
Json
::
Value
result
=
this
->
CallMethod
(
"addNumbers2"
,
p
);
if
(
result
.
isDouble
())
return
result
.
asDouble
();
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
bool
isEqual
(
const
std
::
string
&
param1
,
const
std
::
string
&
param2
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
.
append
(
param1
);
p
.
append
(
param2
);
Json
::
Value
result
=
this
->
CallMethod
(
"isEqual"
,
p
);
if
(
result
.
isBool
())
return
result
.
asBool
();
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
Json
::
Value
buildObject
(
const
std
::
string
&
param1
,
int
param2
)
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
.
append
(
param1
);
p
.
append
(
param2
);
Json
::
Value
result
=
this
->
CallMethod
(
"buildObject"
,
p
);
if
(
result
.
isObject
())
return
result
;
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
std
::
string
methodWithoutParameters
()
throw
(
jsonrpc
::
JsonRpcException
)
{
Json
::
Value
p
;
p
=
Json
::
nullValue
;
Json
::
Value
result
=
this
->
CallMethod
(
"methodWithoutParameters"
,
p
);
if
(
result
.
isString
())
return
result
.
asString
();
else
throw
jsonrpc
::
JsonRpcException
(
jsonrpc
::
Errors
::
ERROR_CLIENT_INVALID_RESPONSE
,
result
.
toStyledString
());
}
};
#endif //JSONRPC_CPP_STUB_STUBCLIENT_H_
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