فهرست منبع

refactor & fix: tool类成员添加dllimport标志

SongZihuan 3 سال پیش
والد
کامیت
db9517edce
7فایلهای تغییر یافته به همراه53 افزوده شده و 42 حذف شده
  1. 1 1
      include/core/code.hpp
  2. 2 1
      include/core/env-var.hpp
  3. 1 0
      include/core/init.hpp
  4. 1 0
      include/core/msg.hpp
  5. 7 7
      include/tool/dlc.hpp
  6. 38 30
      include/tool/log.hpp
  7. 3 3
      include/tool/regex.hpp

+ 1 - 1
include/core/code.hpp

@@ -1,6 +1,7 @@
 #ifndef AFUN_CODE_HPP
 #define AFUN_CODE_HPP
 #include "tool.hpp"
+#include "aFunCoreExport.h"
 
 namespace aFuncore {
     typedef enum CodeType {
@@ -36,7 +37,6 @@ namespace aFuncore {
         aFuntool::FileLine line;
         aFuntool::FilePath file;
     public:
-
         explicit Code(FileLine line, ConstFilePath file="");
         Code (const std::string &element, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);
         Code (BlockType block_type, Code *son, aFuntool::FileLine line, aFuntool::ConstFilePath file="", char prefix=NUL);

+ 2 - 1
include/core/env-var.hpp

@@ -1,6 +1,7 @@
 #ifndef AFUN_ENV_VAR_HPP
 #define AFUN_ENV_VAR_HPP
 #include "tool.hpp"
+#include "aFunCoreExport.h"
 
 namespace aFuncore {
     static const size_t ENV_VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
@@ -22,7 +23,7 @@ namespace aFuncore {
         EnvVarSpace();
         ~EnvVarSpace();
 
-        [[nodiscard]]  size_t getCount() const {return count;}
+        [[nodiscard]] size_t getCount() const {return count;}
 
         bool findString(const std::string &name, std::string &str) const;
         bool findNumber(const std::string &name, int32_t &num) const;

+ 1 - 0
include/core/init.hpp

@@ -1,6 +1,7 @@
 #ifndef AFUN_INIT_HPP
 #define AFUN_INIT_HPP
 #include "tool.hpp"
+#include "aFunCoreExport.h"
 
 namespace aFuncore {
     struct InitInfo {

+ 1 - 0
include/core/msg.hpp

@@ -1,6 +1,7 @@
 #ifndef AFUN_MSG_HPP
 #define AFUN_MSG_HPP
 #include "tool.hpp"
+#include "aFunCoreExport.h"
 
 namespace aFuncore {
     class MessageStream;

+ 7 - 7
include/tool/dlc.hpp

@@ -27,8 +27,8 @@ namespace aFuntool {
     template <typename SYMBOL>
     class DlcSymbol;
 
-    AFUN_TOOL_EXPORT DlcHandle *openLibrary(const char *file, int mode);
     AFUN_TOOL_EXPORT void dlcExit();
+    AFUN_TOOL_EXPORT DlcHandle *openLibrary(const char *file, int mode);
 
     /**
      * DlcHandle: 动态库句柄
@@ -36,8 +36,8 @@ namespace aFuntool {
      * 不需要 delete 释放 (自动管理释放)
      */
     class DlcHandle {
-        friend void dlcExit();
-        friend DlcHandle *openLibrary(const char *file, int mode);
+        friend AFUN_TOOL_EXPORT void dlcExit();
+        friend AFUN_TOOL_EXPORT DlcHandle *openLibrary(const char *file, int mode);
 
         explicit DlcHandle(void *handle);  // 仅 openLibary 可用
         void *handle;
@@ -45,7 +45,7 @@ namespace aFuntool {
         struct DlcHandle *next;
         struct DlcHandle *prev;
     public:
-        ~DlcHandle();
+        AFUN_TOOL_EXPORT ~DlcHandle();
 
         /**
          * 获得动态库中指定名字的符号
@@ -64,9 +64,9 @@ namespace aFuntool {
         /**
          * 关闭动态库句柄
          */
-        void close();
-        int operator++(int);
-        int operator--(int);
+        AFUN_TOOL_EXPORT void close();
+        AFUN_TOOL_EXPORT int operator++(int);
+        AFUN_TOOL_EXPORT int operator--(int);
     };
 
     /**

+ 38 - 30
include/tool/log.hpp

@@ -1,5 +1,6 @@
 #ifndef AFUN_LOG_HPP
 #define AFUN_LOG_HPP
+
 #include <iostream>
 #include "aFunToolExport.h"
 #include "macro.hpp"
@@ -26,22 +27,30 @@ namespace aFuntool {
         const std::string id;
         LogLevel level = log_debug;
         bool exit = true;
+
         friend class LogFactory;
 
     public:
-        explicit Logger(const std::string &id_, LogLevel level_=log_warning, bool exit_=true);
+        explicit Logger(const std::string &id_, LogLevel level_ = log_warning, bool exit_ = true);
+
         int writeTrackLog(const char *file, int line, const char *func,
                           const char *format, ...);
+
         int writeDebugLog(const char *file, int line, const char *func,
                           const char *format, ...);
+
         int writeInfoLog(const char *file, int line, const char *func,
                          const char *format, ...);
+
         int writeWarningLog(const char *file, int line, const char *func,
                             const char *format, ...);
+
         int writeErrorLog(const char *file, int line, const char *func,
                           const char *format, ...);
+
         int writeSendErrorLog(const char *file, int line, const char *func,
                               const char *format, ...);
+
         int writeFatalErrorLog(const char *file, int line, const char *func,
                                int exit_code, const char *format, ...);
     };
@@ -63,37 +72,36 @@ namespace aFuntool {
 
     public:
         Logger sys_log = Logger("SYSTEM");
-
-        LogFactory();
-        ~LogFactory();
-        int initLogSystem(ConstFilePath path, bool is_asyn=true);
-        bool destruct();
-        void writeLog(LogLevel level,
-                      const char *id, pid_t tid,
-                      const char *ti, time_t t,
-                      const char *file, int line, const char *func,
-                      const char *info);
-        static void writeConsole(LogLevel level,
-                          const char *id, pid_t tid,
-                          const char *ti, time_t t,
-                          const char *file, int line, const char *func,
-                          const char *info);
-        void writeLogAsyn(LogLevel level,
-                          const char *id, pid_t tid,
-                          const char *ti, time_t t,
-                          const char *file, int line, const char *func, const char *info);
-        int newLog(Logger *logger,
-                    bool pc,
-                    LogLevel level,
-                    const char *file, int line, const char *func,
-                    const char *format, va_list ap);
-        bool news() {return !init || log_buf != nullptr;}
-        int wait() {return pthread_cond_wait(&cond, &mutex);}
-        bool stop() {return !init && log_buf == nullptr;}
-        struct LogNode *pop();
+        AFUN_TOOL_EXPORT LogFactory();
+        AFUN_TOOL_EXPORT ~LogFactory();
+        AFUN_TOOL_EXPORT int initLogSystem(ConstFilePath path, bool is_asyn = true);
+        AFUN_TOOL_EXPORT bool destruct();
+        AFUN_TOOL_EXPORT void writeLog(LogLevel level,
+                                       const char *id, pid_t tid,
+                                       const char *ti, time_t t,
+                                       const char *file, int line, const char *func,
+                                       const char *info);
+        AFUN_TOOL_EXPORT static void writeConsole(LogLevel level,
+                                                  const char *id, pid_t tid,
+                                                  const char *ti, time_t t,
+                                                  const char *file, int line, const char *func,
+                                                  const char *info);
+        AFUN_TOOL_EXPORT void writeLogAsyn(LogLevel level,
+                                           const char *id, pid_t tid,
+                                           const char *ti, time_t t,
+                                           const char *file, int line, const char *func, const char *info);
+        AFUN_TOOL_EXPORT int newLog(Logger *logger,
+                                    bool pc,
+                                    LogLevel level,
+                                    const char *file, int line, const char *func,
+                                    const char *format, va_list ap);
+        bool news(){ return !init || log_buf != nullptr; }
+        int wait(){ return pthread_cond_wait(&cond, &mutex); }
+        bool stop(){ return !init && log_buf == nullptr; }
+        AFUN_TOOL_EXPORT struct LogNode *pop();
     };
 
-    extern LogFactory log_factory;
+    AFUN_TOOL_EXPORT extern LogFactory log_factory;
 }
 
 #ifndef NO_DEFINE_LOG_MACRO

+ 3 - 3
include/tool/regex.hpp

@@ -13,9 +13,9 @@ namespace aFuntool {
         pcre2_code *re;  // 正则表达式
         const std::string pattern;  // 正则表达式的字符串
     public:
-        explicit Regex (const std::string &pattern_);
-        ~Regex ();
-        int match(const char *subject);
+        AFUN_TOOL_EXPORT explicit Regex (const std::string &pattern_);
+        AFUN_TOOL_EXPORT ~Regex ();
+        AFUN_TOOL_EXPORT int match(const char *subject);
     };
 }