diff --git a/example-of-exported/py3/API.md b/example-of-exported/py3/API.md index 38405de..37406d1 100644 --- a/example-of-exported/py3/API.md +++ b/example-of-exported/py3/API.md @@ -2,7 +2,7 @@ Automatically generated by wsjcpp-jsonrpc20. * Version: v0.0.4 -* Date: Wed, 07 Oct 2020 01:59:09 GMT +* Date: Wed, 07 Oct 2020 02:05:13 GMT Example connect/disconnect: ``` diff --git a/example-of-exported/py3/libwsjcppjson20client/SomeClient.py b/example-of-exported/py3/libwsjcppjson20client/SomeClient.py index 2e78d67..f9e93cb 100644 --- a/example-of-exported/py3/libwsjcppjson20client/SomeClient.py +++ b/example-of-exported/py3/libwsjcppjson20client/SomeClient.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- ### This file was automatically generated by wsjcpp-jsonrpc20 ### Version: v0.0.4 -### Date: Wed, 07 Oct 2020 01:59:09 GMT +### Date: Wed, 07 Oct 2020 02:05:13 GMT import asyncio import websocket diff --git a/src/wsjcpp_jsonrpc20_export_cli_base.cpp b/src/wsjcpp_jsonrpc20_export_cli_base.cpp index 491f60f..0900f2e 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_base.cpp +++ b/src/wsjcpp_jsonrpc20_export_cli_base.cpp @@ -36,4 +36,31 @@ std::string WsjcppJsonRpc20ExportCliBase::getPackageName() const { return m_sPackageName; } +// --------------------------------------------------------------------- + +void WsjcppJsonRpc20ExportCliBase::setAppName(const std::string &sAppName) { + m_sAppName = sAppName; +} + +// --------------------------------------------------------------------- + +std::string WsjcppJsonRpc20ExportCliBase::getAppName() const { + return m_sAppName; +} + +// --------------------------------------------------------------------- + +void WsjcppJsonRpc20ExportCliBase::setAppVersion(const std::string &sAppVersion) { + // https://www.python.org/dev/peps/pep-0440/ + // [N!]N(.N)*[{a|b|rc}N][.postN][.devN] + // TODO regexp + m_sAppVersion = sAppVersion; +} + +// --------------------------------------------------------------------- + +std::string WsjcppJsonRpc20ExportCliBase::getAppVersion() const { + return m_sAppVersion; +} + // --------------------------------------------------------------------- \ No newline at end of file diff --git a/src/wsjcpp_jsonrpc20_export_cli_base.h b/src/wsjcpp_jsonrpc20_export_cli_base.h index cfc096b..18b0023 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_base.h +++ b/src/wsjcpp_jsonrpc20_export_cli_base.h @@ -14,6 +14,10 @@ class WsjcppJsonRpc20ExportCliBase { std::string getExportDir() const; std::string getPackageName() const; + void setAppName(const std::string &sAppName); + std::string getAppName() const; + void setAppVersion(const std::string &sAppVersion); + std::string getAppVersion() const; virtual bool doExportLib() = 0; @@ -23,6 +27,8 @@ class WsjcppJsonRpc20ExportCliBase { private: std::string m_sExportDir; std::string m_sPackageName; + std::string m_sAppName; + std::string m_sAppVersion; }; #endif // WSJCPP_JSONRPC20_EXPORT_CLI_BASE_H \ No newline at end of file diff --git a/src/wsjcpp_jsonrpc20_export_cli_python.cpp b/src/wsjcpp_jsonrpc20_export_cli_python.cpp index e0e2959..e632cae 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_python.cpp +++ b/src/wsjcpp_jsonrpc20_export_cli_python.cpp @@ -130,8 +130,6 @@ WsjcppJsonRpc20ExportCliPython::WsjcppJsonRpc20ExportCliPython( TAG = "WsjcppJsonRpc20ExportCliPython"; m_sAuthorName = "Unknown"; m_sAuthorEmail = "unknown"; - m_sAppName = "unknown"; - m_sAppVersion = "unknown"; m_sClassName = "Unknown"; m_sUrl = "none"; } @@ -150,21 +148,6 @@ void WsjcppJsonRpc20ExportCliPython::setAuthorEmail(const std::string &sAuthorEm // --------------------------------------------------------------------- -void WsjcppJsonRpc20ExportCliPython::setAppName(const std::string &sAppName) { - m_sAppName = sAppName; -} - -// --------------------------------------------------------------------- - -void WsjcppJsonRpc20ExportCliPython::setAppVersion(const std::string &sAppVersion) { - // https://www.python.org/dev/peps/pep-0440/ - // [N!]N(.N)*[{a|b|rc}N][.postN][.devN] - // TODO regexp - m_sAppVersion = sAppVersion; -} - -// --------------------------------------------------------------------- - void WsjcppJsonRpc20ExportCliPython::setClassName(const std::string &sClassName) { m_sClassName = sClassName; } @@ -269,7 +252,7 @@ bool WsjcppJsonRpc20ExportCliPython::prepareReadmeMdIfNeed() { if (!WsjcppCore::fileExists(sReadmeMd)) { std::string sContentReadme = "#" + this->getPackageName() + "\n\n" - + m_sClassName + " Python Library for " + m_sAppName + "\n\n" + + m_sClassName + " Python Library for " + this->getAppName() + "\n\n" + "## Install \n\n" + "```\n" + "$ pip3 install " + this->getPackageName() + " --upgrade\n" @@ -306,13 +289,13 @@ bool WsjcppJsonRpc20ExportCliPython::exportSetupPy() { "\n" "setuptools.setup(\n" " name='" + this->getPackageName() + "',\n" - " version='" + m_sAppVersion + "',\n" + " version='" + this->getAppVersion() + "',\n" " packages=['" + this->getPackageName() + "'],\n" " install_requires=['websocket-client>=0.56.0', 'requests>=2.21.0'],\n" " keywords=['" + WsjcppCore::join(m_vKeywords, "', '") + "'],\n" " author='" + m_sAuthorName + "',\n" " author_email='" + m_sAuthorEmail + "',\n" - " description='" + m_sClassName + " Python Library for " + m_sAppName + "',\n" + " description='" + m_sClassName + " Python Library for " + this->getAppName() + "',\n" " long_description=long_description,\n" " long_description_content_type='text/markdown',\n" " url='" + m_sUrl + "',\n" @@ -351,8 +334,8 @@ bool WsjcppJsonRpc20ExportCliPython::exportAPImd() { long nSec = WsjcppCore::getCurrentTimeInSeconds(); apimd << "# " + m_sClassName + " Python Library \n\n"; - apimd << "Automatically generated by " << m_sAppName << ". \n"; - apimd << "* Version: " << m_sAppVersion << "\n"; + apimd << "Automatically generated by " << this->getAppName() << ". \n"; + apimd << "* Version: " << this->getAppVersion() << "\n"; apimd << "* Date: " << WsjcppCore::formatTimeForWeb(nSec) << "\n\n"; apimd << "Example connect/disconnect:\n" << "```\n" @@ -483,8 +466,8 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() { builder .add("#!/usr/bin/env python3") .add("# -*- coding: utf-8 -*-") - .add("### This file was automatically generated by " + m_sAppName) - .add("### Version: " + m_sAppVersion) + .add("### This file was automatically generated by " + this->getAppName()) + .add("### Version: " + this->getAppVersion()) .add("### Date: " + WsjcppCore::formatTimeForWeb(nSec)) .add("") .add("import asyncio") @@ -496,7 +479,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() { .sub("class " + m_sClassName + ":") .add("__ws = None") .add("__url = None") - .add("__cli_version = '" + m_sAppVersion + "'") + .add("__cli_version = '" + this->getAppVersion() + "'") .add("__loop = None") .add("__token = None") .add("__connecting = False") diff --git a/src/wsjcpp_jsonrpc20_export_cli_python.h b/src/wsjcpp_jsonrpc20_export_cli_python.h index d68b562..28e680f 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_python.h +++ b/src/wsjcpp_jsonrpc20_export_cli_python.h @@ -13,8 +13,6 @@ class WsjcppJsonRpc20ExportCliPython : public WsjcppJsonRpc20ExportCliBase { ); void setAuthorName(const std::string &sAuthorName); void setAuthorEmail(const std::string &sAuthorEmail); - void setAppName(const std::string &sAppName); - void setAppVersion(const std::string &sAppVersion); void setClassName(const std::string &sClassName); void setUrl(const std::string &sUrl); void setDownloadUrl(const std::string &sDownloadUrl); @@ -26,8 +24,6 @@ class WsjcppJsonRpc20ExportCliPython : public WsjcppJsonRpc20ExportCliBase { private: std::string m_sAuthorName; std::string m_sAuthorEmail; - std::string m_sAppName; - std::string m_sAppVersion; std::string m_sClassName; std::string m_sUrl; std::string m_sDownloadUrl; diff --git a/src/wsjcpp_jsonrpc20_export_cli_webjs.cpp b/src/wsjcpp_jsonrpc20_export_cli_webjs.cpp index 971fbcd..6f22db1 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_webjs.cpp +++ b/src/wsjcpp_jsonrpc20_export_cli_webjs.cpp @@ -23,8 +23,8 @@ WsjcppJsonRpc20ExportCliWebJs::WsjcppJsonRpc20ExportCliWebJs( TAG = "WsjcppJsonRpc20ExportCliWebJs"; m_sAuthorName = "Unknown"; m_sAuthorEmail = "unknown"; - m_sAppName = "unknown"; - m_sAppVersion = "unknown"; + this->getAppName() = "unknown"; + this->getAppVersion() = "unknown"; m_sClassName = "Unknown"; m_sDefaultConnectionString = "ws://localhost:1234/"; @@ -53,12 +53,6 @@ void WsjcppJsonRpc20ExportCliWebJs::setAuthorEmail(const std::string &sAuthorEma // --------------------------------------------------------------------- -void WsjcppJsonRpc20ExportCliWebJs::setAppName(const std::string &sAppName) { - m_sAppName = sAppName; -} - -// --------------------------------------------------------------------- - void WsjcppJsonRpc20ExportCliWebJs::setClassName(const std::string &sClassName) { m_sClassName = sClassName; } @@ -97,12 +91,6 @@ void WsjcppJsonRpc20ExportCliWebJs::setDefaultConnectionString(const std::string // --------------------------------------------------------------------- -void WsjcppJsonRpc20ExportCliWebJs::setAppVersion(const std::string &sAppVersion) { - m_sAppVersion = sAppVersion; -} - -// --------------------------------------------------------------------- - bool WsjcppJsonRpc20ExportCliWebJs::doExportLib() { std::string sBasicDir = "./" + this->getPackageName(); @@ -159,8 +147,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportPackageJson() { packageJson << "{\n" " \"name\": \"" + this->getPackageName() + "\",\n" - " \"version\": \"" + m_sAppVersion + "\",\n" - " \"description\": \"" + m_sClassName + " JavaScript Web Client Library for " + m_sAppName + "\",\n" + " \"version\": \"" + this->getAppVersion() + "\",\n" + " \"description\": \"" + m_sClassName + " JavaScript Web Client Library for " + this->getAppName() + "\",\n" " \"main\": \"dist/" + this->getPackageName() + ".js\",\n" " \"repository\": {\n" " \"type\": \"" + m_sRepositoryType + "\",\n" @@ -199,8 +187,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportAPImd() { apimd << "# " + this->getPackageName() + "\n\n" - " Automatically generated by " << m_sAppName << ". \n" - " * Version: " << m_sAppVersion << "\n" + " Automatically generated by " << this->getAppName() << ". \n" + " * Version: " << this->getAppVersion() << "\n" " * Date: " << buffer.str() << "\n\n" " Include script ```dist/" + this->getPackageName() + ".js```\n" " Example connect:\n" @@ -381,11 +369,11 @@ bool WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebJSFile() { // now the result is in `buffer.str()`. libwjscppcli_web_js_file << - "// This file was automatically generated by " << m_sAppName << " (" + m_sAppVersion + "), date: " << sBuildDate << "\r\n" + "// This file was automatically generated by " << this->getAppName() << " (" + this->getAppVersion() + "), date: " << sBuildDate << "\r\n" "window." << m_sClassName << " = window." << m_sClassName << " || (function() { \r\n" " var self = {};\r\n" - " self.appName = '" + m_sAppName + "';\r\n" - " self.appVersion = '" + m_sAppVersion + "';\r\n" + " self.appName = '" + this->getAppName() + "';\r\n" + " self.appVersion = '" + this->getAppVersion() + "';\r\n" " self.appBuildDate = '" + sBuildDate + "';\r\n" " var _lastm = 0;\r\n" " var _listeners = {};\r\n" @@ -401,7 +389,7 @@ bool WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebJSFile() { libwjscppcli_web_js_file << " };\r\n" " function _lm() { _lastm++; return 'm' + _lastm; };\r\n" - " console.warn('" + m_sClassName + " (" + m_sAppVersion + ")');\r\n" + " console.warn('" + m_sClassName + " (" + this->getAppVersion() + ")');\r\n" " self.promise = function() {\r\n" " return {\r\n" " completed: false, failed: false, successed: false, \r\n" @@ -698,7 +686,7 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() { // now the result is in `buffer.str()`. libwjscppcli_web_service_ts_file << - "// This file was automatically generated by " << m_sAppName << " (v" + m_sAppVersion + "), date: " << sBuildDate << "\r\n" + "// This file was automatically generated by " << this->getAppName() << " (v" + this->getAppVersion() + "), date: " << sBuildDate << "\r\n" "import { Injectable, EventEmitter } from '@angular/core';\r\n" "import { PlatformLocation } from '@angular/common';\r\n" "import { ToastrService } from 'ngx-toastr';\r\n" @@ -707,8 +695,8 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() { "\r\n" "@Injectable({providedIn: 'root'})\r\n" "export class " + m_sClassName + " {\r\n" - " private appName: string = '" + m_sAppName + "';\r\n" - " private appVersion: string = '" + m_sAppVersion + "';\r\n" + " private appName: string = '" + this->getAppName() + "';\r\n" + " private appVersion: string = '" + this->getAppVersion() + "';\r\n" " private appBuildDate: string = '" + sBuildDate + "';\r\n" " isAuthorized: boolean = false;\r\n" " connectionState: string = '';\r\n" @@ -738,7 +726,7 @@ void WsjcppJsonRpc20ExportCliWebJs::exportLibCliWebServiceTSFile() { " ) {\r\n" " this.serverHost = this._location.hostname;\r\n" " this.currentProtocol = this._location.protocol;\r\n" - " console.warn('" + m_sClassName + " (" + m_sAppVersion + ")');\r\n" + " console.warn('" + m_sClassName + " (" + this->getAppVersion() + ")');\r\n" " this._tokenValue = this.getToken();\r\n" " }\r\n" "\r\n" diff --git a/src/wsjcpp_jsonrpc20_export_cli_webjs.h b/src/wsjcpp_jsonrpc20_export_cli_webjs.h index fc855ed..e173830 100644 --- a/src/wsjcpp_jsonrpc20_export_cli_webjs.h +++ b/src/wsjcpp_jsonrpc20_export_cli_webjs.h @@ -12,8 +12,6 @@ class WsjcppJsonRpc20ExportCliWebJs : public WsjcppJsonRpc20ExportCliBase { ); void setAuthorName(const std::string &sAuthorName); void setAuthorEmail(const std::string &sAuthorEmail); - void setAppName(const std::string &sAppName); - void setAppVersion(const std::string &sAppVersion); // TODO homepage void setClassName(const std::string &sClassName); void setIssuesURL(const std::string &sIssuesURL); @@ -27,8 +25,6 @@ class WsjcppJsonRpc20ExportCliWebJs : public WsjcppJsonRpc20ExportCliBase { std::string TAG; std::string m_sAuthorName; std::string m_sAuthorEmail; - std::string m_sAppName; - std::string m_sAppVersion; std::string m_sClassName; std::string m_sIssuesURL; std::string m_sRepositoryType;