- Main Page
- Classes
- Files
- Examples

- File List
- File Members

# include/board/Tools.h

Go to the documentation of this file.

    00001 /* -*- mode: c++ -*- */
    00010 #ifndef _BOARD_TOOLS_H_
    00011 #define _BOARD_TOOLS_H_
    00012
    00013 #include <iostream>
    00014 #include <ctime>
    00015 #include <cstring>
    00016
    00017 #define SHOW( V ) std::cerr << " " #V " = " << ( V ) << std::endl
    00018
    00019 namespace LibBoard {
    00020
    00025   class MessageStream {
    00026   public:
    00027
    00028     inline MessageStream( std::ostream & out, const char * prefix  );
    00029
    00030     template<typename T>
    00031     inline MessageStream operator<<( const T & v );
    00032
    00033   private:
    00034     std::ostream & _out;
    00035     const char * _prefix;
    00036   };
    00037
    00038   extern MessageStream error;
    00039   extern MessageStream warning;
    00040   extern MessageStream notice;
    00041
    00042   MessageStream::MessageStream( std::ostream & out, const char * prefix )
    00043     : _out( out ),
    00044       _prefix( prefix )
    00045   {
    00046   }
    00047
    00048   template<typename T>
    00049   MessageStream MessageStream::operator<<( const T & v )
    00050   {
    00051     if ( _prefix )
    00052       _out << _prefix << v;
    00053     else
    00054       _out << v;
    00055     return MessageStream( _out, 0 );
    00056   }
    00057
    00058
    00059 #if defined( _MSC_VER )
    00060 #define secured_sprintf sprintf_s
    00061 #else
    00062 #define secured_sprintf snprintf
    00063 #endif // defined( _MSC_VER )
    00064
    00065 inline void secured_strncpy( char * dst, const char * src, size_t count );
    00066 inline void secured_ctime( char * str, const time_t * t, size_t count );
    00067
    00068 }
    00069
    00070 #include "Tools.ih"
    00071
    00072 #endif /* _SHAPE_H_ */
    00073