Board  0.9.2
Tools.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
26 #ifndef _BOARD_TOOLS_H_
27 #define _BOARD_TOOLS_H_
28 
29 #include <iostream>
30 #include <ctime>
31 #include <cstring>
32 #include "Rect.h"
33 
34 #define SHOW( V ) std::cerr << " " #V " = " << ( V ) << std::endl
35 
36 namespace LibBoard {
37 
42 public:
43 
44  inline MessageStream( std::ostream & out, const char * prefix );
45 
46  template<typename T>
47  inline MessageStream operator<<( const T & v );
48 
49 private:
50  std::ostream & _out;
51  const char * _prefix;
52 };
53 
54 extern MessageStream error;
55 extern MessageStream warning;
56 extern MessageStream notice;
57 
58 MessageStream::MessageStream( std::ostream & out, const char * prefix )
59  : _out( out ),
60  _prefix( prefix )
61 {
62 }
63 
64 template<typename T>
65 MessageStream MessageStream::operator<<( const T & v )
66 {
67  if ( _prefix ) {
68  _out << _prefix << v;
69  } else {
70  _out << v;
71  }
72  return MessageStream( _out, 0 );
73 }
74 
75 #if defined( _MSC_VER )
76 #define secured_sprintf sprintf_s
77 #else
78 #define secured_sprintf snprintf
79 #endif // defined( _MSC_VER )
80 
81 inline void secured_strncpy( char * dst, const char * src, size_t count );
82 
83 inline void secured_ctime( char * str, const time_t * t, size_t count );
84 
85 bool base64encode(std::istream & in, std::ostream & , int linesize = 80);
86 
87 bool stringEndsWith( const char * str, const char * end );
88 
89 void flushFile( const char * filename, std::ostream & out );
90 
91 Rect getEPSBoundingBox( const char * filename );
92 
93 bool canCreateFile( const char * filename );
94 
95 bool canReadFile( const char * filename );
96 
97 const char * temporaryFilename( const char * extension );
98 
99 unsigned int boardRand();
100 
101 } // namespace LibBoard
102 
103 #include "Tools.ih"
104 
105 #endif /* _SHAPE_H_ */
106 
Definition: Board.h:40
Definition: Tools.h:41
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...