28#if defined(CHECK_REFCOUNT)
31 count =
si->Release();
34# define RefCountCheck(si)
43class TStorageBuf :
public streambuf {
52 virtual ~TStorageBuf();
54 int is_open() {
return opened; }
57 TStorageBuf * close();
61 return traits_type::eof();
70 ios_base::openmode
which = ios_base::in |
73 ios_base::openmode
which =
74 ios_base::in | ios_base::out);
79 void setb(
char *beg,
char *end,
int = 0){
94 return (
int) (ebuf_ - base_);
109class TStorageStreamBase :
virtual public ios {
112 ~TStorageStreamBase() {}
113 void setbuf(
char *,
int);
122class TStorageInStream :
public TStorageStreamBase,
127 TStorageStreamBase(*
doc.StorageI,
name, mode) {}
128 ~TStorageInStream() {}
134class TStorageOutStream :
public TStorageStreamBase,
139 TStorageStreamBase(*
doc.StorageI,
name, mode) {}
140 ~TStorageOutStream() {}
343 OrgStorageI = StorageI;
390 StorageI = OrgStorageI;
452 LockBytes->Release();
489 LockBytes->Release();
528 if (!StorageI || !CanRelease)
545TStorageDocument::DetachStream(
TStream& strm)
661 _T(
"IStorage Instance"),
667static int PropFlags[] = {
731 return sizeof(FILETIME);
736 dt.wMonth,
dt.wDay,
dt.wYear,
737 dt.wHour,
dt.wMinute,
dt.wSecond,
dt.wMilliseconds / 10);
761 return sizeof(
ulong);
797#if OWL_PERSISTENT_STREAMS
813TStorageDocument::Streamer::Write(
opstream&
os)
const
835 else if (buf.open(
stg,
name, mode))
841void TStorageStreamBase::setbuf(
char*
newbuf,
int len)
846#if defined(BI_COMP_BORLANDC)
847 setstate(ios::failbit);
853void TStorageStreamBase::close()
858#if defined(BI_COMP_BORLANDC)
859 setstate(ios::failbit);
872TStorageBuf::TStorageBuf()
880 char* p =
new char[
B_size];
892TStorageBuf::~TStorageBuf()
911 if (opened || !
omode)
921 if (
omode & ofWrite) {
922 if (!(mode & (ofAtEnd | ofAppend | ofRead)))
928 if (
omode & (ofNoReplace)) {
932 else if (!(
omode & (ofNoCreate))) {
934 if (
omode & ofTruncate) {
940 else if (
omode & ofRead)
968 if ((
omode & ofAtEnd) != 0
975 int pb =
b ? ((blen() > 8) ? 4 : 1) : 0;
986TStorageBuf* TStorageBuf::attach(
IStream* f)
1009 setb(
b,
b+B_size, 1);
1011 int pb =
b ? ((blen() > 8) ? 4 : 1) : 0;
1025 if (opened && base())
1030 pb = (
len > 8) ? 4 : 1;
1048TStorageBuf::pos_type TStorageBuf::seekoff(
off_type off,
1049 ios_base::seekdir
dir, ios_base::openmode )
1052 int count = out_waiting();
1060 else if (
dir == ios::cur) {
1061 count =
static_cast<int>(
in_avail());
1067 if ((mode & ofBinary) == 0) {
1082 if (!unbuffered() && base()) {
1083 int pb = (blen() > 8) ? 4 : 1;
1088 return (
uint32)last_seek;
1091TStorageBuf::pos_type TStorageBuf::seekpos(
pos_type sp,
1092 ios_base::openmode
which){
1099int TStorageBuf::sync()
1105 int count = out_waiting();
1113 if ((mode & ofBinary) == 0) {
1132 int pb = (blen() > 8) ? 4 : 1;
1151TStorageBuf::int_type TStorageBuf::underflow()
1157 if (!opened || (mode & (ofRead | ofWrite)) == ofWrite)
1163 if (!unbuffered() && base()) {
1169 int pb = (blen() > 8) ? 4 : 1;
1170 char*
begp = base() +
pb;
1181 if ((mode & ofBinary) == 0) {
1224 if ((mode & ofBinary) == 0 &&
c ==
_T(
'\r'))
1226 setg(lahead, lahead, lahead+1);
1239TStorageBuf::int_type TStorageBuf::overflow(
int_type c)
1241 if (!opened || (mode & (ofRead | ofWrite)) == ofRead)
1244 if (unbuffered() || !base()) {
1248 if (
c ==
_T(
'\n') && (mode & ofBinary) == 0) {
1259 if ((
int)
actual != count)
1272 int pb = (blen() > 8) ? 4 : 1;
1288TStorageBuf* TStorageBuf::close()
1294 if (out_waiting() && overflow(eof()) == eof())
1296 if ((mode & ofWrite) )
1302 return ores ? 0 :
this;
#define PRECONDITION(condition)
LPCTSTR PropertyName(int index)
int FindProperty(LPCTSTR name)
int GetProperty(int index, void *dest, int textlen=0)
friend class TStorageInStream
bool Commit(bool force=false)
virtual bool OpenHandle(int omode, HANDLE hGlobal)
Create an IStorage based on a memory handle.
virtual bool SetStorage(IStorage *stg, bool remember=true)
Give an IStorage to document. This typically happens for OLE servers.
bool Open(int omode, LPCTSTR stgId)
Open the compound file with a given path.
virtual bool ReleaseDoc()
Release the IStorage and close the document.
friend class TStorageOutStream
bool IsOpen()
Return 'true' if the storage document object has opened an OLE storage.
bool Revert(bool clear=false)
owl::TInStream * InStream(int omode, LPCTSTR strmId=0)
owl::TOutStream * OutStream(int omode, LPCTSTR strmId=0)
virtual bool GetHandle(HGLOBAL *handle)
Get the global handle from ILockBytes.
virtual bool SetHandle(int omode, HANDLE hGlobal, bool create=false, bool remember=false)
Replace the IStorage with an istorage based on a memory handle.
bool SetProperty(int index, const void *src)
virtual IStorage * GetNewStorage()
Get a new IStorage, typically in a SaveAs situation.
int PropertyFlags(int index)
virtual bool RestoreStorage()
Restore the original root IStorage before the save operation.
bool SetDocPath(LPCTSTR path)
bool CommitTransactedStorage()
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
virtual int GetProperty(int index, void *dest, int textlen=0)
Retrieves the property identified by the given index.
virtual void DetachStream(TStream &strm)
called from TStream destructor
bool NotifyViews(int eventId, TParam2=0, TView *exclude=nullptr)
Notifies the views of this document, and the views of any child documents, of a change.
virtual bool SetProperty(int index, const void *src)
native type
LPCTSTR GetDocPath() const
Returns the directory path for the document.
virtual LPCTSTR PropertyName(int index)
locale invariant name
virtual bool Close()
close document, does not delete or detach
virtual int PropertyFlags(int index)
pfXxxxx bit array
virtual bool SetDocPath(LPCTSTR path)
Sets the document path for Open and Save operations.
void SetOpenMode(int mode)
Sets the mode and protection flag values for the current document.
void SetDirty(bool dirty=true)
Updates the document's dirty flag using the specified parameter.
bool IsEmbedded() const
Returns true if the document is embedded in an OLE 2 container.
virtual bool Commit(bool force=false)
save current data, force write
int GetOpenMode() const
Gets the mode and protection flag values for the current document.
void SetEmbedded(bool embed)
Marks the document as being embedded in an OLE 2 container.
TDocument * GetParentDoc()
Returns either the parent document of the current document or 0 if there is no parent document.
virtual bool Revert(bool clear=false)
abort changes, no reload if true
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...
An abstract base class, TStream provides links between streams and documents, views,...
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Base class for writing streamable objects.
Definition of classes TDocument, TView, TWindowView, TStream, TInStream, TOutStream.
void ReadBaseObject(Base *base, ipstream &in)
#define IMPLEMENT_STREAMABLE1(cls, base1)
void WriteBaseObject(Base *base, opstream &out)
const uint pfGetText
property accessible as text format
const uint vnDocClosed
document has just been closed
const uint vnDocOpened
document has just been opened
const uint pfGetBinary
property accessible as native non-text format
@ ofRead
ios::in, open for reading
@ ofTruncate
ios::trunc, truncate file if already exists
@ shRead
DENY_WRITE functionality.
@ ofParent
use open mode of parent storage
@ ofNoReplace
ios::noreplace, open fails if file already exists
@ ofPriority
STGM_PRIORITY, temporary efficient peeking.
@ ofPreserve
STGM_CONVERT, backup old data of same name.
@ ofAppend
ios::app, append mode: all additions at eof
@ ofWrite
ios::out, open for writing
@ ofAtEnd
ios::ate, seek to eof upon original open
@ ofTransacted
STGM_TRANSACTED, supports commit and revert.
@ shReadWrite
DENY_NONE functionality.
@ shNone
EXCLUSIVE functionality.
@ ofNoCreate
ios::nocreate, open fails if file doesn't exist
@ shCompat
for non-compliant applications, avoid if possible
@ ofTemporary
STGM_DELETEONRELEASE, delete when destructed.
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation)
long IosToStgMode(int omode)
int StgToIosShareMode(long grfMode)
int StgToIosMode(long grfMode)
int StgToIosTempMode(long grfMode)
int StgToIosOpenMode(long grfMode)
long IosToStgTempMode(int omode)
const TCHAR DefaultStreamName[]
long IosToStgShareMode(int omode)
long IosToStgOpenMode(int omode)
Object Windows Library (OWLNext Core)
interface _ICLASS IStorage
#define RefCountCheck(si)
interface _ICLASS IStream
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Definition of class TString, a flexible universal string envelope class.