/[escript]/branches/arrexp_2137_win_merge/escript/src/DataVector.cpp
ViewVC logotype

Diff of /branches/arrexp_2137_win_merge/escript/src/DataVector.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 122 by jgs, Thu Jun 9 05:38:05 2005 UTC revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC
# Line 13  Line 13 
13  */  */
14    
15  #include <iostream>  #include <iostream>
16    #include <fstream>
17  #include <cassert>  #include <cassert>
18    
19  #include "escript/Data/DataVector.h"  #include "escript/Data/DataVector.h"
# Line 144  DataVector::operator!=(const DataVector& Line 145  DataVector::operator!=(const DataVector&
145    return !(*this==other);    return !(*this==other);
146  }  }
147    
148    int
149    DataVector::archiveData(ofstream& archiveFile,
150                            const size_type noValues) const
151    {
152      //
153      // Check number of values expected to be written matches number in this object
154      if (noValues != size()) {
155        return 2;
156      }
157    
158      //
159      // Write all values in this object out to archiveFile
160      for (int i=0; i<size(); i++) {
161        archiveFile.write(reinterpret_cast<char *>(&m_array_data[i]),sizeof(double));
162      }
163    
164      //
165      // Check no errors were encountered before returning
166      if (!archiveFile.good()) {
167        return 1;
168      }
169    
170      return 0;
171    }
172    
173    int
174    DataVector::extractData(ifstream& archiveFile,
175                            const size_type noValues)
176    {
177      //
178      // Check number of values expected to be read matches number in this object
179      if (noValues != size()) {
180        return 2;
181      }
182    
183      //
184      // Read all values in archiveFile back to this object
185      for (int i=0; i<size(); i++) {
186        archiveFile.read(reinterpret_cast<char *>(&m_array_data[i]),sizeof(double));
187      }
188    
189      //
190      // Check no errors were encountered before returning
191      if (!archiveFile.good()) {
192        return 1;
193      }
194    
195      return 0;
196    }
197    
198  } // end of namespace  } // end of namespace

Legend:
Removed from v.122  
changed lines
  Added in v.123

  ViewVC Help
Powered by ViewVC 1.1.26