diff --git a/Linux.mk b/Linux.mk new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/NahidaProject.Communication/Sources/HTTPClient.h b/NahidaProject.Communication/Sources/HTTPClient.h index abc951914205ddf8a2cead952db7d891283327e1..9337d4fbb325f2c365cf32fbd8568c8e98dbd07f 100644 --- a/NahidaProject.Communication/Sources/HTTPClient.h +++ b/NahidaProject.Communication/Sources/HTTPClient.h @@ -1,10 +1,31 @@ -#include +/* +Copyright (c) 2025 HeZongLun +NahidaProject is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan +PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +#pragma once + +#include #include #include #include #include #include +#ifdef _WIN32 +#define ExportSymbol __declspec(dllexport) +#else +#define ExportSymbol +#endif + #ifdef _WIN32 #include #include @@ -21,9 +42,9 @@ namespace NahidaProject { - enum class ClientHTTPMethod { GET, POST, PUT, DELETE_METHOD, HEAD, OPTIONS}; + enum class ExportSymbol ClientHTTPMethod { GET, POST, PUT, DELETE_METHOD, HEAD, OPTIONS}; - enum class ClientHTTPStatus { + enum class ExportSymbol ClientHTTPStatus { OK = 200, CREATED = 201, ACCEPTED = 202, @@ -37,7 +58,7 @@ namespace NahidaProject { SERVICE_UNAVAILABLE = 503 }; - struct ClientHTTPResponse { + struct ExportSymbol ClientHTTPResponse { int statusCode; std::string statusMessage; std::map headers; @@ -46,7 +67,7 @@ namespace NahidaProject { ClientHTTPResponse() : statusCode(0) {} }; - class HTTPClient { + class ExportSymbol HTTPClient { private: std::string baseUrl; std::map defaultHeaders; diff --git a/NahidaProject.Communication/Sources/HTTPServer.h b/NahidaProject.Communication/Sources/HTTPServer.h index 72d5dca5322fbac3be120f76dbc0ebf3d227e8c6..bfeec49d72773316c43df1b8a80ebc2feb2c7c53 100644 --- a/NahidaProject.Communication/Sources/HTTPServer.h +++ b/NahidaProject.Communication/Sources/HTTPServer.h @@ -1,4 +1,19 @@ -#include +/* +Copyright (c) 2025 HeZongLun +NahidaProject is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan +PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +#pragma once + +#include #include #include #include @@ -8,6 +23,12 @@ #include #include +#ifdef _WIN32 +#define ExportSymbol __declspec(dllexport) +#else +#define ExportSymbol +#endif + #ifdef _WIN32 #include #include @@ -21,7 +42,7 @@ #endif namespace NahidaProject { - class HTTPServer { + class ExportSymbol HTTPServer { public: // HTTP请求结构 struct HTTPRequest { @@ -34,7 +55,7 @@ namespace NahidaProject { }; // HTTP响应结构 - struct HTTPResponse { + struct ExportSymbol HTTPResponse { int statusCode = 200; std::string statusText = "OK"; std::map headers; diff --git a/NahidaProject.Communication/Sources/SerialPort.cpp b/NahidaProject.Communication/Sources/SerialPort.cpp index 3a6320bbac8239719366fbe4fd7e81c224eb2d5e..b541a6b065169ae3c1b344e686346a26ec3dfb82 100644 --- a/NahidaProject.Communication/Sources/SerialPort.cpp +++ b/NahidaProject.Communication/Sources/SerialPort.cpp @@ -194,25 +194,25 @@ NahidaProject::SerialPort::ErrorCode NahidaProject::SerialPort::ConfigureSerialP // 设置波特率 speed_t baud = B9600; switch (baudRate_) { - case BaudRate::BAUD_110: baud = B110; break; - case BaudRate::BAUD_300: baud = B300; break; - case BaudRate::BAUD_600: baud = B600; break; - case BaudRate::BAUD_1200: baud = B1200; break; - case BaudRate::BAUD_2400: baud = B2400; break; - case BaudRate::BAUD_4800: baud = B4800; break; - case BaudRate::BAUD_9600: baud = B9600; break; - case BaudRate::BAUD_19200: baud = B19200; break; - case BaudRate::BAUD_38400: baud = B38400; break; - case BaudRate::BAUD_57600: baud = B57600; break; - case BaudRate::BAUD_115200: baud = B115200; break; + case BaudRate::BAUDRATE_110: baud = B110; break; + case BaudRate::BAUDRATE_300: baud = B300; break; + case BaudRate::BAUDRATE_600: baud = B600; break; + case BaudRate::BAUDRATE_1200: baud = B1200; break; + case BaudRate::BAUDRATE_2400: baud = B2400; break; + case BaudRate::BAUDRATE_4800: baud = B4800; break; + case BaudRate::BAUDRATE_9600: baud = B9600; break; + case BaudRate::BAUDRATE_19200: baud = B19200; break; + case BaudRate::BAUDRATE_38400: baud = B38400; break; + case BaudRate::BAUDRATE_57600: baud = B57600; break; + case BaudRate::BAUDRATE_115200: baud = B115200; break; #ifdef B230400 - case BaudRate::BAUD_230400: baud = B230400; break; + case BaudRate::BAUDRATE_230400: baud = B230400; break; #endif #ifdef B460800 - case BaudRate::BAUD_460800: baud = B460800; break; + case BaudRate::BAUDRATE_460800: baud = B460800; break; #endif #ifdef B921600 - case BaudRate::BAUD_921600: baud = B921600; break; + case BaudRate::BAUDRATE_921600: baud = B921600; break; #endif default: baud = B9600; break; } diff --git a/NahidaProject.Communication/Sources/SerialPort.h b/NahidaProject.Communication/Sources/SerialPort.h index d113d191843579cbc2c2a7f3110891ac9ffdb669..161229256b790ac5415661cac0db2646f8b393ee 100644 --- a/NahidaProject.Communication/Sources/SerialPort.h +++ b/NahidaProject.Communication/Sources/SerialPort.h @@ -1,4 +1,17 @@ -#pragma once +/* +Copyright (c) 2025 HeZongLun +NahidaProject is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan +PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +#pragma once #include #include @@ -8,10 +21,16 @@ #include #include #include -#pragma comment(lib, "kernel32.lib") + +#ifdef _WIN32 +#define ExportSymbol __declspec(dllexport) +#else +#define ExportSymbol +#endif #ifdef _WIN32 #include + #pragma comment(lib, "kernel32.lib") #else #include #include @@ -21,10 +40,10 @@ #endif namespace NahidaProject { - class SerialPort { + class ExportSymbol SerialPort { public: // 波特率枚举 - enum class BaudRate { + enum class ExportSymbol BaudRate { BAUDRATE_110 = 110, BAUDRATE_300 = 300, BAUDRATE_600 = 600, @@ -43,7 +62,7 @@ namespace NahidaProject { }; // 数据位枚举 - enum class DataBits { + enum class ExportSymbol DataBits { DATA_5 = 5, DATA_6 = 6, DATA_7 = 7, @@ -51,14 +70,14 @@ namespace NahidaProject { }; // 停止位枚举 - enum class StopBits { + enum class ExportSymbol StopBits { STOP_1 = 1, // 1个停止位 STOP_1_5 = 15, // 1.5个停止位 STOP_2 = 2 // 2个停止位 }; // 校验位枚举 - enum class Parity { + enum class ExportSymbol Parity { NONE, // 无校验 ODD, // 奇校验 EVEN, // 偶校验 @@ -67,14 +86,14 @@ namespace NahidaProject { }; // 流控制枚举 - enum class FlowControl { + enum class ExportSymbol FlowControl { NONE, // 无流控制 HARDWARE, // 硬件流控制 SOFTWARE // 软件流控制 }; // 错误码枚举 - enum class ErrorCode { + enum class ExportSymbol ErrorCode { SUCCESS = 0, INVALID_PARAMETER, PORT_NOT_OPEN, diff --git a/NahidaProject.Communication/Sources/StaticWebServer.h b/NahidaProject.Communication/Sources/StaticWebServer.h index 48972b6b61fb561fece65ebcc04a19c943817cda..837a1283e14203fe1c7fd3df3cce7ff18124377f 100644 --- a/NahidaProject.Communication/Sources/StaticWebServer.h +++ b/NahidaProject.Communication/Sources/StaticWebServer.h @@ -1,13 +1,34 @@ -#include +/* +Copyright (c) 2025 HeZongLun +NahidaProject is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan +PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +#pragma once + +#include #include #include #include #include +#ifdef _WIN32 +#define ExportSymbol __declspec(dllexport) +#else +#define ExportSymbol +#endif + namespace NahidaProject { - class StaticWebServer { + class ExportSymbol StaticWebServer { public: - struct StaticWebServerHTTPRequest { + struct ExportSymbol StaticWebServerHTTPRequest { std::string method; std::string url; std::string version; diff --git a/NahidaProject.Communication/Tests/ModuleUnitTestFile.cpp b/NahidaProject.Communication/Tests/ModuleUnitTestFile.cpp index a18dee048e209492f54fba08bda9bb04eebf16f2..0df0401e92a243081607aec996fbad66d9c82128 100644 --- a/NahidaProject.Communication/Tests/ModuleUnitTestFile.cpp +++ b/NahidaProject.Communication/Tests/ModuleUnitTestFile.cpp @@ -1,9 +1,9 @@ -# include "..\..\NahidaProject.UnitTest\Sources\NahidaUnitTest.h" +# include "../../NahidaProject.UnitTest/Sources/NahidaUnitTest.h" -#include "..\Sources\HTTPClient.h" -#include "..\Sources\HTTPServer.h" -#include "..\Sources\SerialPort.h" -#include "..\Sources\StaticWebServer.h" +#include "../Sources/HTTPClient.h" +#include "../Sources/HTTPServer.h" +#include "../Sources/SerialPort.h" +#include "../Sources/StaticWebServer.h" Test(HTTPClientTest) { try { diff --git a/NahidaProject.Console/Sources/ChooseDialog.h b/NahidaProject.Console/Sources/ChooseDialog.h index d5bacc6abdbb5d9db4a84c5e570af698f52382f2..9f3f18a6200c11c657bed16bc9ee1c5215491f45 100644 --- a/NahidaProject.Console/Sources/ChooseDialog.h +++ b/NahidaProject.Console/Sources/ChooseDialog.h @@ -13,6 +13,12 @@ See the Mulan PSL v2 for more details. #pragma once +#ifdef _WIN32 +#define ExportSymbol __declspec(dllexport) +#else +#define ExportSymbol +#endif + #include #include #include @@ -40,7 +46,7 @@ const std::wstring NO_INSTRUCTION = L""; namespace NahidaProject { namespace ChooseDialog { - class __declspec(dllexport) Option { + class ExportSymbol Option { public: BOOL IsSelected() const { return _selected; @@ -76,7 +82,7 @@ namespace NahidaProject { }; - struct __declspec(dllexport) MenuState { + struct ExportSymbol MenuState { std::vector