会VC的富翁看一下,这个头文件如何定义成DELPHI?(300分)

  • 主题发起人 主题发起人 wk_knife
  • 开始时间 开始时间
W

wk_knife

Unregistered / Unconfirmed
GUEST, unregistred user!
找到一个射影变换的头文件,本人VC的只能看懂一点点,最后的matrixT的意思如何理解?

// _NO_NAMESPACE: Define this macro to remove namespace support.
//
// _NO_EXCEPTION: Define this macro to remove exception handling
// and use old style of error handling using function.
//
// _NO_TEMPLATE: If this macro is defined matrix class ofdo
uble
// type will be generated by default. You can also
// generate a different type of matrix like float.
//
// _SGI_BROKEN_STL: For SGI C++ v.7.2.1 compiler.
//
#ifndef __cplusplus
#error Must use C++ for the type matrix.
#endif
#if !defined(__STD_MATRIX_H)
#define __STD_MATRIX_H
//////////////////////////////
// First deal with various shortcomings and incompatibilities of
// various (mainly old) versions of popular compilers available.
//
#if defined(__BORLANDC__)
#pragma option -w-inl -w-pch
#endif
#if ( defined(__BORLANDC__) || _MSC_VER <= 1000 ) && !defined( __GNUG__ )
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <iostream.h>
# include <string.h>
#else
# include <cmath>
# include <cstdio>
# include <cstdlib>
# include <string>
# include <iostream>
#endif
#if defined(_MSC_VER) && _MSC_VER <= 1000
# define _NO_EXCEPTION // stdexception is not fully supported in MSVC++ 4.0
typedef int bool;
# if !defined(false)
# define false 0
# endif
# if !defined(true)
# define true 1
# endif
#endif
#if defined(__BORLANDC__) && !defined(__WIN32__)
# define _NO_EXCEPTION // std exception and namespace are not fully
# define _NO_NAMESPACE // supported in 16-bit compiler
#endif
#if defined(_MSC_VER) && !defined(_WIN32)
# define _NO_EXCEPTION
#endif
#if defined(_NO_EXCEPTION)
# define _NO_THROW
# define _THROW_MATRIX_ERROR
#else
# if defined(_MSC_VER)
# if _MSC_VER >= 1020
# include <stdexcept>
# else
# include <stdexcpt.h>
# endif
# elif defined(__MWERKS__)
# include <stdexcept>
# elif (__GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
# include <stdexcept>
# else
# include <stdexcep>
# endif
# define _NO_THROW throw ()
# define _THROW_MATRIX_ERROR throw (matrix_error)
#endif
#ifndef __MINMAX_DEFINED
# define max(a,b) (((a) > (b)) ? (a) : (b))
# define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#if defined(_MSC_VER)
#undef _MSC_EXTENSIONS // To include overloaded abs function definitions!
#endif
#if ( defined(__BORLANDC__) || _MSC_VER ) && !defined( __GNUG__ )
inline float abs (float v) { return (float)fabs( v);
}
inlinedo
uble abs (double v) { return fabs( v);
}
inline longdo
uble abs (longdo
uble v) { return fabsl( v);
}
#endif
#if defined(__GNUG__) || defined(__MWERKS__) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x540))
#define FRIEND_FUN_TEMPLATE <>
#else
#define FRIEND_FUN_TEMPLATE
#endif
#if defined(_MSC_VER) && _MSC_VER <= 1020 // MSVC++ 4.0/4.2do
es not
# define _NO_NAMESPACE // support "std" namespace
#endif
#if !defined(_NO_NAMESPACE)
#if defined( _SGI_BROKEN_STL ) // For SGI C++ v.7.2.1 compiler
namespace std { }
#endif
using namespace std;
#endif
#ifndef _NO_NAMESPACE
namespace math {
#endif
#if !defined(_NO_EXCEPTION)
class matrix_error : public logic_error
{
public:
matrix_error (const string& what_arg) : logic_error( what_arg) {}
};
#define REPORT_ERROR(ErrormMsg) throw matrix_error( ErrormMsg);
#else
inline void _matrix_error (const char* pErrMsg)
{
cout << pErrMsg << endl;
exit(1);
}
#define REPORT_ERROR(ErrormMsg) _matrix_error( ErrormMsg);
#endif
#if !defined(_NO_TEMPLATE)
# define MAT_TEMPLATE template <class T>
# define matrixT matrix<T>
#else
# define MAT_TEMPLATE
# define matrixT matrix
# ifdef MATRIX_TYPE
typedef MATRIX_TYPE T;
# else
typedefdo
uble T;
# endif
#endif

MAT_TEMPLATE
class matrix
{
public:
// Constructors
matrix (const matrixT& m);
//这个matrixT如何理解?
matrix (size_t row = 6, size_t col = 6);
// Destructor
~matrix ();
 
# define matrixT matrix
这里不是说了吗?晕.....
 
// 估计你的困惑在C++的模板上,找本书翻一下
#if !defined(_NO_TEMPLATE) // 如果已经创建了模板
# define MAT_TEMPLATE template <class T> // 宏定义我就不说了,后面为C++
// 的模板模板定义方式
# define matrixT matrix<T> // 同样,模板
#else
// 如果没有模板
# define MAT_TEMPLATE
# define matrixT matrix // matrixT 代表 matrix
# ifdef MATRIX_TYPE
typedef MATRIX_TYPE T;
# else
typedefdo
uble T;
# endif
#endif
 
C++中的模板是否和VCL中的TCLASS有相同点
如:matrixT=class of matrix
或者是为了定义类的数组做准备,如
matrixT=array of matrix
或者是其他概念,定义摸板是为了什么样的应用需要呢?
 
刚才看了点文章,摸板简单说就是容器+算法,对吧?
matrix是一个自己定义的摸板类,它要么只是个简单的容器,要么还要实现一定的算法.
这样理解是否恰当?
 
delphi有条件编译的吗?
 
delphi有条件编译!
 
多人接受答案了。
 
后退
顶部