Parcourir la source

refactor & feat: 添加noexcept(false)标记

SongZihuan il y a 3 ans
Parent
commit
fe2d4006f3

+ 2 - 2
include/tool/log.h

@@ -37,8 +37,8 @@ namespace aFuntool {
         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, ...);
+        int writeSendErrorLog(const char *file, int line, const char *func, const char *format, ...) noexcept(false);
+        int writeFatalErrorLog(const char *file, int line, const char *func, int exit_code, const char *format, ...) noexcept(false);
     private:
         const std::string id_;
         LogLevel level_ = log_debug;

+ 1 - 1
include/tool/md5.h

@@ -17,7 +17,7 @@ namespace aFuntool {
     AFUN_TOOL_EXPORT void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int input_len);
 
     template <typename T>
-    T getFileMd5 (T &path);
+    T getFileMd5 (T &path) noexcept(false) ;
 }
 
 #endif //AFUN_MD5_H

+ 1 - 1
include/tool/tool-regex.h

@@ -7,7 +7,7 @@ namespace aFuntool {
         std::regex re;  // 正则表达式
         std::string pattern;  // 正则表达式的字符串
     public:
-        inline explicit Regex(std::string pattern_);
+        inline explicit Regex(std::string pattern_) noexcept(false);
         inline Regex(const Regex &regex) noexcept;
         inline Regex(Regex &&regex) noexcept;
         Regex &operator=(const Regex &regex)=delete;

+ 1 - 1
include/tool/tool-regex.inline.h

@@ -4,7 +4,7 @@
 #include "tool-regex.h"
 
 namespace aFuntool {
-    inline Regex::Regex(std::string pattern_) : re{pattern_}, pattern{std::move(pattern_)} {
+    inline Regex::Regex(std::string pattern_) noexcept(false) : re{pattern_}, pattern{std::move(pattern_)} {
         if (!isCharUTF8(pattern))
             throw RegexException("Pattern not utf-8");
     }

+ 2 - 2
src/tool/log.cpp

@@ -421,7 +421,7 @@ namespace aFuntool {
 #undef sendErrorLog
 
     int Logger::writeSendErrorLog(const char *file, int line, const char *func,
-                                  const char *format, ...){
+                                  const char *format, ...) noexcept(false) {
 #ifndef aFunOFFAllLog
 #if !aFunIgnoreSendError
         va_list ap;
@@ -439,7 +439,7 @@ namespace aFuntool {
 #undef fatalErrorLog
 
     int Logger::writeFatalErrorLog(const char *file, int line, const char *func,
-                                   int exit_code, const char *format, ...){
+                                   int exit_code, const char *format, ...) noexcept(false){
 #ifndef aFunOFFAllLog
 #if !aFunIgnoreFatal
         va_list ap;

+ 1 - 1
src/tool/md5.cpp

@@ -193,7 +193,7 @@ namespace aFuntool {
 
 
     template<typename T>
-    T getFileMd5(T &path){
+    T getFileMd5(T &path) noexcept(false) {
         FILE *fd;
 
         unsigned long ret;