forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmplutils.h
81 lines (62 loc) · 1.39 KB
/
mplutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- mode: c++; c-basic-offset: 4 -*- */
/* mplutils.h --
*
* $Header$
* $Log$
* Revision 1.2 2004/11/24 15:26:12 jdh2358
* added Printf
*
* Revision 1.1 2004/06/24 20:11:17 jdh2358
* added mpl src
*
*/
#ifndef _MPLUTILS_H
#define _MPLUTILS_H
#include <Python.h>
#include <string>
#include <iostream>
#include <sstream>
#if PY_MAJOR_VERSION >= 3
#define PY3K 1
#else
#define PY3K 0
#endif
void _VERBOSE(const std::string&);
#undef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
inline double mpl_round(double v)
{
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
}
class Printf
{
private :
char *buffer;
public :
Printf(const char *, ...);
~Printf();
std::string str()
{
return buffer;
}
friend std::ostream &operator <<(std::ostream &, const Printf &);
};
#if defined(_MSC_VER) && (_MSC_VER == 1400)
/* Required by libpng and zlib */
#pragma comment(lib, "bufferoverflowU")
/* std::max and std::min are missing in Windows Server 2003 R2
Platform SDK compiler. See matplotlib bug #3067191 */
namespace std {
template <class T> inline T max(const T& a, const T& b)
{
return (a > b) ? a : b;
}
template <class T> inline T min(const T& a, const T& b)
{
return (a < b) ? a : b;
}
}
#endif
#endif