Go to the documentation of this file.
10 #ifndef _PWPANCHOREDFILEVALUE_H_
11 #define _PWPANCHOREDFILEVALUE_H_
25 template<
typename ValType >
39 PWP_INT fldWidth,
const char * suffix,
const char * prefix)
43 return f.
write(v, suffix, prefix);
59 PWP_INT fldWidth,
const char * suffix,
const char * prefix)
62 return 0 != fprintf(f,
"%s%*u%s", (prefix ? prefix :
""), (
int)fldWidth,
63 (
unsigned int)v, (suffix ? suffix :
""));
79 PWP_INT fldWidth,
const char * suffix,
const char * prefix)
86 ret = f.
write(v, suffix, prefix);
167 template<
typename ValType,
330 const ValType&
val()
const
340 operator const ValType&()
const
476 #endif // _PWPANCHOREDFILEVALUE_H_
PwpAnchoredFileValue(PwpFile &f, const ValType &initV, PWP_INT fldWidth, const char *suffix=0, const char *prefix=0)
Constructor.
bool setPos(const sysFILEPOS &pos)
Set the current file position.
const ValType & val() const
Gets the current data value.
PwpAnchoredFileValue< ValType, ValWriter > & operator=(const PwpAnchoredFileValue< ValType, ValWriter > &)
const char * suffix() const
Gets the current value suffix.
bool anchor(const char *suffix=0, const char *prefix=0, PWP_INT fldWidth=0)
Anchors the value to the associated file's current file position and writes a placeholder value to th...
bool isUnformatted() const
Determines if file was opened with pwpUnformatted mode flag.
PwpFile & f() const
Gets the file associated with the anchored value.
bool getPos(sysFILEPOS &pos) const
Get the current file position.
static bool writeBin(bool placeholder, PwpFile &f, const ValType &v, PWP_INT fldWidth, const char *suffix, const char *prefix)
Handles the writing an anchored value to a binary file.
bool anchor(PWP_INT fldWidth, const char *suffix=0, const char *prefix=0)
Anchors the value to the associated file's current file position and writes a placeholder value to th...
The default ValWriter type used by PwpAnchoredFileValue<ValWriter>.
bool rollback()
Moves the associated file to the anchored file position and unanchors the value.
PwpAnchoredFileValue(PwpFile &f, const ValType &initV, const char *suffix=0, const char *prefix=0, PWP_INT fldWidth=-1)
Constructor.
ValType & val()
Gets the current data value.
bool isAnchored() const
Gets the current value anchoring status.
PwpAnchoredFileValue(PwpFile &f)
Constructor.
static bool writeUnf(bool placeholder, PwpFile &f, const ValType &v, PWP_INT fldWidth, const char *suffix, const char *prefix)
Handles the writing an anchored value to an fortran unformatted file.
Handles the delayed updating of a value in a PwpFile object.
PWP_INT fldWidth() const
Gets the current value field width.
virtual bool write(PWP_INT64 val, const char *suffix=0, const char *prefix=0)
Writes a integer value with proper encoding and byte order.
const ValType & operator=(const ValType &rhs) const
const ValType assignment operator.
const sysFILEPOS & pos() const
Gets the anchor position associated with the file.
ValType & operator=(const ValType &rhs)
ValType assignment operator.
bool isAscii() const
Determines if file was opened with either the pwpAscii or pwpFormatted mode flag.
const void * PwuApplyEndianness(PWP_ENDIANNESS endianness, const void *buf, size_t size)
Apply specified byte order to buf containing size bytes.
bool isBinary() const
Determines if file was opened with pwpBinary mode flag.
PWP_ENDIANNESS getByteOrder(bool mapBigLittle=false) const
Get the byte order used for writes.
const char * prefix() const
Gets the current value prefix.
static bool writeAsc(bool placeholder, PwpFile &f, const ValType &v, PWP_INT fldWidth, const char *suffix, const char *prefix)
Handles the writing an anchored value to an ASCII file.
bool commit()
Writes the value to the associated file's anchored file position.