51Testing软件测试论坛

标题: base.h [打印本页]

作者: wwtsanmao    时间: 2009-12-21 16:30
标题: base.h
#ifndef _BASE_H
#define _BASE_H
#include <string.h>
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
typedef short Int2;

#define PRINT(X) print(X);
#define NEW(x,y) x = new(y);if (x == NULL) { PRINT("apply memory error!"); exit (1); };
#define DELETE_A(p) if (p != NULL) {delete p; p = NULL; }
#define DELETE_P(p) do { if (p != NULL) {delete [] p; p = NULL; } } while (0)
inline void print(int i)
{
cout << i <<endl;
}
inline void print(char *s)
{
cout << s <<endl;
}
inline void print(char c)
{
cout << c <<endl;
}
inline char* IntToStr (int v)
{
const int max_len=50;
static char tmp[max_len+1];
//char *tmp;
//tmp = new(char[max_len+1]);
memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%ld", v);
return tmp;
}
#define VAR_LOG(var) Var_Log(#var,var);
inline void Base_log (char* var,char* var1)
{
if(var)
{
  if(var1)
  {
   cout << var << "=" << var1 << endl;
  }
  else
  {
   cout << var << " is NULL" << endl;
  }
}
else
{
  PRINT("error!");
}
return;
}
inline void Var_Log(char* var,int var1)
{
Base_log(var,IntToStr(var1));
}
inline void Var_Log(char* var,char* var1)
{
Base_log(var,var1);
}

//extern CString
/*void Var_Log(char* var,CString var1)
{
Base_log(var,var1.Data());
}*/
template <class T>
void CopyElements(T* pDest, const T* pSrc, int numof)
{
if (pDest == pSrc)
{
  return;
}
memcpy(pDest, pSrc, numof);
return;
}

#endif




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2