25class _OWLCLASS TFileBuf :
public tstreambuf {
33 if (base_)
delete[] base_;
36 return traits_type::eof();
47 ios_base::seekdir, ios_base::openmode
which =
48 ios_base::in | ios_base::out);
51 ios_base::openmode
which =
52 ios_base::in | ios_base::out);
60 void setb(tchar* beg, tchar* end,
int = 0){
70 void unbuffered(
int buf){
73 setb(
nullptr,
nullptr, 0);
82 return static_cast<int> (ebuf_ - base_);
109class _OWLCLASS TFileInStream :
public TInStream,
public TFileStreamBase {
111class _OWLCLASS TFileInStream :
public TFileStreamBase,
public TInStream {
125class _OWLCLASS TFileOutStream :
public TOutStream,
public TFileStreamBase {
127class _OWLCLASS TFileOutStream :
public TFileStreamBase,
public TOutStream {
200 InfoPresent = GetFileTime(f, &FileCreateTime, &FileAccessTime, &FileUpdateTime);
238 if ((FHdl = OpenThisFile(GetOpenMode(),GetDocPath(),&seekpos)) ==
HFILE_ERROR)
266TFileDocument::Close()
268 if (!TDocument::Close())
271 if (TDocument::IsOpen())
273 CloseThisFile(FHdl, GetOpenMode());
286 if (!TDocument::Commit(
force))
297TFileDocument::Revert(
bool clear)
299 if (!TDocument::Revert(clear))
313static int PropFlags[] = {
314 pfGetBinary|pfGetText,
315 pfGetBinary|pfGetText,
316 pfGetBinary|pfGetText,
317 pfGetBinary|pfGetText,
325TFileDocument::PropertyName(
int index)
327 if (index <= PrevProperty)
328 return TDocument::PropertyName(index);
329 else if (index < NextProperty)
330 return PropNames[index-PrevProperty-1];
339TFileDocument::PropertyFlags(
int index)
341 if (index <= PrevProperty)
342 return TDocument::PropertyFlags(index);
343 else if (index < NextProperty)
344 return PropFlags[index-PrevProperty-1];
357 for (
i=0;
i < NextProperty-PrevProperty-1;
i++)
359 return i+PrevProperty+1;
360 return TDocument::FindProperty(
name);
379 *
reinterpret_cast<FILETIME*
>(
dest) =
pft;
380 return sizeof(FILETIME);
385 dt.wMonth,
dt.wDay,
dt.wYear,
386 dt.wHour,
dt.wMinute,
dt.wSecond,
dt.wMilliseconds / 10);
405 *
reinterpret_cast<unsigned long *
>(
dest) = FileLength;
406 return sizeof(FileLength);
425 return TDocument::GetProperty(index,
dest,
textlen);
434TFileDocument::SetProperty(
int prop,
const void *
src)
438 return TDocument::SetProperty(
prop,
src);
453 omode = GetOpenMode();
472 return new TFileInStream(*
this,
fhdl,
omode, seekpos);
488 omode = GetOpenMode();
507 return new TFileOutStream(*
this,
fhdl,
omode, seekpos);
515TFileInStream::~TFileInStream()
517 (
static_cast<TFileDocument&
>(Doc)).CloseThisFile(buf.xfd, GetOpenMode());
523TFileOutStream::~TFileOutStream()
525 if (buf.out_waiting())
527 (
static_cast<TFileDocument&
>(Doc)).CloseThisFile(buf.xfd, GetOpenMode());
541 base_ = ebuf_ =
nullptr;
558TFileBuf::pos_type TFileBuf::seekoff(
off_type off, ios_base::seekdir
dir,
566 else if (
dir == ios::cur) {
573 if ((mode & ofBinary) == 0) {
588 if (!unbuffered() && base()) {
589 size_t pb = (blen() > 8) ? 4 : 1;
602 uint count = out_waiting();
611 if ((mode & ofBinary) == 0) {
615 count =
static_cast<int>(
curp -
srcp) + 1;
627 int pb = (blen() > 8) ? 4 : 1;
648 if ((mode & (ofRead | ofWrite)) == ofWrite)
657 if (!unbuffered() && base()) {
662 int pb = (blen() > 8) ? 4 : 1;
671 if ((mode & ofBinary) == 0) {
693 count =
static_cast<int>(
endp -
begp);
707 setg(
nullptr,
nullptr,
nullptr);
710 c =
static_cast<utchar>(lahead[0]);
711 if ((mode & ofBinary) == 0 &&
c ==
_T(
'\r'))
713 setg(lahead, lahead, lahead+1);
726TFileBuf::int_type TFileBuf::overflow(
int_type c)
728 if ((mode & (ofRead | ofWrite)) == ofRead)
731 if (unbuffered() || !base()) {
736 if (
c ==
_T(
'\n') && (mode & ofBinary) == 0) {
756 int pb = (blen() > 8) ? 4 : 1;
777TFileBuf::pos_type TFileBuf::seekpos(
pos_type sp,
778 ios_base::openmode
which){
799#if OWL_PERSISTENT_STREAMS
809 o->InfoPresent =
false;
818TFileDocument::Streamer::Write(opstream&
os)
const
821 WriteBaseObject((TDocument*)GetObject(),
os);
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
Derived from TDocument, TFileDocument opens and closes views and provides stream support for views.
Derived from TStream and istream, TInStream is a base class used to define input streams for document...
Derived from TStream and ostream, TOutStream is a base class used to create output storage streams fo...
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TFileDocument.
void ReadBaseObject(Base *base, ipstream &in)
#define IMPLEMENT_STREAMABLE1(cls, base1)
const uint vnDocClosed
document has just been closed
const uint vnDocOpened
document has just been opened
#define IS_PREV_OPEN(omode)
@ ofRead
ios::in, open for reading
@ ofTruncate
ios::trunc, truncate file if already exists
@ shRead
DENY_WRITE functionality.
@ shDefault
use stream implementation default value
@ ofParent
use open mode of parent storage
@ ofNoReplace
ios::noreplace, open fails if file already exists
@ ofAppend
ios::app, append mode: all additions at eof
@ ofWrite
ios::out, open for writing
@ ofAtEnd
ios::ate, seek to eof upon original open
@ shReadWrite
DENY_NONE functionality.
@ ofNoCreate
ios::nocreate, open fails if file doesn't exist
@ shCompat
for non-compliant applications, avoid if possible
Object Windows Library (OWLNext Core)
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.