Skip to content

Commit 5944acf

Browse files
committed
Copied source code from fhq-server
1 parent eae693d commit 5944acf

File tree

11 files changed

+708
-96
lines changed

11 files changed

+708
-96
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.wsjcpp/*
22
tmp/*
3-
wsjcpp-jsonrpc2
3+
wsjcpp-jsonrpc2
4+
wsjcpp-jsonrpc20

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
project(wsjcpp-jsonrpc2 C CXX)
3+
project(wsjcpp-jsonrpc20 C CXX)
44

55
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
66

77
set(CMAKE_CXX_STANDARD 11)
8-
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp-jsonrpc2_SOURCE_DIR})
8+
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp-jsonrpc20_SOURCE_DIR})
99

1010
# include header dirs
1111
list (APPEND WSJCPP_INCLUDE_DIRS "src")
@@ -17,13 +17,13 @@ list (APPEND WSJCPP_SOURCES "src/main.cpp")
1717

1818
include_directories(${WSJCPP_INCLUDE_DIRS})
1919

20-
add_executable (wsjcpp-jsonrpc2 ${WSJCPP_SOURCES})
20+
add_executable (wsjcpp-jsonrpc20 ${WSJCPP_SOURCES})
2121

22-
target_link_libraries(wsjcpp-jsonrpc2 ${WSJCPP_LIBRARIES})
22+
target_link_libraries(wsjcpp-jsonrpc20 ${WSJCPP_LIBRARIES})
2323

2424
install(
2525
TARGETS
26-
wsjcpp-jsonrpc2
26+
wsjcpp-jsonrpc20
2727
RUNTIME DESTINATION
2828
/usr/bin
2929
)

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# wsjcpp-jsonrpc2
1+
# wsjcpp-jsonrpc20
22

3-
[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-jsonrpc2.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-jsonrpc2)
3+
[![Build Status](https://api.travis-ci.com/wsjcpp/wsjcpp-jsonrpc20.svg?branch=master)](https://travis-ci.com/wsjcpp/wsjcpp-jsonrpc20)
44

55
C++ Implementation for JsonRPC 2.0
66

@@ -11,6 +11,25 @@ C++ Implementation for JsonRPC 2.0
1111
*
1212

1313

14+
## Integration
15+
16+
### via wsjcpp
17+
18+
```
19+
$ wsjcpp install https://github.com/wsjcpp/wsjcpp-jsonrpc20:master
20+
```
21+
22+
### Include files
23+
24+
* src.wsjcpp/nlohmann_json/json.hpp
25+
* src.wsjcpp/wsjcpp_core.h
26+
* src.wsjcpp/wsjcpp_validators/wsjcpp_validators.h
27+
* src.wsjcpp/wsjcpp_validators/wsjcpp_validators.cpp
28+
* src/wsjcpp_jsonrpc20.h
29+
* src/wsjcpp_jsonrpc20.cpp
30+
* src/wsjcpp_jsonrpc20_export_cli_python.h
31+
* src/wsjcpp_jsonrpc20_export_cli_python.cpp
32+
1433
## Example
1534

1635
``` cpp
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/wsjcpp-safe-scripting
2+
3+
# log_info rootdir
4+
# log_info script_filename
5+
6+
make_dir "src"
7+
8+
var argument_processor_name
9+
set_value argument_processor_name arg1
10+
normalize_class_name argument_processor_name
11+
convert_CamelCase_to_snake_case argument_processor_name argument_processor_name
12+
13+
var class_name
14+
concat class_name "WsjcppJsonRpc20Handler" arg1
15+
normalize_class_name class_name
16+
17+
var base_filename
18+
convert_CamelCase_to_snake_case class_name base_filename
19+
# log_info base_filename
20+
21+
var filename_cpp
22+
concat filename_cpp "./src/" base_filename ".cpp"
23+
24+
var filename_h
25+
concat filename_h "./src/" base_filename ".h"
26+
27+
var ifndef_header
28+
set_value ifndef_header base_filename
29+
concat ifndef_header "_H"
30+
31+
to_upper_case ifndef_header
32+
33+
var content_header
34+
concat content_header "#ifndef " ifndef_header "
35+
#define " ifndef_header "
36+
37+
#include <wsjcpp_arguments.h>
38+
39+
class " class_name " : public WsjcppJsonRpc20HandlerBase {
40+
public:
41+
" class_name "();
42+
virtual void handle(WsjcppJsonRpc20Request *pRequest) override;
43+
};
44+
45+
#endif // " ifndef_header
46+
47+
48+
var content_source
49+
concat content_source "
50+
#include \"" base_filename ".h\"
51+
#include <wsjcpp_jsonrpc20.h>
52+
53+
// ---------------------------------------------------------------------
54+
// " class_name "
55+
56+
" class_name "::" class_name "()
57+
: WsjcppJsonRpc20HandlerBase(\"" argument_processor_name "\", \"TODO description\") {
58+
TAG = \"" class_name "\";
59+
// setAccessUnauthorized(true);
60+
// setAccessUser(true);
61+
// setAccessTester(\"here example of command\");
62+
// setAccessAdmin();
63+
// void setActivatedFromVersion(\"v0.0.1"); // TODO authomatic set WSJCPP_APP_VERSION
64+
// void setDeprecatedFromVersion("");
65+
66+
// description of input params
67+
// requireStringParam(\"uuid\", "object uuid")
68+
// .addValidator(new WsjcppValidatorUUID());
69+
// optionalStringParam(\"name\", "Name of object")
70+
// .addValidator(new WsjcppValidatorStringLength(3,10));
71+
72+
// requireIntegerParam(\"cost\", "Name of object")
73+
// .addValidator(new WsjcppValidatorIntegerMinValue(3))
74+
// .addValidator(new WsjcppValidatorIntegerMaxValue(1000));
75+
// optionalIntegerParam(\"age\", "Name of object")
76+
// .addValidator(new WsjcppValidatorIntegerMinValue(0))
77+
78+
// requireBooleanParam(\"public\", "True if object is public");
79+
// optionalBooleanParam(\"activated\", "If object can handle");
80+
}
81+
82+
// ---------------------------------------------------------------------
83+
84+
void " class_name "::handle(WsjcppJsonRpc20Request *pRequest) {
85+
WsjcppLog::err(TAG, \"Not implemented\");
86+
// TODO
87+
pRequest->fail(WsjcppJsonRpc20Error(501, "NOT_IMPLEMENTED"));
88+
}
89+
90+
"
91+
92+
var file_source
93+
concat file_source "src/" filename_cpp
94+
95+
write_file filename_h content_header
96+
write_file filename_cpp content_source
97+
98+
log_info "
99+
======
100+
Generated class:
101+
- " class_name "
102+
Generated files:
103+
- " filename_h "
104+
- " filename_cpp "
105+
======
106+
"
107+
108+
cmakelists_txt_append_wsjcpp filename_h
109+
cmakelists_txt_append_wsjcpp filename_cpp

src.wsjcpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cmake_minimum_required(VERSION 3.0)
33

44
add_definitions(-DWSJCPP_APP_VERSION="v0.0.2")
5-
add_definitions(-DWSJCPP_APP_NAME="wsjcpp-jsonrpc2")
5+
add_definitions(-DWSJCPP_APP_NAME="wsjcpp-jsonrpc20")
66

77
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
88
set(MACOSX TRUE)

src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ int main(int argc, const char* argv[]) {
1313
}
1414
WsjcppLog::setPrefixLogFile("wsjcpp");
1515
WsjcppLog::setLogDirectory(".logs");
16+
17+
18+
1619
// TODO your code here
1720
return 0;
1821
}

0 commit comments

Comments
 (0)