CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 00023 #ifndef _ComplexTmplDef_ 00024 #define _ComplexTmplDef_ 00025 00026 // remove me 00027 #include <iostream> 00028 00029 namespace CLAM 00030 { 00031 00032 template <class T> 00033 inline std::istream& operator >> (std::istream & is, ComplexTmpl<T> & a) 00034 { 00035 if (is.flags() & std::ios::skipws) { 00036 char c = '\0'; 00037 do 00038 is.get(c); 00039 while (is && isspace(c)); 00040 if (is) is.putback(c); 00041 } 00042 char c = '\0'; 00043 is >> c; 00044 if (c!='{') { 00045 if (is) is.putback(c); 00046 // std::cerr << "A complex starting with '" << c << "'" << std::endl; 00047 return is; 00048 } 00049 T x; 00050 T y; 00051 if (!(is >> x)) return is; 00052 if (!(is >> y)) return is; 00053 if (is.flags() & std::ios::skipws) { 00054 char c = '\0'; 00055 do 00056 is.get(c); 00057 while (is && isspace(c)); 00058 if (is) is.putback(c); 00059 } 00060 if (!is.get(c) || c!='i') return is; 00061 if (is.flags() & std::ios::skipws) { 00062 char c = '\0'; 00063 do 00064 is.get(c); 00065 while (is && isspace(c)); 00066 if (is) is.putback(c); 00067 } 00068 if (!is.get(c) || c!='}') return is; 00069 00070 a.SetReal(x); 00071 a.SetImag(y); 00072 return is; 00073 } 00074 00075 template <class T> 00076 inline std::ostream& operator << (std::ostream & os, const ComplexTmpl<T> & a) 00077 { 00078 return os 00079 << "{" 00080 << a.Real() 00081 << " " 00082 << a.Imag() 00083 << "i}"; 00084 } 00085 00086 } // namespace CLAM 00087 00088 00089 #endif // _ComplexTmplDef_ 00090