//------------------------------------------------------------------------- // Microsoft OLE // Copyright (C) Microsoft Corporation, 1992 - 1996. // All rights reserved. // // File: chancedf.cxx // // Contents: Implementation for ChanceDF object. // // Classes: ChanceDF // // Functions: ChanceDF (public) // ~ChanceDF (public) // CreateFromParams (public) // CreateFromSize, multiple (public) // CreateFromFile (public) // Create (public) // GetSeed (public) // Generate (protected) // GenerateRoot (protected) // Init, multiple (public) // ParseRange(protected) // DeleteChanceDocFileTree (public) // GetModes (public) // AppendChildNode (protected) // AppendSisterNode (protected) // DeleteChanceDocFileSubTree (protected) // GetDocFileNameFromCmdline (private) // GetRandomChanceNode (protected) // GetDepthOfNode (private) // // History: DeanE 12-Mar-96 Created // Narindk 20-Apr-96 Added more functions, enhanced. // BogdanT 30-Oct-96 Mac porting changes //-------------------------------------------------------------------------- #include #pragma hdrstop // Debug object declaration DH_DECLARE; #define WSZ_DEF_VAL OLESTR("none") //-------------------------------------------------------------------------- // Member: ChanceDF::ChanceDF, public // // Synopsis: Constructor. Initializes variables but real work is // done in ::Create*() methods. This method cannot fail. // // Arguments: None. // // Returns: Nothing. // // History: DeanE 12-Mar-96 Created //--------------------------------------------------------------------------- ChanceDF::ChanceDF() : _pdgi(NULL), _pcnRoot(NULL), _pcdfd(NULL), _ptszName(NULL) { DH_FUNCENTRY(NULL, DH_LVL_DFLIB, _TEXT("ChanceDF ctor")); } //+-------------------------------------------------------------------------- // Member: ChanceDF::~ChanceDF, public // // Synopsis: Destructor. Frees memory and releases objects. // // Arguments: None. // // Returns: Nothing. // // History: DeanE 12-Mar-96 Created //--------------------------------------------------------------------------- ChanceDF::~ChanceDF() { DH_FUNCENTRY(NULL, DH_LVL_DFLIB, _TEXT("ChanceDF dtor")); if(NULL != _pcdfd) { delete _pcdfd; _pcdfd = NULL; } if(NULL != _pdgi) { delete _pdgi; _pdgi = NULL; } if(NULL != _ptszName) { delete _ptszName; _ptszName = NULL; } } //-------------------------------------------------------------------------- // Member: ChanceDF::Init, public // // Synopsis: Initializes _pcdfd field in the ChanceDF object with default // values // // Arguments: // // // Returns: HRESULT // // History: t-leonr 26-Jul-97 Created // // Notes: // //--------------------------------------------------------------------------- HRESULT ChanceDF::Init() { DH_FUNCENTRY(NULL, DH_LVL_DFLIB, _TEXT("ChanceDF::Init()")); if (NULL == _pcdfd) { _pcdfd = new CDFD; if (NULL == _pcdfd) { return(E_OUTOFMEMORY); } } _pcdfd->cDepthMin = 0; _pcdfd->cDepthMax = 2; _pcdfd->cStgMin = 0; _pcdfd->cStgMax = 3; _pcdfd->cStmMin = 0; _pcdfd->cStmMax = 5; _pcdfd->cbStmMin = 0; _pcdfd->cbStmMax = 5000; _pcdfd->ulSeed = 0; _pcdfd->dwRootMode = _pcdfd->dwStgMode = _pcdfd->dwStmMode = STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE; return(S_OK); } //-------------------------------------------------------------------------- // Member: ChanceDF::Init, public // // Synopsis: Initializes the _pcdfd field in the ChanceDF object with the // values passed in the pcdfd. // // Arguments: pcdfd // // // Returns: HRESULT // // History: t-leonr 26-Jul-97 Created // // Notes: // //--------------------------------------------------------------------------- HRESULT ChanceDF::Init(CDFD *pcdfd) { DH_FUNCENTRY(NULL, DH_LVL_DFLIB, _TEXT("ChanceDF::Init(pcdfd)")); if (NULL == _pcdfd) { _pcdfd = new CDFD; if (NULL == _pcdfd) { return(E_OUTOFMEMORY); } } memcpy(_pcdfd, pcdfd, sizeof(CDFD)); return (S_OK); } //-------------------------------------------------------------------------- // Member: ChanceDF::CreateFromParams, public // // Synopsis: Creates the DocFile from the command line parameters. // // Arguments: [argc] // [argv] // // Returns: HRESULT // // History: DeanE 12-Mar-96 Created // Narindk 20-Apr-96 Enhanced // t-leonr 27-Jul-97 Add stuff about Init() // // Notes: // Precedence of switches in the event of conflicts: // 1) /dfsize:tiny, huge, etc // 2) /dftemp: