Changeset 1325 for trunk/src/core
- Timestamp:
- Mar 14, 2009, 4:20:03 PM (16 years ago)
- Location:
- trunk/src/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpDXWriter.cc
r1092 r1325 210 210 211 211 DXWriter& 212 DXWriter::write(FILE *stream) 213 { 214 SimpleCharBuffer *dxfile = NULL; 215 216 if (stream == NULL) { 217 fprintf(stderr,"stream is NULL, cannot write to NULL file inside DXWriter::write\n"); 218 return *this; 219 } 220 221 dxfile = new SimpleCharBuffer(); 222 212 DXWriter::write(FILE *f) 213 { 214 if (f == NULL) { 215 fprintf(stderr,"FILE is NULL, cannot write to NULL file inside DXWriter::write\n"); 216 return *this; 217 } 218 SimpleCharBuffer dxfile; 223 219 _writeDxToBuffer(dxfile); 224 fwrite((const void*)(dxfile->bytes()),1,dxfile->size(),stream); 225 226 delete dxfile; 227 220 ssize_t nWritten; 221 nWritten = fwrite(dxfile.bytes(), 1, dxfile.size(), f); 222 assert(nWritten == (ssize_t)dxfile.size()); 228 223 return *this; 229 224 } … … 249 244 DXWriter::write(char *str) 250 245 { 251 SimpleCharBuffer *dxfile = NULL; 252 int sz = 0; 253 254 dxfile = new SimpleCharBuffer(); 246 SimpleCharBuffer dxfile; 247 int sz; 255 248 256 249 _writeDxToBuffer(dxfile); 257 sz = dxfile ->size();250 sz = dxfile.size(); 258 251 str = new char[sz+1]; 259 memcpy(str, dxfile->bytes(),sz);252 memcpy(str, dxfile.bytes(), sz); 260 253 str[sz] = '\0'; 261 262 delete dxfile;263 264 254 return *this; 265 255 } … … 273 263 274 264 DXWriter& 275 DXWriter::_writeDxToBuffer(SimpleCharBuffer *dxfile)265 DXWriter::_writeDxToBuffer(SimpleCharBuffer &dxfile) 276 266 { 277 267 char b[80]; … … 281 271 // because we know there are at least 282 272 // 400 characters in even our smallest dx file. 283 dxfile ->set(512);284 285 dxfile ->append("<ODX>object 1 class gridpositions counts",40);273 dxfile.set(512); 274 275 dxfile.append("<ODX>object 1 class gridpositions counts",40); 286 276 for (size_t i=0; i < _rank; i++) { 287 277 sprintf(b, " %10lu", (unsigned long)_positions[i]); 288 dxfile ->append(b,11);289 } 290 291 dxfile ->append("\norigin");278 dxfile.append(b,11); 279 } 280 281 dxfile.append("\norigin"); 292 282 for (size_t i=0; i < _rank; i++) { 293 283 sprintf(b, " %10g",_origin[i]); 294 dxfile ->append(b,11);284 dxfile.append(b,11); 295 285 } 296 286 297 287 for (size_t row=0; row < _rank; row++) { 298 dxfile ->append("\ndelta");288 dxfile.append("\ndelta"); 299 289 for (size_t col=0; col < _rank; col++) { 300 290 sprintf(b, " %10g",_delta[(_rank*row)+col]); 301 dxfile ->append(b,11);291 dxfile.append(b,11); 302 292 } 303 293 } 304 294 305 dxfile ->append("\nobject 2 class gridconnections counts", 38);295 dxfile.append("\nobject 2 class gridconnections counts", 38); 306 296 for (size_t i=0; i < _rank; i++) { 307 297 sprintf(b, " %10lu",(unsigned long)_positions[i]); 308 dxfile ->append(b,11);309 } 310 311 dxfile ->append("\nattribute \"element type\" string \"cubes\"\n",41);312 dxfile ->append("attribute \"ref\" string \"positions\"\n",35);298 dxfile.append(b,11); 299 } 300 301 dxfile.append("\nattribute \"element type\" string \"cubes\"\n",41); 302 dxfile.append("attribute \"ref\" string \"positions\"\n",35); 313 303 314 304 sprintf(b,"object 3 class array type float rank 0 items %lu data follows\n", 315 305 (unsigned long)_dataBuf.nmemb()); 316 dxfile ->append(b);306 dxfile.append(b); 317 307 318 308 _dataBuf.seek(0,SEEK_SET); … … 327 317 // only that it has 10 sigdigs, so we cannot tell 328 318 // append the size of the data 329 // dxfile ->append(b,15);330 dxfile ->append(b);331 } 332 333 dxfile ->append("attribute \"dep\" string \"positions\"\n",35);334 dxfile ->append("object \"density\" class field\n",29);335 dxfile ->append("component \"positions\" value 1\n",30);336 dxfile ->append("component \"connections\" value 2\n",32);337 dxfile ->append("component \"data\" value 3\n",25);319 // dxfile.append(b,15); 320 dxfile.append(b); 321 } 322 323 dxfile.append("attribute \"dep\" string \"positions\"\n",35); 324 dxfile.append("object \"density\" class field\n",29); 325 dxfile.append("component \"positions\" value 1\n",30); 326 dxfile.append("component \"connections\" value 2\n",32); 327 dxfile.append("component \"data\" value 3\n",25); 338 328 339 329 return *this; -
trunk/src/core/RpDXWriter.h
r1109 r1325 1 1 2 /* 2 3 * ---------------------------------------------------------------------- … … 58 59 double* _origin; // array holding coord of origin 59 60 60 DXWriter& _writeDxToBuffer(SimpleCharBuffer *dxfile);61 DXWriter& _writeDxToBuffer(SimpleCharBuffer &dxfile); 61 62 }; 62 63 -
trunk/src/core/RpOutcome.cc
r1051 r1325 63 63 64 64 Outcome& 65 Outcome:: AddError(const char* format, ...)65 Outcome::addError(const char* format, ...) 66 66 { 67 67 char stackSpace[1024]; … … 138 138 * Query the error remark from an outcome. 139 139 */ 140 std::string 140 const char * 141 141 Outcome::remark() const 142 142 { 143 if (!_remarkPtr.isNull()) { 144 return _remarkPtr->data(); 145 } 146 return ""; 143 return (!_remarkPtr.isNull()) ? _remarkPtr->data() : ""; 147 144 } 148 145 … … 164 161 * Query the context stack from an outcome. 165 162 */ 166 std::string 163 164 const char * 167 165 Outcome::context() const 168 166 { 169 if (!_contextPtr.isNull()) { 170 return _contextPtr->data(); 171 } 172 return ""; 167 return (!_contextPtr.isNull()) ? _contextPtr->data() : ""; 173 168 } -
trunk/src/core/RpOutcome.h
r1023 r1325 31 31 virtual ~Outcome(); 32 32 33 Outcome& AddError(const char* format, ...);33 Outcome& addError(const char* format, ...); 34 34 virtual Outcome& error(const char* errmsg, int status=1); 35 35 virtual Outcome& clear(); … … 39 39 virtual Outcome& operator&=(Outcome status); // pass-by-value to avoid temp 40 40 41 virtual std::stringremark() const;41 virtual const char *remark() const; 42 42 virtual Outcome& addContext(const char *rem); 43 virtual std::stringcontext() const;43 virtual const char *context() const; 44 44 45 45 private:
Note: See TracChangeset
for help on using the changeset viewer.