Pointwise Plugin SDK
PwpFile.cxx
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * class PwpFile
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #include "PwpFile.h"
10 #include "PwpFileWriter.h"
11 #include "pwpPlatform.h"
12 
13 #include <cctype>
14 #include <cstring>
15 #include <cstdio>
16 #include <string>
17 
18 
19 // readOrdered(), writeOrdered() max number of swappable buffer bytes
20 enum {
21  ORDERED_MAXSIZE = 8
22 };
23 
24 
25 //***************************************************************************
26 //***************************************************************************
27 //***************************************************************************
28 
29 class PwpAsciiWriter : public PwpFileWriter {
30 public:
31 
33  PwpFileWriter(file)
34  {
35  }
36 
37 
38  virtual ~PwpAsciiWriter()
39  {
40  }
41 
42 
43  virtual bool write(PWP_INT64 val, const char *suffix = 0,
44  const char *prefix = 0)
45  {
46  return 0 <= fprintf(file_.fp(), "%s%" PWP_INT64_FORMAT "%s",
47  (prefix ? prefix : ""), val, (suffix ? suffix : ""));
48  }
49 
50 
51  virtual bool write(PWP_INT32 val, const char *suffix = 0,
52  const char *prefix = 0)
53  {
54  return 0 <= fprintf(file_.fp(), "%s%ld%s", (prefix ? prefix : ""),
55  (long)val, (suffix ? suffix : ""));
56  }
57 
58 
59  virtual bool write(PWP_INT16 val, const char *suffix = 0,
60  const char *prefix = 0)
61  {
62  return 0 <= fprintf(file_.fp(), "%s%ld%s", (prefix ? prefix : ""),
63  (long)val, (suffix ? suffix : ""));
64  }
65 
66 
67  virtual bool write(PWP_INT8 val, const char *suffix = 0,
68  const char *prefix = 0)
69  {
70  return 0 <= fprintf(file_.fp(), "%s%ld%s", (prefix ? prefix : ""),
71  (long)val, (suffix ? suffix : ""));
72  }
73 
74 
75  virtual bool write(PWP_UINT64 val, const char *suffix = 0,
76  const char *prefix = 0)
77  {
78  return 0 <= fprintf(file_.fp(), "%s%" PWP_UINT64_FORMAT "%s",
79  (prefix ? prefix : ""), val, (suffix ? suffix : ""));
80  }
81 
82 
83  virtual bool write(PWP_UINT32 val, const char *suffix = 0,
84  const char *prefix = 0)
85  {
86  return 0 <= fprintf(file_.fp(), "%s%lu%s", (prefix ? prefix : ""),
87  (unsigned long)val, (suffix ? suffix : ""));
88  }
89 
90 
91  virtual bool write(PWP_UINT16 val, const char *suffix = 0,
92  const char *prefix = 0)
93  {
94  return 0 <= fprintf(file_.fp(), "%s%lu%s", (prefix ? prefix : ""),
95  (unsigned long)val, (suffix ? suffix : ""));
96  }
97 
98 
99  virtual bool write(PWP_UINT8 val, const char *suffix = 0,
100  const char *prefix = 0)
101  {
102  return 0 <= fprintf(file_.fp(), "%s%lu%s", (prefix ? prefix : ""),
103  (unsigned long)val, (suffix ? suffix : ""));
104  }
105 
106 
107  virtual bool write(PWP_FLOAT val, const char *suffix = 0,
108  const char *prefix = 0)
109  {
110  return file_.isDouble() ?
112  (suffix ? suffix : ""), (prefix ? prefix : "")) :
114  (suffix ? suffix : ""), (prefix ? prefix : ""));
115  }
116 
117 
118  virtual bool write(PWP_REAL val, const char *suffix = 0,
119  const char *prefix = 0)
120  {
121  return file_.isSingle() ?
123  (suffix ? suffix : ""), (prefix ? prefix : "")) :
125  (suffix ? suffix : ""), (prefix ? prefix : ""));
126  }
127 
128 
129  virtual bool write(const char * val, PWP_INT size = -1, char /*pad*/ = 0)
130  {
131  if (-1 == size) {
132  size = (PWP_INT)strlen(val);
133  }
134  return 0 <= fprintf(file_.fp(), "%*.*s", (int)size, (int)size, val);
135  }
136 
137 
138 private:
139 
140  bool writeWdPrec(PWP_REAL val, int wd, int prec, const char *sfx,
141  const char *pfx)
142  {
143  switch (fmtType_) {
144  case FormatG:
145  return 0 <= fprintf(file_.fp(), "%s%g%s", pfx, val, sfx);
146  case FormatWdPrecG:
147  return 0 <= fprintf(file_.fp(), "%s%*.*g%s", pfx, wd, prec, val, sfx);
148  case FormatWdG:
149  return 0 <= fprintf(file_.fp(), "%s%*g%s", pfx, wd, val, sfx);
150  case FormatPrecG:
151  return 0 <= fprintf(file_.fp(), "%s%.*g%s", pfx, prec, val, sfx);
152 
153  case FormatF:
154  return 0 <= fprintf(file_.fp(), "%s%f%s", pfx, val, sfx);
155  case FormatWdPrecF:
156  return 0 <= fprintf(file_.fp(), "%s%*.*f%s", pfx, wd, prec, val, sfx);
157  case FormatWdF:
158  return 0 <= fprintf(file_.fp(), "%s%*f%s", pfx, wd, val, sfx);
159  case FormatPrecF:
160  return 0 <= fprintf(file_.fp(), "%s%.*f%s", pfx, prec, val, sfx);
161 
162  case FormatE:
163  return 0 <= fprintf(file_.fp(), "%s%e%s", pfx, val, sfx);
164  case FormatWdPrecE:
165  return 0 <= fprintf(file_.fp(), "%s%*.*e%s", pfx, wd, prec, val, sfx);
166  case FormatWdE:
167  return 0 <= fprintf(file_.fp(), "%s%*e%s", pfx, wd, val, sfx);
168  case FormatPrecE:
169  return 0 <= fprintf(file_.fp(), "%s%.*e%s", pfx, prec, val, sfx);
170  }
171  return false;
172  }
173 };
174 
175 
176 //***************************************************************************
177 //***************************************************************************
178 //***************************************************************************
179 
181 
182  template< typename T >
183  bool writeOrdered(T val) {
184  return writeOrdered(&val, sizeof(T));
185  }
186 
187 public:
188 
190  PwpFileWriter(file)
191  {
192  }
193 
194 
196  {
197  }
198 
199 
200  virtual bool write(PWP_INT64 val, const char *suffix = 0,
201  const char *prefix = 0)
202  {
203  (void)prefix, (void)suffix;
204  return writeOrdered(val);
205  }
206 
207 
208  virtual bool write(PWP_INT32 val, const char *suffix = 0,
209  const char *prefix = 0)
210  {
211  (void)prefix, (void)suffix;
212  return writeOrdered(val);
213  }
214 
215 
216  virtual bool write(PWP_INT16 val, const char *suffix = 0,
217  const char *prefix = 0)
218  {
219  (void)prefix, (void)suffix;
220  return writeOrdered(val);
221  }
222 
223 
224  virtual bool write(PWP_INT8 val, const char *suffix = 0,
225  const char *prefix = 0)
226  {
227  (void)prefix, (void)suffix;
228  return writeOrdered(val);
229  }
230 
231 
232  virtual bool write(PWP_UINT64 val, const char *suffix = 0,
233  const char *prefix = 0)
234  {
235  (void)prefix, (void)suffix;
236  return writeOrdered(val);
237  }
238 
239 
240  virtual bool write(PWP_UINT32 val, const char *suffix = 0,
241  const char *prefix = 0)
242  {
243  (void)prefix, (void)suffix;
244  return writeOrdered(val);
245  }
246 
247 
248  virtual bool write(PWP_UINT16 val, const char *suffix = 0,
249  const char *prefix = 0)
250  {
251  (void)prefix, (void)suffix;
252  return writeOrdered(val);
253  }
254 
255 
256  virtual bool write(PWP_UINT8 val, const char *suffix = 0,
257  const char *prefix = 0)
258  {
259  (void)prefix, (void)suffix;
260  return writeOrdered(val);
261  }
262 
263 
264  virtual bool write(PWP_FLOAT val, const char *suffix = 0,
265  const char *prefix = 0)
266  {
267  (void)prefix, (void)suffix;
268  if (file_.isDouble()) {
269  return writeOrdered((PWP_REAL)val);
270  }
271  return writeOrdered(val);
272  }
273 
274 
275  virtual bool write(PWP_REAL val, const char *suffix = 0,
276  const char *prefix = 0)
277  {
278  (void)prefix, (void)suffix;
279  if (file_.isSingle()) {
280  return writeOrdered((PWP_FLOAT)val);
281  }
282  return writeOrdered(val);
283  }
284 
285 
286  virtual bool write(const char * val, PWP_INT size = -1, char pad = 0)
287  {
288  bool ret = false;
289  if (0 != val) {
290  PWP_INT len = (PWP_INT)strlen(val);
291  if (-1 == size) {
292  size = len;
293  }
294  if (len >= size) {
295  // no padding needed
296  ret = (1 == pwpFileWrite(val, size, 1, file_.fp()));
297  }
298  else if (1 == pwpFileWrite(val, len, 1, file_.fp())) {
299  // str already written, now write pad chars
300  ret = true;
301  const size_t bufSz = 512;
302  char padBuf[bufSz] = { '\0' }; // compiler fills all with zeros
303  if (0 != pad) {
304  memset(padBuf, pad, bufSz);
305  }
306  size -= len; // reduce size by # chars already written
307  while (ret && (bufSz < size)) {
308  ret = (1 == pwpFileWrite(padBuf, bufSz, 1, file_.fp()));
309  size -= bufSz;
310  }
311  // write final partial buffer (size == 0 is okay)
312  ret = ret && (1 == pwpFileWrite(padBuf, size, 1, file_.fp()));
313  }
314  }
315  return ret;
316  }
317 
318 private:
319 
320  bool
321  writeOrdered(const void *buf, size_t size)
322  {
323  bool ret = false;
324  FILE *fp = file_.fp();
325  if (0 == buf) {
326  // bad
327  }
328  else if (1 == size) {
329  ret = (1 == pwpFileWrite(buf, size, 1, fp));
330  }
331  else if (!(size & 0x1) && (ORDERED_MAXSIZE >= size)) {
332  static unsigned char tmpBuf[ORDERED_MAXSIZE];
333  if (file_.needByteSwap()) {
334  const char *cbuf = (const char *)buf;
335  size_t hNdx = 0;
336  size_t tNdx = size - 1;
337  while (hNdx < tNdx) {
338  tmpBuf[hNdx] = cbuf[tNdx];
339  tmpBuf[tNdx--] = cbuf[hNdx++];
340  }
341  buf = tmpBuf; // write tmpBuf instead
342  }
343  ret = (1 == pwpFileWrite(buf, size, 1, fp));
344  }
345  return ret;
346  }
347 };
348 
349 
350 //***************************************************************************
351 //***************************************************************************
352 //***************************************************************************
353 
355 public:
356 
358  PwpFileWriter(file)
359  {
361  }
362 
363 
365  {
367  }
368 
369 
370  virtual bool beginRecord() {
371  endRecord();
373  return 0 != PwuUnfRecBegin(&file_.unfData());
374  }
375 
376 
377  virtual bool beginRecord(PWP_UINT32 bytes, PWP_UINT32 count = 1) {
378  endRecord();
380  return 0 != PwuUnfRecBeginFixed(&file_.unfData(), bytes, count);
381  }
382 
383 
384  virtual bool endRecord() {
385  return 0 != PwuUnfRecEnd(&file_.unfData());
386  }
387 
388 
389  virtual bool write(PWP_INT64 val, const char *suffix = 0,
390  const char *prefix = 0)
391  {
392  (void)prefix, (void)suffix;
393  return 0 != PwuUnfRecWriteINT64(&file_.unfData(), val);
394  }
395 
396 
397  virtual bool write(PWP_INT32 val, const char *suffix = 0,
398  const char *prefix = 0)
399  {
400  (void)prefix, (void)suffix;
401  return 0 != PwuUnfRecWriteINT32(&file_.unfData(), val);
402  }
403 
404 
405  virtual bool write(PWP_INT16 val, const char *suffix = 0,
406  const char *prefix = 0)
407  {
408  (void)prefix, (void)suffix;
409  return 0 != PwuUnfRecWriteINT16(&file_.unfData(), val);
410  }
411 
412 
413  virtual bool write(PWP_INT8 val, const char *suffix = 0,
414  const char *prefix = 0)
415  {
416  (void)prefix, (void)suffix;
417  return 0 != PwuUnfRecWriteINT8(&file_.unfData(), val);
418  }
419 
420 
421  virtual bool write(PWP_UINT64 val, const char *suffix = 0,
422  const char *prefix = 0)
423  {
424  (void)prefix, (void)suffix;
425  return 0 != PwuUnfRecWriteUINT64(&file_.unfData(), val);
426  }
427 
428 
429  virtual bool write(PWP_UINT32 val, const char *suffix = 0,
430  const char *prefix = 0)
431  {
432  (void)prefix, (void)suffix;
433  return 0 != PwuUnfRecWriteUINT32(&file_.unfData(), val);
434  }
435 
436 
437  virtual bool write(PWP_UINT16 val, const char *suffix = 0,
438  const char *prefix = 0)
439  {
440  (void)prefix, (void)suffix;
441  return 0 != PwuUnfRecWriteUINT16(&file_.unfData(), val);
442  }
443 
444 
445  virtual bool write(PWP_UINT8 val, const char *suffix = 0,
446  const char *prefix = 0)
447  {
448  (void)prefix, (void)suffix;
449  return 0 != PwuUnfRecWriteUINT8(&file_.unfData(), val);
450  }
451 
452 
453  virtual bool write(PWP_FLOAT val, const char *suffix = 0,
454  const char *prefix = 0)
455  {
456  (void)prefix, (void)suffix;
457  if (file_.isDouble()) {
458  return 0 != PwuUnfRecWriteREAL(&file_.unfData(), (PWP_REAL)val);
459  }
460  return 0 != PwuUnfRecWriteFLOAT(&file_.unfData(), val);
461  }
462 
463 
464  virtual bool write(PWP_REAL val, const char *suffix = 0,
465  const char *prefix = 0)
466  {
467  (void)prefix, (void)suffix;
468  if (file_.isSingle()) {
469  return 0 != PwuUnfRecWriteFLOAT(&file_.unfData(), (PWP_FLOAT)val);
470  }
471  return 0 != PwuUnfRecWriteREAL(&file_.unfData(), val);
472  }
473 
474 
475  virtual bool write(const char * val, PWP_INT size = -1, char pad = 0)
476  {
477  bool ret = false;
478  if (0 != val) {
479  PWP_INT len = (PWP_INT)strlen(val);
480  if (-1 == size) {
481  size = len;
482  }
483  if (len >= size) {
484  // no padding needed
485  ret = (0 != PwuUnfRecWriteBuf(&file_.unfData(), val, size));
486  }
487  else if (0 != PwuUnfRecWriteBuf(&file_.unfData(), val, len)) {
488  // str already written, now write pad chars
489  ret = true;
490  const size_t bufSz = 512;
491  char padBuf[bufSz] = { '\0' }; // compiler fills all with zeros
492  if (0 != pad) {
493  memset(padBuf, pad, bufSz);
494  }
495  size -= len; // reduce size by # chars already written
496  while (ret && (bufSz < size)) {
497  ret = (0 != PwuUnfRecWriteBuf(&file_.unfData(), padBuf,
498  bufSz));
499  size -= bufSz;
500  }
501  // write final partial buffer (size == 0 is okay)
502  ret = ret && (0 != PwuUnfRecWriteBuf(&file_.unfData(), padBuf,
503  size));
504  }
505  }
506  return ret;
507  }
508 };
509 
510 
511 //***************************************************************************
512 //***************************************************************************
513 //***************************************************************************
514 
515 PwpFile::PwpFile(FILE *fp, std::string filename, int mode) :
516  fp_(0),
517  mode_(0),
518  filename_(),
519  byteOrder_(PWP_ENDIAN_NATIVE),
520  precision_(PWP_PRECISION_DOUBLE),
521  ud_(),
522  writer_(0)
523 {
524  wrap(fp, filename, mode);
525 }
526 
527 
528 PwpFile::PwpFile(std::string filename, int mode) :
529  fp_(0),
530  mode_(0),
531  filename_(),
532  byteOrder_(PWP_ENDIAN_NATIVE),
533  precision_(PWP_PRECISION_DOUBLE),
534  ud_(),
535  writer_(0)
536 {
537  open(filename, mode);
538 }
539 
541  fp_(nullptr),
542  mode_(),
543  filename_(),
544  byteOrder_(ref.byteOrder_),
545  precision_(ref.precision_),
546  ud_(),
547  writer_(nullptr)
548 {
549  open(ref.filename_, ref.mode_);
550 }
551 
553 {
554  close();
555 }
556 
557 PwpFile&
559 {
560  open(ref.filename_, ref.mode_);
561  byteOrder_ = ref.byteOrder_;
562  precision_ = ref.precision_;
563  return *this;
564 }
565 
566 
567 bool
568 PwpFile::wrap(FILE *fp, std::string filename, int mode)
569 {
570  close();
571  fp_ = fp;
572  if (0 != fp_) {
573  filename_ = filename;
574  mode_ = mode;
575  if (isAscii()) {
576  writer_ = new PwpAsciiWriter(*this);
577  }
578  else if (isBinary()) {
579  writer_ = new PwpBinaryWriter(*this);
580  }
581  else if (isUnformatted()) {
582  writer_ = new PwpUnformattedWriter(*this);
583  }
584  if (0 == writer_) {
585  close(); // bad error
586  }
587  }
588  return 0 != fp_;
589 }
590 
591 
592 bool
593 PwpFile::open(std::string filename, int mode)
594 {
595  return wrap(pwpFileOpen(filename.c_str(), mode), filename, mode);
596 }
597 
598 
599 bool
601 {
602  return 0 != fp_;
603 }
604 
605 bool
607 {
608  return 0 != feof(fp_);
609 }
610 
611 
612 bool
614 {
615  // delete writer_ BEFORE closing file so dtor has a chance to use file.
616  delete writer_;
617  writer_ = 0;
618  bool ret = (0 == pwpFileClose(fp_));
619  fp_ = 0;
620  filename_.clear();
621  mode_ = 0;
622  return ret;
623 }
624 
625 
628 {
630  byteOrder_ = byteOrder;
631  return ret;
632 }
633 
634 
636 PwpFile::getByteOrder(bool mapBigLittle) const
637 {
638  return mapBigLittle ? mapToBigLittle(byteOrder_) : byteOrder_;
639 }
640 
641 
644 {
646  precision_ = precision;
647  return ret;
648 }
649 
650 
653 {
654  return precision_;
655 }
656 
657 
658 bool
660 {
661  return 0 != (mode_ & pwpRead);
662 }
663 
664 
665 bool
667 {
668  return 0 != (mode_ & pwpWrite);
669 }
670 
671 
672 bool
674 {
676 }
677 
678 
679 bool
681 {
683 }
684 
685 
686 bool
688 {
689  return 0 != (mode_ & (pwpAscii | pwpFormatted));
690 }
691 
692 bool
694 {
695  bool ret = false;
696  PwpFile local(*this);
697  PWP_UINT64 fileSize;
698  getSize(filename_.c_str(), fileSize);
699 
700  // Process chunks of data from file to determine ASCII-ness!
701  const size_t NumChunks = 4;
702  const size_t ChunkSize = 256;
703  const size_t FullBufSize = ChunkSize * NumChunks;
704  PWP_UINT8 buf[FullBufSize];
705  PWP_UINT n = 0;
706  if (FullBufSize >= fileSize) {
707  // Entire file fits in buf
708  n = pwpFileRead(buf, sizeof(PWP_UINT8), FullBufSize, local.fp_);
709  }
710  else {
711  // Get chunk 1 from start of file
712  n = pwpFileRead(buf, sizeof(PWP_UINT8), ChunkSize, local.fp_);
713  // Get chunks 2 ... NumChunks from file at equally spaced intervals
714  for (PWP_UINT chunk = 1; chunk < NumChunks; ++chunk) {
715  if (!local.setIntPos((chunk * fileSize) / NumChunks)) {
716  continue;
717  }
718  // Fill this chunk with chars from start of interval.
719  n += pwpFileRead(buf + n, sizeof(PWP_UINT8), ChunkSize, local.fp_);
720  }
721  }
722 
723  // Scan for number of non-ascii chars found in buf[]
724  PWP_UINT nNonAscii = 0;
725  for (PWP_UINT ii = 0; ii < n; ++ii) {
726  if ((0x80 <= buf[ii]) || (0x08 >= buf[ii])) {
727  ++nNonAscii;
728  }
729  }
730  ret = ((nNonAscii / (PWP_REAL)n) < 0.1);
731 
732  return ret;
733 }
734 
735 static bool
736 parseUnformattedRecord(PwpFile &theFile, PWP_INT64 &totalRecSize, bool &swap)
737 {
738  bool result = false;
739  PWP_UINT64 fileSize;
740  theFile.getSize(fileSize);
741 
742  totalRecSize = 0;
743  if (0 < fileSize) {
744  // It is valid for block length to be zero. So, there must be at
745  // least (header + footer) bytes remaining in file for a valid
746  // record to exist.
747  const PWP_INT64 HDRFTR_VALUE_SIZE = sizeof(PWP_INT32);
748  const PWP_INT64 MIN_RECORD_SIZE = 2 * HDRFTR_VALUE_SIZE;
749 
750  try {
751  // calc starting unconsumed file bytes
752  PWP_INT64 bytesRemaining = fileSize - theFile.getPos();
753  if (bytesRemaining >= MIN_RECORD_SIZE) {
754  // get record's data block size
755  PWP_INT32 blockSize = theFile.readSwap<PWP_INT32>(swap);
756  // verify there are enough bytes left in theFile for footer
757  // skip past data block to beginning of footer
758  // consume footer and verify the header/footer values match
759  bytesRemaining -= HDRFTR_VALUE_SIZE + blockSize;
760  if ((HDRFTR_VALUE_SIZE <= bytesRemaining) &&
761  theFile.setIntPos(theFile.getPos() + blockSize) &&
762  (blockSize == theFile.readSwap<PWP_INT32>(swap))) {
763  totalRecSize = HDRFTR_VALUE_SIZE + blockSize +
764  HDRFTR_VALUE_SIZE;
765  result = true;
766  }
767  }
768  }
769  catch (...) {
770  result = false;
771  }
772  }
773  return result;
774 }
775 
776 bool
777 PwpFile::checkUnformatted(bool &swapped, std::vector<PWP_INT64> *pRecSizes) const
778 {
779  bool result = false;
780  PwpFile local(*this);
781  if (pRecSizes) {
782  pRecSizes->clear();
783  }
784 
785  PWP_INT64 totalRecSize;
786  sysFILEPOS start;
787  local.getPos(start);
788  bool swap = true;
789 
790  if (!parseUnformattedRecord(local, totalRecSize, swap)) {
791  local.setPos(start);
792  // toggle swap bytes flag and try to read first record again
793  swap = !swap;
794  parseUnformattedRecord(local, totalRecSize, swap);
795  }
796  if (0 < totalRecSize) {
797  if (pRecSizes) {
798  pRecSizes->push_back(totalRecSize);
799  }
800  PWP_UINT64 fileSize;
801  local.getSize(fileSize);
802  PWP_INT64 bytesRemaining = fileSize - totalRecSize;
803  while (parseUnformattedRecord(local, totalRecSize, swap)) {
804  if (pRecSizes) {
805  pRecSizes->push_back(totalRecSize);
806  }
807  bytesRemaining -= totalRecSize;
808  }
809  result = (0 == bytesRemaining);
810  if (result) {
811  swapped = swap;
812  }
813  }
814 
815  local.setPos(start);
816 
817  return result;
818 }
819 
820 bool
822 {
823  return 0 != (mode_ & pwpBinary);
824 }
825 
826 
827 bool
829 {
830  return 0 != (mode_ & pwpUnformatted);
831 }
832 
833 
834 bool
836 {
837  return 0 != pwpFileEof(fp_);
838 }
839 
840 
841 bool
843 {
844  return 0 == pwpFileFlush(fp_);
845 }
846 
847 
848 bool
850 {
851  return 0 == pwpFileGetpos(fp_, &pos);
852 }
853 
854 PWP_INT64
856 {
857 #if !defined(linux)
858  fpos_t pos;
859  pwpFileGetpos(fp_, &pos);
860 #else
861  //linux fpos_t cannot be casted to long
862  PWP_INT64 pos;
863  pos = ::ftell(fp_);
864 #endif
865  return (PWP_INT64)pos;
866 }
867 
868 
869 bool
871 {
872 #if !defined(linux)
873  fpos_t pos = position;
874  return 0 == pwpFileSetpos(fp_, &pos);
875 #else
876  return (::fseek(fp_,position,SEEK_SET) == 0);
877 #endif
878 }
879 
880 bool
881 PwpFile::setPos(const sysFILEPOS &position)
882 {
883  return 0 == pwpFileSetpos(fp_, &position);
884 }
885 
886 bool
888 {
890  return 0 != fp_;
891 }
892 
893 
894 bool
896 {
897  size_t sz;
898  return (0 == pwpFileGetSize(fp_, &sz)) ?
899  ((size = (PWP_UINT64)sz), true) :
900  false;
901 }
902 
903 
904 bool
905 PwpFile::getSize(const char *filename, PWP_UINT64 &size)
906 {
907  size_t sz;
908  return (0 == pwpFilenameGetSize(filename, &sz)) ?
909  ((size = (PWP_UINT64)sz), true) :
910  false;
911 }
912 
913 
914 void
915 PwpFile::setName(std::string filename)
916 {
917  filename_ = filename;
918 }
919 
920 
921 const char *
923 {
924  return filename_.c_str();
925 }
926 
927 
928 bool
929 PwpFile::read(void *buf, size_t size, size_t count)
930 {
931  return count == pwpFileRead(buf, size, count, fp_);
932 }
933 
934 
935 bool
937 {
938  int c;
939  while (1) {
940  if (!getcNotEOF(c)) {
941  return false;
942  }
943  if (!std::isspace(c)) {
944  break;
945  }
946  }
947  // put back non-whitespace char
948  return ungetc(c);
949 }
950 
951 
952 bool
953 PwpFile::readToken(std::string &tok)
954 {
955  tok.clear();
956  if (wspaceSkip()) {
957  tok.reserve(DefReserve);
958  while (1) {
959  const int c = ::fgetc(fp_);
960  if (EOF == c) {
961  break;
962  }
963  if (!std::isspace(c)) {
964  tok += static_cast<char>(c);
965  continue;
966  }
967  // found trailing white space char, put it back and stop
968  ::ungetc(c, fp_);
969  break;
970  }
971  }
972  return !tok.empty();
973 }
974 
975 
976 bool
977 PwpFile::readAlphaToken(std::string &tok)
978 {
979  tok.clear();
980  if (wspaceSkip()) {
981  tok.reserve(DefReserve);
982  while (1) {
983  const int c = ::fgetc(fp_);
984  if (EOF == c) {
985  break;
986  }
987  if (std::isalpha(c)) {
988  tok += static_cast<char>(c);
989  continue;
990  }
991  // found non-alpha char put it back
992  ::ungetc(c, fp_);
993  break;
994  }
995  }
996  return !tok.empty();
997 }
998 
999 
1000 bool
1001 PwpFile::readUntil(std::string &str, const int stopC, int maxLen,
1002  const bool doTrim)
1003 {
1004  // If true, keep consuming chars until stopC is found even if str is "full".
1005  const bool FlushToStopC = (0 > maxLen);
1006  if (0 == maxLen) {
1007  maxLen = 2048; // sanity check
1008  }
1009  else if (FlushToStopC) {
1010  maxLen = -maxLen;
1011  }
1012 
1013  str.clear();
1014  str.reserve(DefReserve);
1015  int len = 0;
1016  int c = EOF;
1017  while (len < maxLen) {
1018  c = ::fgetc(fp_);
1019  // Check this first to support stopC == EOF
1020  if (stopC == c) {
1021  if (doTrim) {
1022  trim(str);
1023  }
1024  return true;
1025  }
1026  if (EOF == c) {
1027  break;
1028  }
1029  str += static_cast<char>(c);
1030  ++len;
1031  }
1032 
1033  if (FlushToStopC) {
1034  // Consume chars until stopC or EOF is found
1035  while (EOF != c) {
1036  c = ::fgetc(fp_);
1037  if (stopC == c) {
1038  if (doTrim) {
1039  trim(str);
1040  }
1041  return true;
1042  }
1043  }
1044  }
1045  return false;
1046 }
1047 
1048 
1049 bool
1051 {
1052  (void)base;
1053  while (cnt--) {
1054  if (1 != fscanf(*this, "%lf", v++)) {
1055  return false;
1056  }
1057  }
1058  return true;
1059 }
1060 
1061 
1062 bool
1064 {
1065  (void)base;
1066  while (cnt--) {
1067  if (1 != fscanf(*this, "%f", v++)) {
1068  return false;
1069  }
1070  }
1071  return true;
1072 }
1073 
1074 
1075 bool
1077 {
1078  (void)base;
1079  while (cnt--) {
1080  if (1 != fscanf(*this, "%u", (unsigned int*)v++)) {
1081  return false;
1082  }
1083  }
1084  return true;
1085 }
1086 
1087 
1088 bool
1089 PwpFile::readAscVal(char *v, PWP_UINT32 cnt, const PWP_UINT32 base)
1090 {
1091  (void)base;
1092  while (cnt--) {
1093  if (1 != fscanf(*this, "%c", v++)) {
1094  return false;
1095  }
1096  }
1097  return true;
1098 }
1099 
1100 bool
1102  PWP_UINT32 maxDigits)
1103 {
1104  if (0 == maxDigits) {
1105  maxDigits = PWP_UINT32_MAX;
1106  }
1107  std::string tok;
1108  if (wspaceSkip()) {
1109  tok.reserve(DefReserve);
1110  while (0 != maxDigits) {
1111  const int c = ::fgetc(fp_);
1112  if (EOF == c) {
1113  return !tok.empty();
1114  }
1115  if (10 == base) {
1116  if (std::isdigit(c)) {
1117  tok += static_cast<char>(c);
1118  --maxDigits;
1119  continue;
1120  }
1121  }
1122  else if (16 == base) {
1123  if (std::isxdigit(c)) {
1124  tok += static_cast<char>(c);
1125  --maxDigits;
1126  continue;
1127  }
1128  }
1129  else if (8 == base) {
1130  if ((c >= '0') && (c <= '7')) {
1131  tok += static_cast<char>(c);
1132  --maxDigits;
1133  continue;
1134  }
1135  }
1136  else if (!std::isspace(c)) {
1137  // other base - this is not complete
1138  tok += static_cast<char>(c);
1139  --maxDigits;
1140  continue;
1141  }
1142  // found non-int char put it back
1143  ::ungetc(c, fp_);
1144  break;
1145  }
1146  }
1147  return tok.empty() ? false :
1148  ((val = std::stoul(tok.c_str(), 0, int(base))), true);
1149 }
1150 
1151 
1152 bool
1154  const PWP_UINT32 base, PWP_UINT32 maxDigits)
1155 {
1156  return PwpFile::readInt(v, base, maxDigits) ? true : ((v = defV), false);
1157 }
1158 
1159 
1160 bool
1162 {
1163  //char *endPtr;
1164  //val = std::strtod(toks.at(0).c_str(), &endPtr);
1165  //return ret;
1166  if (0 == maxDigits) {
1167  maxDigits = PWP_UINT32_MAX;
1168  }
1169  std::string tok;
1170  if (wspaceSkip()) {
1171  tok.reserve(DefReserve);
1172  while (1) {
1173  const int c = ::fgetc(fp_);
1174  if (EOF == c) {
1175  return false;
1176  }
1177  if (std::isdigit(c)) {
1178  tok += static_cast<char>(c);
1179  continue;
1180  }
1181  // found non-alpha char put it back
1182  ::ungetc(c, fp_);
1183  break;
1184  }
1185  }
1186  return tok.empty() ? false :
1187  ((val = std::stoul(tok.c_str(), 0, 10)), true);
1188 }
1189 
1190 bool
1191 PwpFile::unlink(const char *filename)
1192 {
1193  return 0 == pwpFileDelete(filename);
1194 }
1195 
1196 
1199 {
1201 }
1202 
1203 
1206 {
1207  PWP_ENDIANNESS ret = byteOrder;
1208  switch (byteOrder) {
1209  case PWP_ENDIAN_NATIVE:
1210  ret = getOsByteOrder();
1211  break;
1212  case PWP_ENDIAN_FOREIGN:
1214  PWP_ENDIAN_BIG);
1215  break;
1216  case PWP_ENDIAN_BIG:
1217  case PWP_ENDIAN_LITTLE:
1218  break; // already set above
1219  default:
1220  ret = PWP_ENDIAN_ERROR;
1221  break;
1222  }
1223  return ret;
1224 }
1225 
1226 
1227 bool
1229 {
1230  return getOsByteOrder() != mapToBigLittle(byteOrder);
1231 }
1232 
1233 
1234 bool
1236  return writer_ && writer_->beginRecord();
1237 }
1238 
1239 
1240 bool
1242  return writer_ && writer_->beginRecord(bytes, count);
1243 }
1244 
1245 
1246 bool
1248  return writer_ && writer_->endRecord();
1249 }
1250 
1251 
1252 bool
1253 PwpFile::write(PWP_INT64 val, const char *suffix, const char *prefix)
1254 {
1255  return writer_ && writer_->write(val, suffix, prefix);
1256 }
1257 
1258 
1259 bool
1260 PwpFile::write(PWP_INT32 val, const char *suffix, const char *prefix)
1261 {
1262  return writer_ && writer_->write(val, suffix, prefix);
1263 }
1264 
1265 
1266 bool
1267 PwpFile::write(PWP_INT16 val, const char *suffix, const char *prefix)
1268 {
1269  return writer_ && writer_->write(val, suffix, prefix);
1270 }
1271 
1272 
1273 bool
1274 PwpFile::write(PWP_INT8 val, const char *suffix, const char *prefix)
1275 {
1276  return writer_ && writer_->write(val, suffix, prefix);
1277 }
1278 
1279 
1280 bool
1281 PwpFile::write(PWP_UINT64 val, const char *suffix, const char *prefix)
1282 {
1283  return writer_ && writer_->write(val, suffix, prefix);
1284 }
1285 
1286 
1287 bool
1288 PwpFile::write(PWP_UINT32 val, const char *suffix, const char *prefix)
1289 {
1290  return writer_ && writer_->write(val, suffix, prefix);
1291 }
1292 
1293 
1294 bool
1295 PwpFile::write(PWP_UINT16 val, const char *suffix, const char *prefix)
1296 {
1297  return writer_ && writer_->write(val, suffix, prefix);
1298 }
1299 
1300 
1301 bool
1302 PwpFile::write(PWP_UINT8 val, const char *suffix, const char *prefix)
1303 {
1304  return writer_ && writer_->write(val, suffix, prefix);
1305 }
1306 
1307 
1308 bool
1309 PwpFile::write(PWP_FLOAT val, const char *suffix, const char *prefix)
1310 {
1311  return writer_ && writer_->write(val, suffix, prefix);
1312 }
1313 
1314 
1315 bool
1316 PwpFile::write(PWP_REAL val, const char *suffix, const char *prefix)
1317 {
1318  return writer_ && writer_->write(val, suffix, prefix);
1319 }
1320 
1321 
1322 void
1323 PwpFile::setFmtFieldSingle(const int width, const int prec)
1324 {
1325  if (0 != writer_) {
1326  writer_->setFmtFieldSingle(width, prec);
1327  }
1328 }
1329 
1330 
1331 void
1332 PwpFile::getFmtFieldSingle(int &width, int &prec) const
1333 {
1334  if (0 != writer_) {
1335  writer_->getFmtFieldSingle(width, prec);
1336  }
1337 }
1338 
1339 
1340 void
1341 PwpFile::setFmtFieldDouble(const int width, const int prec)
1342 {
1343  if (0 != writer_) {
1344  writer_->setFmtFieldDouble(width, prec);
1345  }
1346 }
1347 
1348 
1349 void
1350 PwpFile::getFmtFieldDouble(int &width, int &prec) const
1351 {
1352  if (0 != writer_) {
1353  writer_->getFmtFieldDouble(width, prec);
1354  }
1355 }
1356 
1357 
1358 
1359 void
1361 {
1362  if (0 != writer_) {
1363  writer_->setFmtType(type);
1364  }
1365 }
1366 
1367 
1370 {
1372 }
1373 
1374 
1375 bool
1376 PwpFile::write(const char * val, PWP_INT size, char pad)
1377 {
1378  return writer_ && writer_->write(val, size, pad);
1379 }
1380 
1381 
1382 //***************************************************************************
1383 //***************************************************************************
1384 //***************************************************************************
1385 
1386 PwpFileRecord::PwpFileRecord(PwpFile &file, bool doBeginRecord) :
1387  file_(file)
1388 {
1389  if (doBeginRecord) {
1390  beginRecord();
1391  }
1392 }
1393 
1394 
1396  file_(file)
1397 {
1398  beginRecord(bytes, count);
1399 }
1400 
1401 
1403 {
1404  if (file_.isOpen()) {
1405  endRecord();
1406  }
1407 }
1408 
1409 
1410 bool
1412  return file_.beginRecord();
1413 }
1414 
1415 
1416 bool
1418  return file_.beginRecord(bytes, count);
1419 }
1420 
1421 
1422 bool
1424  return file_.endRecord();
1425 }
1426 
1427 
1428 bool
1429 PwpFileRecord::write(PWP_INT64 val, const char *suffix,
1430  const char *prefix)
1431 {
1432  return file_.write(val, suffix, prefix);
1433 }
1434 
1435 
1436 bool
1437 PwpFileRecord::write(PWP_INT32 val, const char *suffix,
1438  const char *prefix)
1439 {
1440  return file_.write(val, suffix, prefix);
1441 }
1442 
1443 
1444 bool
1445 PwpFileRecord::write(PWP_INT16 val, const char *suffix,
1446  const char *prefix)
1447 {
1448  return file_.write(val, suffix, prefix);
1449 }
1450 
1451 
1452 bool
1453 PwpFileRecord::write(PWP_INT8 val, const char *suffix,
1454  const char *prefix)
1455 {
1456  return file_.write(val, suffix, prefix);
1457 }
1458 
1459 
1460 bool
1461 PwpFileRecord::write(PWP_UINT64 val, const char *suffix,
1462  const char *prefix)
1463 {
1464  return file_.write(val, suffix, prefix);
1465 }
1466 
1467 
1468 bool
1469 PwpFileRecord::write(PWP_UINT32 val, const char *suffix,
1470  const char *prefix)
1471 {
1472  return file_.write(val, suffix, prefix);
1473 }
1474 
1475 
1476 bool
1477 PwpFileRecord::write(PWP_UINT16 val, const char *suffix,
1478  const char *prefix)
1479 {
1480  return file_.write(val, suffix, prefix);
1481 }
1482 
1483 
1484 bool
1485 PwpFileRecord::write(PWP_UINT8 val, const char *suffix,
1486  const char *prefix)
1487 {
1488  return file_.write(val, suffix, prefix);
1489 }
1490 
1491 
1492 bool
1493 PwpFileRecord::write(PWP_FLOAT val, const char *suffix,
1494  const char *prefix)
1495 {
1496  return file_.write(val, suffix, prefix);
1497 }
1498 
1499 
1500 bool
1501 PwpFileRecord::write(PWP_REAL val, const char *suffix,
1502  const char *prefix)
1503 {
1504  return file_.write(val, suffix, prefix);
1505 }
1506 
1507 
1508 void
1509 PwpFileRecord::setFmtFieldSingle(const int width, const int prec)
1510 {
1511  file_.setFmtFieldSingle(width, prec);
1512 }
1513 
1514 
1515 void
1516 PwpFileRecord::getFmtFieldSingle(int &width, int &prec) const
1517 {
1518  file_.getFmtFieldSingle(width, prec);
1519 }
1520 
1521 
1522 void
1523 PwpFileRecord::setFmtFieldDouble(const int width, const int prec)
1524 {
1525  file_.setFmtFieldDouble(width, prec);
1526 }
1527 
1528 
1529 void
1530 PwpFileRecord::getFmtFieldDouble(int &width, int &prec) const
1531 {
1532  file_.getFmtFieldDouble(width, prec);
1533 }
1534 
1535 
1536 
1537 void
1539 {
1540  file_.setFmtType(type);
1541 }
1542 
1543 
1546 {
1547  return file_.getFmtType();
1548 }
1549 
1550 
1551 bool
1552 PwpFileRecord::write(const char * val, PWP_INT size, char pad)
1553 {
1554  return file_.write(val, size, pad);
1555 }
PwpAsciiWriter::PwpAsciiWriter
PwpAsciiWriter(PwpFile &file)
Definition: PwpFile.cxx:32
PwpFile::setIntPos
bool setIntPos(const PWP_INT64 &pos)
Set the current file position.
Definition: PwpFile.cxx:870
PwpFile::setPos
bool setPos(const sysFILEPOS &pos)
Set the current file position.
Definition: PwpFile.cxx:881
PwpFile::readUntil
bool readUntil(std::string &str, const int stopC, int maxLen=0, const bool doTrim=false)
Reads up to maxLen chars until the specified stop char is encountered.
Definition: PwpFile.cxx:1001
PwpBinaryWriter::write
virtual bool write(const char *val, PWP_INT size=-1, char pad=0)
Writes a string value.
Definition: PwpFile.cxx:286
PwpAsciiWriter::write
virtual bool write(PWP_INT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:51
PwpBinaryWriter::writeOrdered
bool writeOrdered(T val)
Definition: PwpFile.cxx:183
PwpWriterInterface::FormatWdPrecF
@ FormatWdPrecF
Format "%*.*f".
Definition: PwpFileWriter.h:293
PwuUnfRecWriteUINT8
PWP_BOOL PwuUnfRecWriteUINT8(PWU_UNFDATA *pUData, PWP_UINT8 val)
Write a PWP_UINT8 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:531
PwpFileWriter::endRecord
virtual bool endRecord()
NOP default implementation.
Definition: PwpFileWriter.h:456
pwpBinary
@ pwpBinary
Definition: pwpPlatform.h:89
PwpAsciiWriter::write
virtual bool write(PWP_REAL val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:118
PwpUnformattedWriter::write
virtual bool write(PWP_UINT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:421
PwpFile::readToken
bool readToken(std::string &tok)
Reads a whitespace delimited token (word).
Definition: PwpFile.cxx:953
PwpFileRecord::getFmtFieldSingle
virtual void getFmtFieldSingle(int &width, int &prec) const
Definition: PwpFile.cxx:1516
PwpFile::isEof
bool isEof() const
Get the end-of-file status.
Definition: PwpFile.cxx:835
PwuUnfRecWriteINT8
PWP_BOOL PwuUnfRecWriteINT8(PWU_UNFDATA *pUData, PWP_INT8 val)
Write a PWP_INT8 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:524
sysFILEPOS
fpos_t sysFILEPOS
File position data type.
Definition: pwpPlatform.h:51
PwpFileRecord::endRecord
virtual bool endRecord()
Ends an unformatted record.
Definition: PwpFile.cxx:1423
PwpBinaryWriter::write
virtual bool write(PWP_INT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:208
PwpFile::~PwpFile
virtual ~PwpFile()
Destructor.
Definition: PwpFile.cxx:552
PWP_UINT64_FORMAT
#define PWP_UINT64_FORMAT
PWP_UINT64 printf format flags.
Definition: apiPWP.h:249
PWP_UINT32_MAX
#define PWP_UINT32_MAX
maximum valid PWP_UINT32 value
Definition: apiPWP.h:213
PwpFileWriter::getFmtFieldDouble
virtual void getFmtFieldDouble(int &width, int &prec) const
default implementation.
Definition: PwpFileWriter.h:420
PwpFile::isWritable
bool isWritable() const
Determines if file supports write operations.
Definition: PwpFile.cxx:666
PWP_PRECISION_DOUBLE
@ PWP_PRECISION_DOUBLE
Definition: apiPWP.h:804
PwpBinaryWriter::~PwpBinaryWriter
virtual ~PwpBinaryWriter()
Definition: PwpFile.cxx:195
PwpFile::setFmtFieldSingle
virtual void setFmtFieldSingle(const int width, const int prec)
Definition: PwpFile.cxx:1323
PwpFile::byteOrder_
PWP_ENDIANNESS byteOrder_
The file's byte order.
Definition: PwpFile.h:860
PwpFile::isOpen
bool isOpen() const
Determines a file's status.
Definition: PwpFile.cxx:600
PwpFile::readOptionalInt
bool readOptionalInt(PWP_UINT32 &v, const PWP_UINT32 defV, const PWP_UINT32 base=10, PWP_UINT32 maxDigits=0)
Reads a single PWP_UINT32 value.
Definition: PwpFile.cxx:1153
PwpFile::fileEof
bool fileEof() const
Check for the end of file.
Definition: PwpFile.cxx:606
PwpFile::getOsByteOrder
static PWP_ENDIANNESS getOsByteOrder()
Get the OS's native byte ordering.
Definition: PwpFile.cxx:1198
PwpFileRecord::beginRecord
virtual bool beginRecord()
Starts an unformatted record.
Definition: PwpFile.cxx:1411
PwpBinaryWriter::write
virtual bool write(PWP_UINT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:240
PwpUnformattedWriter::write
virtual bool write(PWP_INT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:405
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
pwpFileEof
int pwpFileEof(FILE *fp)
Queries end-of-file status.
Definition: pwpPlatform.cxx:296
PwpFileRecord::PwpFileRecord
PwpFileRecord(PwpFile &file, bool doBeginRecord=true)
Constructor.
Definition: PwpFile.cxx:1386
PwpBinaryWriter
Definition: PwpFile.cxx:180
pwpFileClose
int pwpFileClose(FILE *fp)
Closes a file opened with pwpFileOpen().
Definition: pwpPlatform.cxx:285
PwpFile::trim
static std::string & trim(std::string &s)
trim leading and trailing whitespace from s
Definition: PwpFile.h:759
PwuUnfRecWriteINT64
PWP_BOOL PwuUnfRecWriteINT64(PWU_UNFDATA *pUData, PWP_INT64 val)
Write a PWP_INT64 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:566
PwpBinaryWriter::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:200
PwpFileWriter::fmtFieldWdSingle_
int fmtFieldWdSingle_
Single precision format field width.
Definition: PwpFileWriter.h:470
PWP_ENDIAN_BIG
@ PWP_ENDIAN_BIG
Definition: apiPWP.h:827
PWP_UINT16
unsigned short PWP_UINT16
16-bit unsigned integer
Definition: apiPWP.h:190
PwpFile::getName
const char * getName() const
Get the file's associated filename.
Definition: PwpFile.cxx:922
PWP_INT16
short PWP_INT16
16-bit integer
Definition: apiPWP.h:187
PWP_INT32
int PWP_INT32
32-bit integer
Definition: apiPWP.h:207
pwpUnformatted
@ pwpUnformatted
Definition: pwpPlatform.h:93
PwpFile::getFmtFieldDouble
virtual void getFmtFieldDouble(int &width, int &prec) const
Definition: PwpFile.cxx:1350
PwpFile::read
bool read(void *buf, size_t size, size_t count)
Read a collection of data items.
Definition: PwpFile.cxx:929
pwpFileOpen
FILE * pwpFileOpen(const char *filename, int mode)
Opens a file for I/O.
Definition: pwpPlatform.cxx:230
PwpFileWriter::beginRecord
virtual bool beginRecord()
NOP default implementation.
Definition: PwpFileWriter.h:448
PwpWriterInterface::FormatWdPrecG
@ FormatWdPrecG
Format "%*.*g".
Definition: PwpFileWriter.h:288
pwpFileRead
size_t pwpFileRead(void *buf, size_t size, size_t count, FILE *fp)
Read an collection of data items from a file.
Definition: pwpPlatform.cxx:391
PwpFile::getPrecision
PWP_ENUM_PRECISION getPrecision() const
Get the floating point precision used for writes.
Definition: PwpFile.cxx:652
PwpFile::needByteSwap
bool needByteSwap() const
Determine if byte swapping is needed for this file.
Definition: PwpFile.h:793
PWP_UINT
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
PwpUnformattedWriter::write
virtual bool write(const char *val, PWP_INT size=-1, char pad=0)
Writes a string value.
Definition: PwpFile.cxx:475
PwpAsciiWriter::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:43
PwuGetOsEndianness
PWP_ENDIANNESS PwuGetOsEndianness(void)
Query the OS's native endianness.
Definition: apiPWPUtils.cxx:218
PwuUnfRecBegin
PWP_BOOL PwuUnfRecBegin(PWU_UNFDATA *pUData)
Prepares a PWU_UNFDATA block for writing a new unformatted data record.
Definition: apiPWPUtils.cxx:428
PwpFileRecord::getFmtFieldDouble
virtual void getFmtFieldDouble(int &width, int &prec) const
Definition: PwpFile.cxx:1530
PwpFile::isUnformatted
bool isUnformatted() const
Determines if file was opened with pwpUnformatted mode flag.
Definition: PwpFile.cxx:828
PwpFile::getPos
bool getPos(sysFILEPOS &pos) const
Get the current file position.
Definition: PwpFile.cxx:849
PwpFile::readSwap
bool readSwap(T &val, const bool swapbyte)
Reads a single value of type T.
Definition: PwpFile.h:502
PwpWriterInterface::FormatWdF
@ FormatWdF
Format "%*f".
Definition: PwpFileWriter.h:294
PwuUnfFileEnd
PWP_BOOL PwuUnfFileEnd(PWU_UNFDATA *pUData)
Finalize an unformatted file I/O session.
Definition: apiPWPUtils.cxx:594
PwpFile::isReadable
bool isReadable() const
Determines if file supports read operations.
Definition: PwpFile.cxx:659
PwpFile::swap
static void swap(T &val)
swap() - (Importer-only function) Wrapper for function swapByteOrder().
Definition: PwpFile.h:602
PwuUnfFileSetEndianness
PWP_ENDIANNESS PwuUnfFileSetEndianness(PWU_UNFDATA *pUData, PWP_ENDIANNESS endianness)
Set the output endianness.
Definition: apiPWPUtils.cxx:340
pwpFileSetpos
int pwpFileSetpos(FILE *fp, const sysFILEPOS *pos)
Set the current file position.
Definition: pwpPlatform.cxx:321
pwpAscii
@ pwpAscii
Definition: pwpPlatform.h:95
PwpFileRecord::setFmtFieldSingle
virtual void setFmtFieldSingle(const int width, const int prec)
Definition: PwpFile.cxx:1509
PwpFile::ungetc
bool ungetc(const int c)
Return a byte value to the file.
Definition: PwpFile.h:654
PwpFile::checkUnformatted
bool checkUnformatted(bool &swapped, std::vector< PWP_INT64 > *pRecSizes=0) const
Determines unformatted type settings by reading the contents of the file.
Definition: PwpFile.cxx:777
PwpFileRecord::setFmtType
virtual void setFmtType(FormatType type)
Definition: PwpFile.cxx:1538
PwpFile::fp
FILE * fp() const
Get the FILE pointer.
Definition: PwpFile.h:767
PwpBinaryWriter::write
virtual bool write(PWP_FLOAT val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:264
PwpFile::DefReserve
@ DefReserve
Definition: PwpFile.h:112
PwuUnfRecWriteBuf
PWP_BOOL PwuUnfRecWriteBuf(PWU_UNFDATA *pUData, const void *buf, size_t size)
Write a data buffer to the current record.
Definition: apiPWPUtils.cxx:495
PwuUnfRecWriteREAL
PWP_BOOL PwuUnfRecWriteREAL(PWU_UNFDATA *pUData, PWP_REAL val)
Write a PWP_REAL value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:587
PwpFile::wrap
bool wrap(FILE *fp, std::string filename=std::string(), int mode=0)
Take ownership of fp opened using pwpFileOpen(filename, mode).
Definition: PwpFile.cxx:568
PwpFileWriter::file_
PwpFile & file_
The file being written.
Definition: PwpFileWriter.h:474
parseUnformattedRecord
static bool parseUnformattedRecord(PwpFile &theFile, PWP_INT64 &totalRecSize, bool &swap)
Definition: PwpFile.cxx:736
PwpFile::readAlphaToken
bool readAlphaToken(std::string &tok)
Reads a whitespace delimited token (word).
Definition: PwpFile.cxx:977
PwpFile::fp_
FILE * fp_
The FILE pointer.
Definition: PwpFile.h:857
PwuUnfRecEnd
PWP_BOOL PwuUnfRecEnd(PWU_UNFDATA *pUData)
Finalize the current record write.
Definition: apiPWPUtils.cxx:371
PwpFile::setFmtFieldDouble
virtual void setFmtFieldDouble(const int width, const int prec)
Definition: PwpFile.cxx:1341
PwpUnformattedWriter
Definition: PwpFile.cxx:354
pwpFileGetpos
int pwpFileGetpos(FILE *fp, sysFILEPOS *pos)
Query the current file position.
Definition: pwpPlatform.cxx:310
PwpFileWriter::setFmtFieldDouble
virtual void setFmtFieldDouble(const int width, const int prec)
default implementation.
Definition: PwpFileWriter.h:416
PwpAsciiWriter::write
virtual bool write(PWP_INT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:67
PwpFileRecord::~PwpFileRecord
virtual ~PwpFileRecord()
Destructor.
Definition: PwpFile.cxx:1402
pwpPlatform.h
Cross Platform Functions.
PwpAsciiWriter::~PwpAsciiWriter
virtual ~PwpAsciiWriter()
Definition: PwpFile.cxx:38
PwpFileRecord::getFmtType
virtual FormatType getFmtType() const
Definition: PwpFile.cxx:1545
PWP_REAL
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
PwuUnfRecWriteINT16
PWP_BOOL PwuUnfRecWriteINT16(PWU_UNFDATA *pUData, PWP_INT16 val)
Write a PWP_INT16 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:538
PwpAsciiWriter::write
virtual bool write(PWP_FLOAT val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:107
PwpFileWriter::getFmtType
virtual FormatType getFmtType() const
default implementation.
Definition: PwpFileWriter.h:438
PwpAsciiWriter
Definition: PwpFile.cxx:29
PwpFile::readAscVal
bool readAscVal(PWP_REAL *v, PWP_UINT32 cnt, const PWP_UINT32 base=10)
Reads an array of cnt PWP_REAL values from an ascii file.
Definition: PwpFile.cxx:1050
PwpFile::setName
void setName(std::string filename)
Set the file's associated filename.
Definition: PwpFile.cxx:915
PwpUnformattedWriter::beginRecord
virtual bool beginRecord(PWP_UINT32 bytes, PWP_UINT32 count=1)
NOP default implementation.
Definition: PwpFile.cxx:377
PwpAsciiWriter::write
virtual bool write(PWP_UINT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:83
pwpFileRewind
void pwpFileRewind(FILE *fp)
Reset position to the beginning of the file.
Definition: pwpPlatform.cxx:420
PwpFile::mode_
int mode_
The mode.
Definition: PwpFile.h:858
PwpWriterInterface::FormatG
@ FormatG
Format "%g".
Definition: PwpFileWriter.h:287
pwpFileFlush
int pwpFileFlush(FILE *fp)
Flush a file to disk.
Definition: pwpPlatform.cxx:303
pwpWrite
@ pwpWrite
Definition: pwpPlatform.h:77
PwpWriterInterface::FormatWdE
@ FormatWdE
Format "%*e".
Definition: PwpFileWriter.h:299
PwpFile::wspaceSkip
bool wspaceSkip()
Reads and discards consecutive whitespace bytes.
Definition: PwpFile.cxx:936
PwpBinaryWriter::write
virtual bool write(PWP_REAL val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:275
PwpFileWriter::fmtFieldWdDouble_
int fmtFieldWdDouble_
Double precision format field width.
Definition: PwpFileWriter.h:472
PwpFile::writer_
PwpFileWriter * writer_
The file writer implementation.
Definition: PwpFile.h:863
PwpFile::PwpFile
PwpFile(FILE *fp=0, std::string filename=std::string(), int mode=0)
Default constructor.
Definition: PwpFile.cxx:515
PwpBinaryWriter::writeOrdered
bool writeOrdered(const void *buf, size_t size)
Definition: PwpFile.cxx:321
PWP_INT64_FORMAT
#define PWP_INT64_FORMAT
PWP_INT64 printf format flags.
Definition: apiPWP.h:246
PwpWriterInterface::FormatPrecG
@ FormatPrecG
Format "%.*g".
Definition: PwpFileWriter.h:290
PwpWriterInterface::FormatPrecE
@ FormatPrecE
Format "%.*e".
Definition: PwpFileWriter.h:300
PwpWriterInterface::FormatF
@ FormatF
Format "%f".
Definition: PwpFileWriter.h:292
PwpWriterInterface::FormatWdPrecE
@ FormatWdPrecE
Format "%*.*e".
Definition: PwpFileWriter.h:298
PWP_ENDIAN_LITTLE
@ PWP_ENDIAN_LITTLE
Definition: apiPWP.h:826
PWP_ENDIAN_ERROR
@ PWP_ENDIAN_ERROR
Definition: apiPWP.h:823
PWP_FLOAT
float PWP_FLOAT
32-bit real
Definition: apiPWP.h:261
PwpAsciiWriter::write
virtual bool write(const char *val, PWP_INT size=-1, char=0)
Writes a string value.
Definition: PwpFile.cxx:129
PWP_ENDIAN_NATIVE
@ PWP_ENDIAN_NATIVE
Definition: apiPWP.h:824
PWP_INT8
signed char PWP_INT8
8-bit integer
Definition: apiPWP.h:167
PwpFileWriter
The abstract PwpFileWriter class.
Definition: PwpFileWriter.h:377
PwpFile::isSingle
bool isSingle() const
Determines if floating point precision is PWP_PRECISION_SINGLE.
Definition: PwpFile.cxx:673
PwpWriterInterface::FormatWdG
@ FormatWdG
Format "%*g".
Definition: PwpFileWriter.h:289
PwpFileWriter::getFmtFieldSingle
virtual void getFmtFieldSingle(int &width, int &prec) const
default implementation.
Definition: PwpFileWriter.h:412
PwpFileWriter::fmtPrecSingle_
int fmtPrecSingle_
Single precision format decimals.
Definition: PwpFileWriter.h:471
PwuUnfFileBegin
PWP_BOOL PwuUnfFileBegin(FILE *fp, PWU_UNFDATA *pUData)
Prepares a PWU_UNFDATA block for a new unformatted file I/O session.
Definition: apiPWPUtils.cxx:359
PwpFile::flush
bool flush()
Flush file to disk.
Definition: PwpFile.cxx:842
PwpFile::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:1253
PWP_ENDIANNESS
PWP_ENDIANNESS
Flags used to indicate endianness or control endian behaviors in functions.
Definition: apiPWP.h:822
PwuUnfRecWriteUINT64
PWP_BOOL PwuUnfRecWriteUINT64(PWU_UNFDATA *pUData, PWP_UINT64 val)
Write a PWP_UINT64 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:573
PwpUnformattedWriter::endRecord
virtual bool endRecord()
NOP default implementation.
Definition: PwpFile.cxx:384
PWP_INT
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
PwpFile::beginRecord
virtual bool beginRecord()
Starts an unformatted record.
Definition: PwpFile.cxx:1235
PwpFile::setByteOrder
PWP_ENDIANNESS setByteOrder(PWP_ENDIANNESS order)
Set the byte order used for writes.
Definition: PwpFile.cxx:627
PwpFile::operator=
PwpFile & operator=(const PwpFile &ref)
Assignment operator Does not copy the file position or unformatted data.
Definition: PwpFile.cxx:558
PwpUnformattedWriter::write
virtual bool write(PWP_INT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:397
PwuUnfRecWriteINT32
PWP_BOOL PwuUnfRecWriteINT32(PWU_UNFDATA *pUData, PWP_INT32 val)
Write a PWP_INT32 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:552
PwpAsciiWriter::write
virtual bool write(PWP_UINT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:99
PwpFile::getSize
bool getSize(PWP_UINT64 &size) const
Get the size of the file managed by this object.
Definition: PwpFile.cxx:895
PwpFile::setPrecision
PWP_ENUM_PRECISION setPrecision(PWP_ENUM_PRECISION precision)
Set the floating point precision used for writes.
Definition: PwpFile.cxx:643
PwpAsciiWriter::writeWdPrec
bool writeWdPrec(PWP_REAL val, int wd, int prec, const char *sfx, const char *pfx)
Definition: PwpFile.cxx:140
PwpFileWriter::setFmtType
virtual void setFmtType(FormatType type)
default implementation.
Definition: PwpFileWriter.h:431
PwpFile::getFmtType
virtual FormatType getFmtType() const
Definition: PwpFile.cxx:1369
pwpFileDelete
int pwpFileDelete(const char *filename)
Delete a file.
Definition: pwpPlatform.cxx:429
pwpFormatted
@ pwpFormatted
Definition: pwpPlatform.h:91
PwpAsciiWriter::write
virtual bool write(PWP_UINT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:75
PwpFile::isDouble
bool isDouble() const
Determines if floating point precision is PWP_PRECISION_DOUBLE.
Definition: PwpFile.cxx:680
PwpFile::mapToBigLittle
static PWP_ENDIANNESS mapToBigLittle(PWP_ENDIANNESS byteOrder)
Map a byte ordering value to PWP_ENDIAN_BIG or PWP_ENDIAN_LITTLE based on getOsByteOrder().
Definition: PwpFile.cxx:1205
PWP_ENDIAN_FOREIGN
@ PWP_ENDIAN_FOREIGN
Definition: apiPWP.h:825
PwpAsciiWriter::write
virtual bool write(PWP_UINT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:91
pwpFileWrite
size_t pwpFileWrite(const void *buf, size_t size, size_t count, FILE *fp)
Write an collection of data items to a file.
Definition: pwpPlatform.cxx:402
PwpBinaryWriter::write
virtual bool write(PWP_UINT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:256
PwuUnfRecWriteFLOAT
PWP_BOOL PwuUnfRecWriteFLOAT(PWU_UNFDATA *pUData, PWP_FLOAT val)
Write a PWP_FLOAT value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:580
PwpUnformattedWriter::write
virtual bool write(PWP_UINT32 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:429
PwpBinaryWriter::write
virtual bool write(PWP_UINT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:248
PwpFile::getPos
PWP_INT64 getPos() const
Get the current file position.
Definition: PwpFile.cxx:855
PwpFileWriter::fmtPrecDouble_
int fmtPrecDouble_
Double precision format decimals.
Definition: PwpFileWriter.h:473
PwpBinaryWriter::write
virtual bool write(PWP_INT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:224
PwuUnfRecWriteUINT32
PWP_BOOL PwuUnfRecWriteUINT32(PWU_UNFDATA *pUData, PWP_UINT32 val)
Write a PWP_UINT32 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:559
PwpFile::endRecord
virtual bool endRecord()
Ends an unformatted record.
Definition: PwpFile.cxx:1247
PwpFileWriter::fmtType_
FormatType fmtType_
Formatting flags.
Definition: PwpFileWriter.h:469
pwpFileGetSize
int pwpFileGetSize(FILE *fp, size_t *size)
Get the file's size in bytes.
Definition: pwpPlatform.cxx:332
PwpAsciiWriter::write
virtual bool write(PWP_INT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:59
PwpFile::isAscii
bool isAscii() const
Determines if file was opened with either the pwpAscii or pwpFormatted mode flag.
Definition: PwpFile.cxx:687
PwpFile::unfData
PWU_UNFDATA & unfData()
Get the file's unformatted data buffer.
Definition: PwpFile.h:779
PwpUnformattedWriter::PwpUnformattedWriter
PwpUnformattedWriter(PwpFile &file)
Definition: PwpFile.cxx:357
PwpFileRecord::file_
PwpFile & file_
Definition: PwpFile.h:987
PwpWriterInterface::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)=0
Writes a integer value with proper encoding and byte order.
PwpBinaryWriter::write
virtual bool write(PWP_UINT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:232
PwpUnformattedWriter::write
virtual bool write(PWP_UINT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:437
PwpFile::close
bool close()
Explicitly close the file object.
Definition: PwpFile.cxx:613
PwpFile::isBinary
bool isBinary() const
Determines if file was opened with pwpBinary mode flag.
Definition: PwpFile.cxx:821
PWP_INT64
long long PWP_INT64
64-bit integer
Definition: apiPWP.h:240
PwpFile
Writes solver files.
Definition: PwpFile.h:110
PwpUnformattedWriter::~PwpUnformattedWriter
virtual ~PwpUnformattedWriter()
Definition: PwpFile.cxx:364
PwpFile::getByteOrder
PWP_ENDIANNESS getByteOrder(bool mapBigLittle=false) const
Get the byte order used for writes.
Definition: PwpFile.cxx:636
PwpFile::readInt
bool readInt(PWP_UINT32 &v, const PWP_UINT32 base=10, PWP_UINT32 maxDigits=0)
Reads a single PWP_UINT32 value.
Definition: PwpFile.cxx:1101
PwpFileRecord::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:1429
PwpFile::getFmtFieldSingle
virtual void getFmtFieldSingle(int &width, int &prec) const
Definition: PwpFile.cxx:1332
PwpUnformattedWriter::write
virtual bool write(PWP_FLOAT val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:453
PwpFile::unlink
static bool unlink(const char *filename)
Delete a file.
Definition: PwpFile.cxx:1191
PwpFile::filename_
std::string filename_
The file name.
Definition: PwpFile.h:859
PwpUnformattedWriter::write
virtual bool write(PWP_UINT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:445
PwpFileWriter.h
PwpBinaryWriter::PwpBinaryWriter
PwpBinaryWriter(PwpFile &file)
Definition: PwpFile.cxx:189
PWP_UINT64
unsigned long long PWP_UINT64
64-bit unsigned integer
Definition: apiPWP.h:243
PwpFile::precision_
PWP_ENUM_PRECISION precision_
The file's floating point precision.
Definition: PwpFile.h:861
PwpWriterInterface::FormatType
FormatType
Formatted output types for floating point values.
Definition: PwpFileWriter.h:286
PwpUnformattedWriter::beginRecord
virtual bool beginRecord()
NOP default implementation.
Definition: PwpFile.cxx:370
pwpRead
@ pwpRead
Definition: pwpPlatform.h:75
PwpWriterInterface::FormatE
@ FormatE
Format "%e".
Definition: PwpFileWriter.h:297
PwuUnfRecBeginFixed
PWP_BOOL PwuUnfRecBeginFixed(PWU_UNFDATA *pUData, PWP_UINT32 bytes, PWP_UINT32 count)
Prepares a PWU_UNFDATA block for writing a new unformatted data record when the amount of data being ...
Definition: apiPWPUtils.cxx:453
PwpFile::open
bool open(std::string filename, int mode)
Opens a file with the given filename and mode.
Definition: PwpFile.cxx:593
PwpFile::readDouble
bool readDouble(PWP_REAL &v, PWP_UINT32 maxDigits=0)
Reads a single PWP_REAL value.
Definition: PwpFile.cxx:1161
PwpBinaryWriter::write
virtual bool write(PWP_INT16 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:216
PwuUnfRecWriteUINT16
PWP_BOOL PwuUnfRecWriteUINT16(PWU_UNFDATA *pUData, PWP_UINT16 val)
Write a PWP_UINT16 value to the current record with endian order applied.
Definition: apiPWPUtils.cxx:545
PwpFileWriter::setFmtFieldSingle
virtual void setFmtFieldSingle(const int width, const int prec)
default implementation.
Definition: PwpFileWriter.h:408
PWP_PRECISION_SINGLE
@ PWP_PRECISION_SINGLE
Definition: apiPWP.h:803
PwpFile::getcNotEOF
bool getcNotEOF(int &c)
Reads a single byte value.
Definition: PwpFile.h:645
PwpWriterInterface::FormatPrecF
@ FormatPrecF
Format "%.*f".
Definition: PwpFileWriter.h:295
PwpFile.h
PwpFile::setFmtType
virtual void setFmtType(FormatType type)
Definition: PwpFile.cxx:1360
PwpUnformattedWriter::write
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:389
PWP_ENUM_PRECISION
PWP_ENUM_PRECISION
File precision values.
Definition: apiPWP.h:802
pwpFilenameGetSize
int pwpFilenameGetSize(const char *filename, size_t *size)
Get the file's size in bytes.
Definition: pwpPlatform.cxx:353
PwpFile::rewind
bool rewind()
Reset position to the beginning of the file.
Definition: PwpFile.cxx:887
PWP_UINT8
unsigned char PWP_UINT8
8-bit unsigned integer
Definition: apiPWP.h:170
PwpUnformattedWriter::write
virtual bool write(PWP_INT8 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
Definition: PwpFile.cxx:413
PwpUnformattedWriter::write
virtual bool write(PWP_REAL val, const char *suffix=0, const char *prefix=0)
Writes a floating point value with proper precision, encoding and byte order.
Definition: PwpFile.cxx:464
PwpFileRecord::setFmtFieldDouble
virtual void setFmtFieldDouble(const int width, const int prec)
Definition: PwpFile.cxx:1523
ORDERED_MAXSIZE
@ ORDERED_MAXSIZE
Definition: PwpFile.cxx:21
PwpFile::checkAscii
bool checkAscii() const
Determines whether the file is Ascii by reading the contents of the file.
Definition: PwpFile.cxx:693