Skip to content

Commit 9282733

Browse files
committed
Moved getAppVersion and getAppName to Export cli base class
1 parent ea50347 commit 9282733

8 files changed

+57
-61
lines changed

example-of-exported/py3/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Automatically generated by wsjcpp-jsonrpc20.
44
* Version: v0.0.4
5-
* Date: Wed, 07 Oct 2020 01:59:09 GMT
5+
* Date: Wed, 07 Oct 2020 02:05:13 GMT
66

77
Example connect/disconnect:
88
```

example-of-exported/py3/libwsjcppjson20client/SomeClient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
### This file was automatically generated by wsjcpp-jsonrpc20
44
### Version: v0.0.4
5-
### Date: Wed, 07 Oct 2020 01:59:09 GMT
5+
### Date: Wed, 07 Oct 2020 02:05:13 GMT
66

77
import asyncio
88
import websocket

src/wsjcpp_jsonrpc20_export_cli_base.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,31 @@ std::string WsjcppJsonRpc20ExportCliBase::getPackageName() const {
3636
return m_sPackageName;
3737
}
3838

39+
// ---------------------------------------------------------------------
40+
41+
void WsjcppJsonRpc20ExportCliBase::setAppName(const std::string &sAppName) {
42+
m_sAppName = sAppName;
43+
}
44+
45+
// ---------------------------------------------------------------------
46+
47+
std::string WsjcppJsonRpc20ExportCliBase::getAppName() const {
48+
return m_sAppName;
49+
}
50+
51+
// ---------------------------------------------------------------------
52+
53+
void WsjcppJsonRpc20ExportCliBase::setAppVersion(const std::string &sAppVersion) {
54+
// https://www.python.org/dev/peps/pep-0440/
55+
// [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
56+
// TODO regexp
57+
m_sAppVersion = sAppVersion;
58+
}
59+
60+
// ---------------------------------------------------------------------
61+
62+
std::string WsjcppJsonRpc20ExportCliBase::getAppVersion() const {
63+
return m_sAppVersion;
64+
}
65+
3966
// ---------------------------------------------------------------------

src/wsjcpp_jsonrpc20_export_cli_base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class WsjcppJsonRpc20ExportCliBase {
1414

1515
std::string getExportDir() const;
1616
std::string getPackageName() const;
17+
void setAppName(const std::string &sAppName);
18+
std::string getAppName() const;
19+
void setAppVersion(const std::string &sAppVersion);
20+
std::string getAppVersion() const;
1721

1822
virtual bool doExportLib() = 0;
1923

@@ -23,6 +27,8 @@ class WsjcppJsonRpc20ExportCliBase {
2327
private:
2428
std::string m_sExportDir;
2529
std::string m_sPackageName;
30+
std::string m_sAppName;
31+
std::string m_sAppVersion;
2632
};
2733

2834
#endif // WSJCPP_JSONRPC20_EXPORT_CLI_BASE_H

src/wsjcpp_jsonrpc20_export_cli_python.cpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ WsjcppJsonRpc20ExportCliPython::WsjcppJsonRpc20ExportCliPython(
130130
TAG = "WsjcppJsonRpc20ExportCliPython";
131131
m_sAuthorName = "Unknown";
132132
m_sAuthorEmail = "unknown";
133-
m_sAppName = "unknown";
134-
m_sAppVersion = "unknown";
135133
m_sClassName = "Unknown";
136134
m_sUrl = "none";
137135
}
@@ -150,21 +148,6 @@ void WsjcppJsonRpc20ExportCliPython::setAuthorEmail(const std::string &sAuthorEm
150148

151149
// ---------------------------------------------------------------------
152150

153-
void WsjcppJsonRpc20ExportCliPython::setAppName(const std::string &sAppName) {
154-
m_sAppName = sAppName;
155-
}
156-
157-
// ---------------------------------------------------------------------
158-
159-
void WsjcppJsonRpc20ExportCliPython::setAppVersion(const std::string &sAppVersion) {
160-
// https://www.python.org/dev/peps/pep-0440/
161-
// [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
162-
// TODO regexp
163-
m_sAppVersion = sAppVersion;
164-
}
165-
166-
// ---------------------------------------------------------------------
167-
168151
void WsjcppJsonRpc20ExportCliPython::setClassName(const std::string &sClassName) {
169152
m_sClassName = sClassName;
170153
}
@@ -269,7 +252,7 @@ bool WsjcppJsonRpc20ExportCliPython::prepareReadmeMdIfNeed() {
269252
if (!WsjcppCore::fileExists(sReadmeMd)) {
270253
std::string sContentReadme =
271254
"#" + this->getPackageName() + "\n\n"
272-
+ m_sClassName + " Python Library for " + m_sAppName + "\n\n"
255+
+ m_sClassName + " Python Library for " + this->getAppName() + "\n\n"
273256
+ "## Install \n\n"
274257
+ "```\n"
275258
+ "$ pip3 install " + this->getPackageName() + " --upgrade\n"
@@ -306,13 +289,13 @@ bool WsjcppJsonRpc20ExportCliPython::exportSetupPy() {
306289
"\n"
307290
"setuptools.setup(\n"
308291
" name='" + this->getPackageName() + "',\n"
309-
" version='" + m_sAppVersion + "',\n"
292+
" version='" + this->getAppVersion() + "',\n"
310293
" packages=['" + this->getPackageName() + "'],\n"
311294
" install_requires=['websocket-client>=0.56.0', 'requests>=2.21.0'],\n"
312295
" keywords=['" + WsjcppCore::join(m_vKeywords, "', '") + "'],\n"
313296
" author='" + m_sAuthorName + "',\n"
314297
" author_email='" + m_sAuthorEmail + "',\n"
315-
" description='" + m_sClassName + " Python Library for " + m_sAppName + "',\n"
298+
" description='" + m_sClassName + " Python Library for " + this->getAppName() + "',\n"
316299
" long_description=long_description,\n"
317300
" long_description_content_type='text/markdown',\n"
318301
" url='" + m_sUrl + "',\n"
@@ -351,8 +334,8 @@ bool WsjcppJsonRpc20ExportCliPython::exportAPImd() {
351334
long nSec = WsjcppCore::getCurrentTimeInSeconds();
352335

353336
apimd << "# " + m_sClassName + " Python Library \n\n";
354-
apimd << "Automatically generated by " << m_sAppName << ". \n";
355-
apimd << "* Version: " << m_sAppVersion << "\n";
337+
apimd << "Automatically generated by " << this->getAppName() << ". \n";
338+
apimd << "* Version: " << this->getAppVersion() << "\n";
356339
apimd << "* Date: " << WsjcppCore::formatTimeForWeb(nSec) << "\n\n";
357340
apimd << "Example connect/disconnect:\n"
358341
<< "```\n"
@@ -483,8 +466,8 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
483466
builder
484467
.add("#!/usr/bin/env python3")
485468
.add("# -*- coding: utf-8 -*-")
486-
.add("### This file was automatically generated by " + m_sAppName)
487-
.add("### Version: " + m_sAppVersion)
469+
.add("### This file was automatically generated by " + this->getAppName())
470+
.add("### Version: " + this->getAppVersion())
488471
.add("### Date: " + WsjcppCore::formatTimeForWeb(nSec))
489472
.add("")
490473
.add("import asyncio")
@@ -496,7 +479,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
496479
.sub("class " + m_sClassName + ":")
497480
.add("__ws = None")
498481
.add("__url = None")
499-
.add("__cli_version = '" + m_sAppVersion + "'")
482+
.add("__cli_version = '" + this->getAppVersion() + "'")
500483
.add("__loop = None")
501484
.add("__token = None")
502485
.add("__connecting = False")

src/wsjcpp_jsonrpc20_export_cli_python.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class WsjcppJsonRpc20ExportCliPython : public WsjcppJsonRpc20ExportCliBase {
1313
);
1414
void setAuthorName(const std::string &sAuthorName);
1515
void setAuthorEmail(const std::string &sAuthorEmail);
16-
void setAppName(const std::string &sAppName);
17-
void setAppVersion(const std::string &sAppVersion);
1816
void setClassName(const std::string &sClassName);
1917
void setUrl(const std::string &sUrl);
2018
void setDownloadUrl(const std::string &sDownloadUrl);
@@ -26,8 +24,6 @@ class WsjcppJsonRpc20ExportCliPython : public WsjcppJsonRpc20ExportCliBase {
2624
private:
2725
std::string m_sAuthorName;
2826
std::string m_sAuthorEmail;
29-
std::string m_sAppName;
30-
std::string m_sAppVersion;
3127
std::string m_sClassName;
3228
std::string m_sUrl;
3329
std::string m_sDownloadUrl;

src/wsjcpp_jsonrpc20_export_cli_webjs.cpp

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ WsjcppJsonRpc20ExportCliWebJs::WsjcppJsonRpc20ExportCliWebJs(
2323
TAG = "WsjcppJsonRpc20ExportCliWebJs";
2424
m_sAuthorName = "Unknown";
2525
m_sAuthorEmail = "unknown";
26-
m_sAppName = "unknown";
27-
m_sAppVersion = "unknown";
26+
this->getAppName() = "unknown";
27+
this->getAppVersion() = "unknown";
2828
m_sClassName = "Unknown";
2929
m_sDefaultConnectionString = "ws://localhost:1234/";
3030

@@ -53,12 +53,6 @@ void WsjcppJsonRpc20ExportCliWebJs::setAuthorEmail(const std::string &sAuthorEma
5353

5454
// ---------------------------------------------------------------------
5555

56-
void WsjcppJsonRpc20ExportCliWebJs::setAppName(const std::string &sAppName) {
57-
m_sAppName = sAppName;
58-
}
59-
60-
// ---------------------------------------------------------------------
61-
6256
void WsjcppJsonRpc20ExportCliWebJs::setClassName(const std::string &sClassName) {
6357
m_sClassName = sClassName;
6458
}
@@ -97,12 +91,6 @@ void WsjcppJsonRpc20ExportCliWebJs::setDefaultConnectionString(const std::string
9791

9892
// ---------------------------------------------------------------------
9993

100-
void WsjcppJsonRpc20ExportCliWebJs::setAppVersion(const std::string &sAppVersion) {
101-
m_sAppVersion = sAppVersion;
102-
}
103-
104-
// ---------------------------------------------------------------------
105-
10694
bool WsjcppJsonRpc20ExportCliWebJs::doExportLib() {
10795
std::string sBasicDir = "./" + this->getPackageName();
10896

@@ -159,8 +147,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportPackageJson() {
159147
packageJson <<
160148
"{\n"
161149
" \"name\": \"" + this->getPackageName() + "\",\n"
162-
" \"version\": \"" + m_sAppVersion + "\",\n"
163-
" \"description\": \"" + m_sClassName + " JavaScript Web Client Library for " + m_sAppName + "\",\n"
150+
" \"version\": \"" + this->getAppVersion() + "\",\n"
151+
" \"description\": \"" + m_sClassName + " JavaScript Web Client Library for " + this->getAppName() + "\",\n"
164152
" \"main\": \"dist/" + this->getPackageName() + ".js\",\n"
165153
" \"repository\": {\n"
166154
" \"type\": \"" + m_sRepositoryType + "\",\n"
@@ -199,8 +187,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportAPImd() {
199187

200188
apimd <<
201189
"# " + this->getPackageName() + "\n\n"
202-
" Automatically generated by " << m_sAppName << ". \n"
203-
" * Version: " << m_sAppVersion << "\n"
190+
" Automatically generated by " << this->getAppName() << ". \n"
191+
" * Version: " << this->getAppVersion() << "\n"
204192
" * Date: " << buffer.str() << "\n\n"
205193
" Include script ```dist/" + this->getPackageName() + ".js```\n"
206194
" Example connect:\n"
@@ -381,11 +369,11 @@ bool WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebJSFile() {
381369
// now the result is in `buffer.str()`.
382370

383371
libwjscppcli_web_js_file <<
384-
"// This file was automatically generated by " << m_sAppName << " (" + m_sAppVersion + "), date: " << sBuildDate << "\r\n"
372+
"// This file was automatically generated by " << this->getAppName() << " (" + this->getAppVersion() + "), date: " << sBuildDate << "\r\n"
385373
"window." << m_sClassName << " = window." << m_sClassName << " || (function() { \r\n"
386374
" var self = {};\r\n"
387-
" self.appName = '" + m_sAppName + "';\r\n"
388-
" self.appVersion = '" + m_sAppVersion + "';\r\n"
375+
" self.appName = '" + this->getAppName() + "';\r\n"
376+
" self.appVersion = '" + this->getAppVersion() + "';\r\n"
389377
" self.appBuildDate = '" + sBuildDate + "';\r\n"
390378
" var _lastm = 0;\r\n"
391379
" var _listeners = {};\r\n"
@@ -401,7 +389,7 @@ bool WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebJSFile() {
401389
libwjscppcli_web_js_file <<
402390
" };\r\n"
403391
" function _lm() { _lastm++; return 'm' + _lastm; };\r\n"
404-
" console.warn('" + m_sClassName + " (" + m_sAppVersion + ")');\r\n"
392+
" console.warn('" + m_sClassName + " (" + this->getAppVersion() + ")');\r\n"
405393
" self.promise = function() {\r\n"
406394
" return {\r\n"
407395
" completed: false, failed: false, successed: false, \r\n"
@@ -698,7 +686,7 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() {
698686
// now the result is in `buffer.str()`.
699687

700688
libwjscppcli_web_service_ts_file <<
701-
"// This file was automatically generated by " << m_sAppName << " (v" + m_sAppVersion + "), date: " << sBuildDate << "\r\n"
689+
"// This file was automatically generated by " << this->getAppName() << " (v" + this->getAppVersion() + "), date: " << sBuildDate << "\r\n"
702690
"import { Injectable, EventEmitter } from '@angular/core';\r\n"
703691
"import { PlatformLocation } from '@angular/common';\r\n"
704692
"import { ToastrService } from 'ngx-toastr';\r\n"
@@ -707,8 +695,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() {
707695
"\r\n"
708696
"@Injectable({providedIn: 'root'})\r\n"
709697
"export class " + m_sClassName + " {\r\n"
710-
" private appName: string = '" + m_sAppName + "';\r\n"
711-
" private appVersion: string = '" + m_sAppVersion + "';\r\n"
698+
" private appName: string = '" + this->getAppName() + "';\r\n"
699+
" private appVersion: string = '" + this->getAppVersion() + "';\r\n"
712700
" private appBuildDate: string = '" + sBuildDate + "';\r\n"
713701
" isAuthorized: boolean = false;\r\n"
714702
" connectionState: string = '';\r\n"
@@ -738,7 +726,7 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() {
738726
" ) {\r\n"
739727
" this.serverHost = this._location.hostname;\r\n"
740728
" this.currentProtocol = this._location.protocol;\r\n"
741-
" console.warn('" + m_sClassName + " (" + m_sAppVersion + ")');\r\n"
729+
" console.warn('" + m_sClassName + " (" + this->getAppVersion() + ")');\r\n"
742730
" this._tokenValue = this.getToken();\r\n"
743731
" }\r\n"
744732
"\r\n"

src/wsjcpp_jsonrpc20_export_cli_webjs.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class WsjcppJsonRpc20ExportCliWebJs : public WsjcppJsonRpc20ExportCliBase {
1212
);
1313
void setAuthorName(const std::string &sAuthorName);
1414
void setAuthorEmail(const std::string &sAuthorEmail);
15-
void setAppName(const std::string &sAppName);
16-
void setAppVersion(const std::string &sAppVersion);
1715
// TODO homepage
1816
void setClassName(const std::string &sClassName);
1917
void setIssuesURL(const std::string &sIssuesURL);
@@ -27,8 +25,6 @@ class WsjcppJsonRpc20ExportCliWebJs : public WsjcppJsonRpc20ExportCliBase {
2725
std::string TAG;
2826
std::string m_sAuthorName;
2927
std::string m_sAuthorEmail;
30-
std::string m_sAppName;
31-
std::string m_sAppVersion;
3228
std::string m_sClassName;
3329
std::string m_sIssuesURL;
3430
std::string m_sRepositoryType;

0 commit comments

Comments
 (0)