代码的核心定义文件
之前的博客里面的很多代碼,有一些自己定義的數(shù)據(jù)類型,很多人很迷糊,下面把我的代碼定義的公用部分貼出來,方便大家查看代碼。
/*************************************************************************** * * Time: 2009-09-21 * Project: 遙感平臺(tái) * Purpose: 核心庫文件 * Author: 李民錄 * Copyright (c) 2009, liminlu0314@gmail.com * Describe:提供常用的數(shù)據(jù)類型定義等 * ****************************************************************************/#ifndef IMGALG_H #define IMGALG_H/** * \file ImgCore.h * @brief 核心類型定義 * * 導(dǎo)出接口(使用C語言方式),核心類型定義 *//** * 忽略在MS Widows平臺(tái)上的警告 lml 2010-10-19 * warning C4100: “*”: 未引用的形參 * warning C4190: “identifier1”有指定的 C 鏈接,但返回了與 C 不兼容的 UDT“identifier2” * warning C4251: 類“type”需要由類“type2”的客戶端使用 dll 接口 * warning C4275: 非 DLL 接口類鍵“identifier”作為 DLL 接口類鍵“identifier”的基使用 * warning C4305: 從“type1”到“type2”截?cái)?* warning C4309: 截?cái)喑?shù)值 * warning C4819: 該文件包含不能在當(dāng)前代碼頁(936)中表示的字符。請(qǐng)將該文件保存為 Unicode 格式以防止數(shù)據(jù)丟失 * warning C4996: 使用了非標(biāo)準(zhǔn)擴(kuò)展: 限定名中使用了枚舉 */ #if defined(_MSC_VER) && (_MSC_VER >= 1400) #pragma warning(disable: 4100 4190 4251 4275 4305 4309 4819 4996 ) #endif/** * @brief 是否使用Vld內(nèi)存泄露監(jiān)測工具 */ #if _USEVLD #if _DEBUG //在debug模式下檢測內(nèi)存泄露 #include "vld.h" #endif #endif/** * @brief 是否使用LOG工具進(jìn)行寫日志 */ #if _USELOG #define USE_LOG4CPP #endif#include <float.h> #include <algorithm> #include <deque> #include <fstream> #include <limits> #include <map> #include <stack> #include <string> #include <vector> using namespace std;/** * @brief 導(dǎo)出符號(hào)定義 */ #ifdef IMGALG_EXPORTS #define IMGALG_API __declspec(dllexport) #else #define IMGALG_API __declspec(dllimport) #endif/** * @brief 定義NULL */ #ifndef NULL # define NULL 0 #endif/** * @brief 定義FALSE */ #ifndef FALSE # define FALSE 0 #endif/** * @brief 定義TRUE */ #ifndef TRUE # define TRUE 1 #endif#ifndef MAX /*! 求最大值 */ # define MIN(a, b) ((a<b) ? a : b) /*! 求最小值 */ # define MAX(a, b) ((a>b) ? a : b) #endif/** * @brief 定義ABS,求絕對(duì)值 */ #ifndef ABS # define ABS(x) ((x<0) ? (-1*(x)) : x) #endif/** * @brief 定義PI=3.141592653...以及度和弧度轉(zhuǎn)換 */ #ifndef M_PI /*! 定義圓周率PI */ # define M_PI 3.1415926535897932384626433832795 /*! 弧度轉(zhuǎn)度 */ # define DEG_PER_RAD ((double)(180.0/M_PI)) /*! 度轉(zhuǎn)弧度 */ # define RAD_PER_DEG ((double)(M_PI/180.0)) #endif/** * @brief 定義平方 */ #ifndef M_SQUARE # define M_SQUARE(x) (x)*(x) #endif/** * @brief 定義立方 */ #ifndef M_CUBE # define M_CUBE(x) (x)*(x)*(x) #endif/*! 判斷浮點(diǎn)數(shù)是否NaN值 */ inline bool isnan(const float& v) { return _isnan(v) ? true : false; } /*! 判斷double數(shù)是否NaN值 */ inline bool isnan(const double& v) { return _isnan(v) ? true : false; } /*! 獲取double的NaN值 */ inline double nan() { return numeric_limits<double>::quiet_NaN(); }/** * @brief float類型的極值 */ #ifndef FLT_EQUALS /*! 浮點(diǎn)數(shù)是否相等 */ #define FLT_EQUALS(x, y) (fabs((double)x-y)<FLT_EPSILON) /*! 浮點(diǎn)數(shù)是否相等(指定比較閾值) */ #define FLT_EQUALS_N(x, y, z) (fabs((double)x-y)<z) #endif#ifndef FLT_ZERO /*! 浮點(diǎn)數(shù)是否為0 */ #define FLT_ZERO(x) (fabs(x)<FLT_EPSILON) #endif/** * @brief 釋放數(shù)組 */ #define RELEASE(x) if(x!=NULL) {delete []x; x = NULL;}/** * @brief 將全局區(qū)域設(shè)為操作系統(tǒng)默認(rèn)區(qū)域 */ #define SET_LOCAL { locale::global(locale("")); setlocale(LC_ALL,"Chinese-simplified"); } /** * @brief 還原全局區(qū)域設(shè)定 */ #define REVERT_LOCAL locale::global(locale("C"))#ifndef EQUAL #if defined(WIN32) || defined(WIN32CE) /*! 比較字符串是否相等 */ # define EQUALN(a, b, n) (_strnicmp(a, b, n) == 0) /*! 比較字符串是否相等 */ # define EQUAL(a, b) (_stricmp(a, b) == 0) #else /*! 比較字符串是否相等 */ # define EQUALN(a, b, n) (strncasecmp(a, b, n) == 0) /*! 比較字符串是否相等 */ # define EQUAL(a, b) (strcasecmp(a, b) == 0) #endif #endif/*! byte */ typedef unsigned char byte; /*! 8U */ typedef unsigned char DT_8U; /*! 16U */ typedef unsigned short DT_16U; /*! 16S */ typedef short DT_16S; /*! 32U */ typedef unsigned int DT_32U; /*! 32S */ typedef int DT_32S; /*! 32F */ typedef float DT_32F; /*! 64F */ typedef double DT_64F;/*! 成功執(zhí)行 */ const int RE_SUCCESS = 0; /*! 文件不存在 */ const int RE_FILENOTEXIST = 1; /*! 文件格式不被支持 */ const int RE_FILENOTSUPPORT = 2; /*! 圖像數(shù)據(jù)類型不正確 */ const int RE_FILETYPEERROR = 3; /*! 創(chuàng)建圖像失敗 */ const int RE_CREATEFAILED = 4; /*! 輸入?yún)?shù)錯(cuò)誤 */ const int RE_PARAMERROR = 5; /*! 其他錯(cuò)誤 */ const int RE_FAILED = 6; /*! 圖像不存在公共區(qū)域 */ const int RE_NOSAMEEXTENT = 7; /*! 用戶取消操作 */ const int RE_USERCANCEL = 8; /*! 文件已經(jīng)被使用 */ const int RE_FILEISUESED = 9; /*! 不支持的像素深度 */ const int RE_DEPTHNOTSUPPORT = 10; /*! 波段數(shù)量不符合要求 */ const int RE_BANDCOUNTERROR = 11; /*! 文件不存在投影 */ const int RE_NOPROJECTION = 12; /*! 投影不一致 */ const int RE_PROJECTIONDIFF = 13;#endif轉(zhuǎn)載于:https://www.cnblogs.com/xiaowangba/archive/2012/11/26/6313999.html
總結(jié)
- 上一篇: 【转】在CSS中 ID与Class的区别
- 下一篇: Lync 2010迁移Lync 2013