OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
filedoc.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TFileDocument
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_FILEDOC_H)
10#define OWL_FILEDOC_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/docview.h>
18
19namespace owl {
20
21#include <owl/preclass.h>
22
23/// \addtogroup docview
24/// @{
25
26/// \class TFileDocument
27// ~~~~~ ~~~~~~~~~~~~~
28/// Derived from TDocument, TFileDocument opens and closes views and provides stream
29/// support for views. TFileDocument has member functions that continue to process
30/// FileNew and FileOpen messages after a view is constructed. You can add support
31/// for specialized file types by deriving classes from TFileDocument. TFileDocument
32/// makes this process easy by hiding the actual process of storing file types.
33//
35 public:
36 /// Contains constants that define the following properties of the document:
38 PrevProperty = TDocument::NextProperty-1,
39 CreateTime, ///< The time the view or document was created (FILETIME)
40 ModifyTime, ///< The time the view or document was modified (FILETIME)
41 AccessTime, ///< The time the view or document was last accessed (FILETIME)
42 StorageSize, ///< An unsigned long containing the storage size (ulong)
43 FileHandle, ///< The platform file handle (HFILE if Windows)
45 };
46
47 TFileDocument(TDocument* parent = 0);
49
50 // Implement virtual methods of TDocument
51 //
52 bool Open(int mode, LPCTSTR path=0);
53 using TDocument::Open; ///< String-aware overload
54 bool Close();
55 TInStream* InStream(int mode, LPCTSTR strmId=0);
56 using TDocument::InStream; ///< String-aware overload
57 TOutStream* OutStream(int mode, LPCTSTR strmId=0);
58 using TDocument::OutStream; ///< String-aware overload
59 bool Commit(bool force = false);
60 bool Revert(bool clear = false);
61 bool IsOpen();
62
63 int FindProperty(LPCTSTR name); ///< return index
64 using TDocument::FindProperty; ///< String-aware overload
65 int PropertyFlags(int index);
66 LPCTSTR PropertyName(int index);
67 int PropertyCount();
68 int GetProperty(int index, void * dest, int textlen=0);
69 bool SetProperty(int index, const void * src);
70
71 // Additional methods for file document
72 //
73 bool Open(HFILE fhdl); ///< open on existing file handle
74
75 protected:
76 HFILE OpenThisFile(int omode, const tstring& fileName, std::streampos* pseekpos);
77 void CloseThisFile(HFILE fhdl, int omode);
78
80 HFILE FHdl; ///< file handle if held open at the document level
81
82 private: // cached info for property access
83 bool InfoPresent;
84 ulong FileLength;
85
86 FILETIME FileCreateTime;
87 FILETIME FileAccessTime;
88 FILETIME FileUpdateTime;
89
90 friend class _OWLCLASS TFileInStream;
91 friend class _OWLCLASS TFileOutStream;
93};
94/// @{
95
97
98#include <owl/posclass.h>
99
100
101//----------------------------------------------------------------------------
102// Inline implementations
103//
104
105//
106/// Constructs a TFileDocument object with the optional parent document.
108:
109 TDocument(parent), FHdl(HFILE_ERROR), InfoPresent(false)
110{
111}
112
113//
114/// Destroys a TFileDocument object.
118
119//
120/// Is nonzero if the document or any streams are open.
121//
123{
124 return FHdl != HFILE_ERROR || TDocument::IsOpen();
125}
126
127//
128/// Return the number of property support by this document.
129/// \note The property count includes properties inherited from base document
130/// classes.
131//
133{
134 return NextProperty - 1;
135}
136
137
138} // OWL namespace
139
140
141#endif // OWL_FILEDOC_H
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
Definition docview.h:187
virtual bool IsOpen()
Checks to see if the document has any streams in its stream list.
Definition docview.h:896
Derived from TDocument, TFileDocument opens and closes views and provides stream support for views.
Definition filedoc.h:34
Derived from TStream and istream, TInStream is a base class used to define input streams for document...
Definition docview.h:594
Derived from TStream and ostream, TOutStream is a base class used to create output storage streams fo...
Definition docview.h:605
Definition of classes TDocument, TView, TWindowView, TStream, TInStream, TOutStream.
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
~TFileDocument()
Destroys a TFileDocument object.
Definition filedoc.h:115
TFileDocProp
Contains constants that define the following properties of the document:
Definition filedoc.h:37
int PropertyCount()
Return the number of property support by this document.
Definition filedoc.h:132
bool IsOpen()
Is nonzero if the document or any streams are open.
Definition filedoc.h:122
TFileDocument(TDocument *parent=0)
Constructs a TFileDocument object with the optional parent document.
Definition filedoc.h:107
@ FileHandle
The platform file handle (HFILE if Windows)
Definition filedoc.h:43
@ ModifyTime
The time the view or document was modified (FILETIME)
Definition filedoc.h:40
@ AccessTime
The time the view or document was last accessed (FILETIME)
Definition filedoc.h:41
@ CreateTime
The time the view or document was created (FILETIME)
Definition filedoc.h:39
@ StorageSize
An unsigned long containing the storage size (ulong)
Definition filedoc.h:42
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long ulong
Definition number.h:26
std::string tstring
Definition defs.h:79
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338