OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
autoiter.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4/// \file
5/// OLE Automation - Implementation of TAutoIterator
6//----------------------------------------------------------------------------
7#include <ocf/pch.h>
8#include <ocf/appdesc.h>
9#include <ocf/ocreg.h>
10
11namespace ocf {
12
13using namespace owl;
14
15//
16//
17//
19 :Creator(creator), Owner(owner), Symbol(0),
20 RefCnt(0), Class(0), Lang(lang)
21{
22 // NOTE: RefCnt = 0 on creation, will ++ in TAutoVal operator(IUnknown*)
23}
24
25
26//
27//
28//
30 :Symbol(copy.Symbol), Owner(copy.Owner), Class(copy.Class),
31 Lang(copy.Lang), Creator(copy.Creator), RefCnt(1)
32{
33 Owner->AddRef();
34}
35
36//
37//
38//
40{
41 Owner->Release();
42}
43
44//
45// IEnumVARIANT implementation
46//
49{
51 *pif = 0;
52 return HR_NOINTERFACE;
53 }
54 *pif = this;
55 ++RefCnt;
56 return HR_NOERROR;
57}
58
59//
60//
61//
63{
64 return ++RefCnt;
65}
66
67//
68//
69//
71{
72 return --RefCnt==0 ? delete this,0 : RefCnt;
73}
74
75//
76//
77//
79 unsigned long* retcount)
80{
81 unsigned long index = 0;
82 try {
83 while(index < count) {
84 if (!Test())
85 break;
86 TAutoVal & retval = ((TAutoVal*)retvals)[(int)index];
88 if (Symbol->IsEnum())
91 if (retval.GetObjDesc(objDesc)) {
92 if (!objDesc.Object) // null pointer returned from function
93 retval = TAutoVoid(); // return an empty value if no object
94 else
96 }
97 Step();
98 index++;
99 }
100 }
101 catch(...) {
102 }
103 if (retcount)
104 *retcount = index;
105 return index==count ? HR_NOERROR : HR_FALSE;
106}
107
108//
109//
110//
112{
113 while(count--) {
114 if (!Test())
115 return HR_FALSE;
116 Step();
117 }
118 return HR_NOERROR;
119}
120
121//
122//
123//
125{
126 Init();
127 return HR_NOERROR;
128}
129
130//
131//
132//
134{
135 try {
136 *ppenum = Copy();
137 return HR_NOERROR;
138 }
139 catch (...) {
140 return HR_OUTOFMEMORY;
141 }
142}
143
144
145} // OCF namespace
146
147//==============================================================================
148
TAppDescriptor - OLE application descriptor definitions.
Object responsible for creating automation COM object.
Definition autodefs.h:924
virtual IDispatch * CreateDispatch(TObjectDescriptor objDesc, IUnknown *outer=0)=0
virtual bool Convert(TAutoVal &txtVal, TAutoVal &numVal)=0
automation collection iterator
Definition autodefs.h:1186
virtual void Return(TAutoVal &v)=0
TAutoSymbol * Symbol
Definition autodefs.h:1213
virtual void Step()=0
HRESULT _IFUNC Reset()
Definition autoiter.cpp:124
virtual ~TAutoIterator()
Definition autoiter.cpp:39
owl::TLangId Lang
Definition autodefs.h:1217
unsigned long _IFUNC AddRef()
Definition autoiter.cpp:62
TAutoIterator(TAutoCreator &creator, IUnknown *owner, owl::TLangId lang)
Definition autoiter.cpp:18
HRESULT _IFUNC Next(unsigned long count, VARIANT *retvals, unsigned long *retcount)
Definition autoiter.cpp:78
virtual TAutoIterator * Copy()=0
unsigned long _IFUNC Release()
Definition autoiter.cpp:70
IUnknown * Owner
Definition autodefs.h:1215
HRESULT _IFUNC QueryInterface(const GUID &iid, void **pif)
Definition autoiter.cpp:48
HRESULT _IFUNC Clone(IEnumVARIANT **retiter)
Definition autoiter.cpp:133
virtual bool Test()=0
TAutoCreator & Creator
Definition autodefs.h:1214
HRESULT _IFUNC Skip(unsigned long count)
Definition autoiter.cpp:111
virtual void Init()=0
Automation data element (same data as OLE/BASIC VARIANT)
Definition autodefs.h:526
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
const GUID & iid
Definition appdesc.h:328
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
#define HR_NOINTERFACE
Definition defs.h:79
#define HR_NOERROR
Definition defs.h:73
#define HR_FALSE
Definition defs.h:75
#define HR_OUTOFMEMORY
Definition defs.h:77
OLE Registration definitions.
#define _IFUNC
Definition oleutil.h:28
bool IsEnum() const
Definition autodefs.h:1513
TAutoEnum * GetEnum() const
Definition autodefs.h:1534