Nsound  0.9.4
StreamOperators.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: StreamOperators.h 879 2014-11-29 20:48:10Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2007 Nick Hilton
11 //
12 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 //-----------------------------------------------------------------------------
15 
16 //-----------------------------------------------------------------------------
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 //-----------------------------------------------------------------------------
33 
34 #ifndef _NSOUND_STREAM_OPERATORS_H_
35 #define _NSOUND_STREAM_OPERATORS_H_
36 
37 #include <Nsound/Nsound.h>
38 
39 #include <iostream>
40 
41 namespace Nsound
42 {
43 
44 // Read/write binary to/from streams.
45 
46 std::ostream & operator&(std::ostream & out, char value);
47 std::ostream & operator&(std::ostream & out, uint32 value);
48 std::ostream & operator&(std::ostream & out, uint64 value);
49 std::ostream & operator&(std::ostream & out, float32 value);
50 std::ostream & operator&(std::ostream & out, float64 value);
51 
52 std::istream & operator&(std::istream & out, char & value);
53 std::istream & operator&(std::istream & out, uint32 & value);
54 std::istream & operator&(std::istream & out, uint64 & value);
55 std::istream & operator&(std::istream & out, float32 & value);
56 std::istream & operator&(std::istream & out, float64 & value);
57 
58 template <class T>
59 T peek(std::istream & in)
60 {
61  T tmp = 0;
62 
63  std::streampos pos = in.tellg();
64 
65  in.read(static_cast<char *>(&tmp), sizeof(T));
66 
67  in.seekg(pos);
68 
69  return tmp;
70 }
71 
72 } // namespace
73 
74 // :mode=c++: jEdit modeline
75 #endif
unsigned int uint32
Definition: Nsound.h:153
double float64
Definition: Nsound.h:146
T peek(std::istream &in)
unsigned long long uint64
Definition: Nsound.h:154
float float32
Definition: Nsound.h:145
std::ostream & operator&(std::ostream &out, char value)