#include "catalog.h" #include "Catmeta.h" #include "WriterGlobalHelper.h" #include "Writer.h" #include "WriterGlobals.h" #include "MBPropertyWriter.h" #include "MBCollectionWriter.h" #include "MBSchemaWriter.h" typedef CMBCollectionWriter* LP_CMBCollectionWriter; // // TODO: Determine an optimal number - set to max number of ADSI classes? // #define MAX_COLLECTIONS 50 /***************************************************************************++ Routine Description: Constructor for CMBSchemaWriter. Arguments: None. Return Value: None. --***************************************************************************/ CMBSchemaWriter::CMBSchemaWriter(CWriter* i_pcWriter): m_apCollection(NULL), m_cCollection(0), m_iCollection(0), m_pCWriter(NULL) { // // Assumption: i_pcWriter will be valid for the // lifetime of the schema writer object. // m_pCWriter = i_pcWriter; } // CMBSchemaWriter::CMBSchemaWriter /***************************************************************************++ Routine Description: Destructor for CMBSchemaWriter. Arguments: None. Return Value: None. --***************************************************************************/ CMBSchemaWriter::~CMBSchemaWriter() { if(NULL != m_apCollection) { for(ULONG i=0; iInitialize(i_wszCollection, i_bContainer, i_wszContainerClassList, m_pCWriter); m_apCollection[m_iCollection++] = pCMBCollectionWriter; *o_pMBCollectionWriter = pCMBCollectionWriter; return S_OK; } // CMBSchemaWriter::GetCollectionWriter /***************************************************************************++ Routine Description: ReAllocates its list of collection writers. Arguments: None. Return Value: HRESULT --***************************************************************************/ HRESULT CMBSchemaWriter::ReAllocate() { CMBCollectionWriter** pSav = NULL; pSav = new LP_CMBCollectionWriter[m_cCollection + MAX_COLLECTIONS]; if(NULL == pSav) { return E_OUTOFMEMORY; } memset(pSav, 0, (sizeof(LP_CMBCollectionWriter))*(m_cCollection + MAX_COLLECTIONS)); if(NULL != m_apCollection) { memcpy(pSav, m_apCollection, (sizeof(LP_CMBCollectionWriter))*(m_cCollection)); delete [] m_apCollection; m_apCollection = NULL; } m_apCollection = pSav; m_cCollection = m_cCollection + MAX_COLLECTIONS; return S_OK; } // CMBSchemaWriter::ReAllocate /***************************************************************************++ Routine Description: Wites the schema. Arguments: None. Return Value: HRESULT --***************************************************************************/ HRESULT CMBSchemaWriter::WriteSchema() { HRESULT hr = S_OK; for(ULONG i=0; iWriteCollection(); if(FAILED(hr)) { return hr; } } return hr; } // CMBSchemaWriter::WriteSchema