Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 00006 #include "Coords.h" 00007 00008 #define MATCH(s, c) while ((s).get() != (c)) 00009 00010 /*************************************************************************/ 00011 /* Static empty coords */ 00012 /*************************************************************************/ 00013 class Coords Coords::_empty_coords; 00014 /*************************************************************************/ 00015 00016 /* 00017 ************************************************************************* 00018 * * 00019 * istream& operator >> (istream& s, Coords& c) * 00020 * * 00021 * Operator >> reads in Coords information in the form: * 00022 * * 00023 * (c(0),c(1), ... ,c(N)). * 00024 * * 00025 ************************************************************************* 00026 */ 00027 00028 istream& operator >> (istream& s, Coords& c) 00029 { 00030 MATCH(s, '('); s >> c(0); 00031 register int i; for (i=1;i<c.rank;i++) {MATCH(s, ','); s >> c(i);} 00032 MATCH(s, ')'); 00033 return(s); 00034 } 00035 00036 /* 00037 ************************************************************************* 00038 * * 00039 * ostream& operator << (ostream& s, const Coords& c) * 00040 * * 00041 * Operator << writes the point information in p in the form: * 00042 * * 00043 * (c(0),c(1), ..., c(N)). * 00044 * * 00045 ************************************************************************* 00046 */ 00047 00048 ostream& operator << (ostream& s, const Coords& c) 00049 { 00050 s << '(' << c(0); 00051 for (register int i=1;i<c.rank;i++) s << ',' << c(i); 00052 s << ')'; 00053 return(s); 00054 } 00055 00056 /* 00057 ************************************************************************* 00058 * * 00059 * ifstream& operator >> (ifstream& s, Coords& c) * 00060 * ofstream& operator << (ofstream& s, const Coords& c) * 00061 * * 00062 ************************************************************************* 00063 */ 00064 00065 ifstream& operator >> (ifstream& s, Coords& c) 00066 { 00067 if (&c == (Coords *)NULL) return s; 00068 00069 s.read((char*)&c,sizeof(Coords)); 00070 00071 return s; 00072 } 00073 00074 ofstream& operator << (ofstream& s, const Coords& c) 00075 { 00076 if (&c == (Coords *)NULL) return s; 00077 00078 s.write((char*)&c,sizeof(Coords)); 00079 00080 return s; 00081 }
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04