mexlog.h

来自「显著区域检测。求的图像中感兴趣区域的位置」· C头文件 代码 · 共 83 行

H
83
字号
/*!@file mexLog.h a few helpful functions for logging in mex files. */// This file is part of the SaliencyToolbox - Copyright (C) 2006-2007// by Dirk B. Walther and the California Institute of Technology.// See the enclosed LICENSE.TXT document for the license agreement. // More information about this project is available at: // http://www.saliencytoolbox.net#ifndef MEXLOG_H_DEFINED#define MEXLOG_H_DEFINED#include <streambuf>#include <iostream>#include <mex.h>#define ASSERT(exp) if (!(exp)) mexFatal("ASSERT failed in %s at line %d: " \                                         #exp,__FILE__,__LINE__);//! writes an info message to mexPrintfvoid mexInfo(const char *fmt,...);//! writes an error messagevoid mexError(const char *fmt,...);//! writes an error message and leaved the mex filevoid mexFatal(const char *fmt,...);//! writes a debug messagevoid mexDebug(const char *fmt,...);// ######################################################################//! This streambuf is used to re-direct cout and cerrclass MexBuf : public std::streambuf{ public:  MexBuf()  : std::streambuf()   { setbuf((char*)0,0); }    virtual int overflow(int c)  {    if (c != EOF)      mexPrintf("%c", c);    return c;  }  virtual std::streamsize xsputn(const char* s, const std::streamsize n)  {    std::streamsize c = n;    while (*s && c--)      mexPrintf("%c", *s++);    return n;  }};// ######################################################################//! This class triggers the redirection of the standard streams at constructionclass MexBufInit{ public:  MexBufInit(MexBuf& buf)    {    std::cout.rdbuf(&buf);    std::cerr.rdbuf(&buf);  }  ~MexBufInit() {} private:  MexBufInit(const MexBufInit&);  MexBufInit& operator=(const MexBufInit&);};// ######################################################################namespace{  static MexBuf mexbuf__;  static MexBufInit mexbufInit__(mexbuf__);}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?