OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
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
11
namespace
ocf
{
12
13
using namespace
owl;
14
15
//
16
//
17
//
18
TAutoIterator::TAutoIterator
(
TAutoCreator
& creator,IUnknown* owner,
TLangId
lang)
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
//
29
TAutoIterator::TAutoIterator
(
TAutoIterator
& copy)
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
//
39
TAutoIterator::~TAutoIterator
()
40
{
41
Owner
->Release();
42
}
43
44
//
45
// IEnumVARIANT implementation
46
//
47
HRESULT
_IFUNC
48
TAutoIterator::QueryInterface
(
const
GUID&
iid
,
void
** pif)
49
{
50
if
(
iid
!=IID_IUnknown &&
iid
!=IID_IEnumVARIANT) {
51
*pif = 0;
52
return
HR_NOINTERFACE
;
53
}
54
*pif =
this
;
55
++
RefCnt
;
56
return
HR_NOERROR
;
57
}
58
59
//
60
//
61
//
62
unsigned
long
_IFUNC
TAutoIterator::AddRef
()
63
{
64
return
++
RefCnt
;
65
}
66
67
//
68
//
69
//
70
unsigned
long
_IFUNC
TAutoIterator::Release
()
71
{
72
return
--
RefCnt
==0 ?
delete
this
,0 :
RefCnt
;
73
}
74
75
//
76
//
77
//
78
HRESULT
_IFUNC
TAutoIterator::Next
(
unsigned
long
count, VARIANT* retvals,
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];
87
Return
(retval);
88
if
(
Symbol
->
IsEnum
())
89
Symbol
->
GetEnum
()->
Convert
(retval,
Lang
);
90
TObjectDescriptor
objDesc;
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
95
retval =
Creator
.
CreateDispatch
(objDesc);
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
//
111
HRESULT
_IFUNC
TAutoIterator::Skip
(
unsigned
long
count)
112
{
113
while
(count--) {
114
if
(!
Test
())
115
return
HR_FALSE
;
116
Step
();
117
}
118
return
HR_NOERROR
;
119
}
120
121
//
122
//
123
//
124
HRESULT
_IFUNC
TAutoIterator::Reset
()
125
{
126
Init
();
127
return
HR_NOERROR
;
128
}
129
130
//
131
//
132
//
133
HRESULT
_IFUNC
TAutoIterator::Clone
(IEnumVARIANT** ppenum)
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
appdesc.h
TAppDescriptor - OLE application descriptor definitions.
ocf::TAutoCreator
Object responsible for creating automation COM object.
Definition
autodefs.h:924
ocf::TAutoCreator::CreateDispatch
virtual IDispatch * CreateDispatch(TObjectDescriptor objDesc, IUnknown *outer=0)=0
ocf::TAutoEnum::Convert
virtual bool Convert(TAutoVal &txtVal, TAutoVal &numVal)=0
ocf::TAutoIterator::Return
virtual void Return(TAutoVal &v)=0
ocf::TAutoIterator::Symbol
TAutoSymbol * Symbol
Definition
autodefs.h:1213
ocf::TAutoIterator::RefCnt
unsigned RefCnt
Definition
autodefs.h:1216
ocf::TAutoIterator::Step
virtual void Step()=0
ocf::TAutoIterator::Reset
HRESULT _IFUNC Reset()
Definition
autoiter.cpp:124
ocf::TAutoIterator::~TAutoIterator
virtual ~TAutoIterator()
Definition
autoiter.cpp:39
ocf::TAutoIterator::Lang
owl::TLangId Lang
Definition
autodefs.h:1217
ocf::TAutoIterator::AddRef
unsigned long _IFUNC AddRef()
Definition
autoiter.cpp:62
ocf::TAutoIterator::TAutoIterator
TAutoIterator(TAutoCreator &creator, IUnknown *owner, owl::TLangId lang)
Definition
autoiter.cpp:18
ocf::TAutoIterator::Next
HRESULT _IFUNC Next(unsigned long count, VARIANT *retvals, unsigned long *retcount)
Definition
autoiter.cpp:78
ocf::TAutoIterator::Class
TAutoClass * Class
Definition
autodefs.h:1211
ocf::TAutoIterator::Copy
virtual TAutoIterator * Copy()=0
ocf::TAutoIterator::Release
unsigned long _IFUNC Release()
Definition
autoiter.cpp:70
ocf::TAutoIterator::Owner
IUnknown * Owner
Definition
autodefs.h:1215
ocf::TAutoIterator::QueryInterface
HRESULT _IFUNC QueryInterface(const GUID &iid, void **pif)
Definition
autoiter.cpp:48
ocf::TAutoIterator::Clone
HRESULT _IFUNC Clone(IEnumVARIANT **retiter)
Definition
autoiter.cpp:133
ocf::TAutoIterator::Test
virtual bool Test()=0
ocf::TAutoIterator::Creator
TAutoCreator & Creator
Definition
autodefs.h:1214
ocf::TAutoIterator::Skip
HRESULT _IFUNC Skip(unsigned long count)
Definition
autoiter.cpp:111
ocf::TAutoIterator::Init
virtual void Init()=0
ocf::TAutoVal
Automation data element (same data as OLE/BASIC VARIANT).
Definition
autodefs.h:526
ocf::TAutoVal::GetObjDesc
bool GetObjDesc(TObjectDescriptor &)
Definition
autodefs.h:1759
pch.h
Include for OC, gets common headers when precompiled headers are enabled.
ocf
Object Component Framework (COM encapsulation).
Definition
appdesc.h:22
ocf::iid
const GUID & iid
Definition
appdesc.h:328
owl::TLangId
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition
lclstrng.h:26
HR_NOINTERFACE
#define HR_NOINTERFACE
Definition
defs.h:79
HR_NOERROR
#define HR_NOERROR
Definition
defs.h:73
HR_FALSE
#define HR_FALSE
Definition
defs.h:75
HR_OUTOFMEMORY
#define HR_OUTOFMEMORY
Definition
defs.h:77
ocreg.h
OLE Registration definitions.
_IFUNC
#define _IFUNC
Definition
oleutil.h:28
ocf::TAutoSymbol::IsEnum
bool IsEnum() const
Definition
autodefs.h:1513
ocf::TAutoSymbol::GetEnum
TAutoEnum * GetEnum() const
Definition
autodefs.h:1534
ocf::TAutoVoid
Definition
autodefs.h:225
ocf::TObjectDescBase::Object
const void * Object
< ONLY for use when storing in TAutoVal union
Definition
autodefs.h:452
ocf::TObjectDescriptor
Definition
autodefs.h:470
source
ocf
autoiter.cpp
Generated by
1.18.0