1
/***********************************************************************
4
* Copyright (C) 2004 Novell, Inc.
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public
17
* License along with this program; if not, write to the Free
18
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
***********************************************************************/
23
#include "CSPObjectIterator.h"
25
CSPObjectIterator::CSPObjectIterator(HFCURSOR cursor, int count, FLMBOOL includeColId) :
29
m_includeColId(includeColId)
34
m_pRecords = new FLMUINT[m_Count];
38
for (i = 0; i < count; ++i)
40
rc = FlmCursorNextDRN(cursor, &m_pRecords[i]);
51
CSPObjectIterator::~CSPObjectIterator(void)
59
int CSPObjectIterator::NextXml(CSPStore *pStore, FLMUNICODE *pOriginalBuffer, int nChars)
62
int charsWritten = nChars;
65
FLMUNICODE* pBuffer = pOriginalBuffer;
66
int endTagLen = f_unilen((FLMUNICODE*)XmlObjectListEndString) + 1;
68
if (m_Index < m_Count)
70
if ((len = flmstrcpy(pBuffer, (FLMUNICODE*)XmlObectListString, nChars)) != -1)
72
nChars -= len + endTagLen;
75
while (RC_OK(rc) && m_Index < m_Count)
77
rc = FlmRecordRetrieve(pStore->GetDB(), FLM_DATA_CONTAINER, m_pRecords[m_Index], FO_EXACT, &pRec, 0);
78
if (RC_OK(rc) && pRec)
80
CSPStoreObject *pObject = new CSPStoreObject(pStore, pRec);
83
if ((len = pObject->ToXML(pBuffer, nChars, false, m_includeColId)) != -1)
97
else if (rc == FERR_NOT_FOUND)
108
if ((len = flmstrcpy(pBuffer, (FLMUNICODE*)XmlObjectListEndString, nChars + endTagLen)) != -1)
114
return (len != -1 ? charsWritten - nChars : 0);
117
bool CSPObjectIterator::SetIndex(IndexOrigin origin, int offset)
126
newOffset = m_Count + offset;
133
if (newOffset <= m_Count && newOffset >= 0)