DGtal 1.3.0
Loading...
Searching...
No Matches
Tools.h
1/* -*- mode: c++ -*- */
9/*
10 * \@copyright This File is part of the Board library which is
11 * licensed under the terms of the GNU Lesser General Public Licence.
12 * See the LICENCE file for further details.
13 */
14#ifndef _BOARD_TOOLS_H_
15#define _BOARD_TOOLS_H_
16
17#include <iostream>
18#include <ctime>
19#include <cstring>
20
21#define SHOW( V ) std::cerr << " " #V " = " << ( V ) << std::endl
22
23namespace LibBoard {
24
30 public:
31
32 inline MessageStream( std::ostream & out, const char * prefix );
33
34 template<typename T>
35 inline MessageStream operator<<( const T & v );
36
37 private:
38 std::ostream & _out;
39 const char * _prefix;
40 };
41
42 extern MessageStream error;
44 extern MessageStream notice;
45
46 MessageStream::MessageStream( std::ostream & out, const char * prefix )
47 : _out( out ),
48 _prefix( prefix )
49 {
50 }
51
52 template<typename T>
54 {
55 if ( _prefix )
56 _out << _prefix << v;
57 else
58 _out << v;
59 return MessageStream( _out, 0 );
60 }
61
62
63#if defined( _MSC_VER )
64#define secured_sprintf sprintf_s
65#else
66#define secured_sprintf snprintf
67#endif // defined( _MSC_VER )
68
69inline void secured_strncpy( char * dst, const char * src, size_t count );
70inline void secured_ctime( char * str, const time_t * t, size_t count );
71
72}
73
74#include "Tools.ih"
75
76#endif /* _SHAPE_H_ */
77
std::ostream & _out
Definition: Tools.h:38
MessageStream(std::ostream &out, const char *prefix)
Definition: Tools.h:46
const char * _prefix
Definition: Tools.h:39
MessageStream operator<<(const T &v)
Definition: Tools.h:53
MessageStream warning
void secured_ctime(char *str, const time_t *t, size_t count)
MessageStream error
MessageStream notice
void secured_strncpy(char *dst, const char *src, size_t count)