File: mplutils.cpp

package info (click to toggle)
matplotlib 1.1.1~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 66,076 kB
  • sloc: python: 90,600; cpp: 69,891; objc: 5,231; ansic: 1,723; makefile: 171; sh: 7
file content (34 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (2)
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
/* -*- mode: c++; c-basic-offset: 4 -*- */

#include <iostream>
#include <cstdarg>
#include <cstdio>
#include "mplutils.h"

void _VERBOSE(const std::string& s)
{
#ifdef VERBOSE
    std::cout << s << std::endl;
#endif
}


Printf::Printf(const char *fmt, ...)
    : buffer(new char[1024]) // some reasonably large number
{
    va_list ap;
    va_start(ap, fmt);
    vsprintf(buffer, fmt, ap);
    va_end(ap);  // look ma - I rememberd it this time
}

Printf::~Printf()
{
    delete [] buffer;
}


std::ostream &operator<<(std::ostream &o, const Printf &p)
{
    return o << p.buffer;
}