BOOL CXMLVecLS::Load(LPCTSTR pcszFileName,stVecParam ¶m,CElems &elems) { CXmlDoc file; if (!file.Load(pcszFileName)) return FALSE; CElem *pElem; CXmlNode n; CXmlNode node = file.Root; param.strBkgndImage = node.GetStringAttrib(_T("BkgndImage")); param.clrBk = node.GetUIntAttrib(_T("BkColor")); param.dwCustomData = node.GetBigUIntAttrib(_T("CustomData")); param.strDesc = node.GetStringAttrib(_T("Desc")); param.scale.cx = node.GetFloatAttrib(_T("XScale")); param.scale.cy = node.GetFloatAttrib(_T("YScale")); BOOL err = FALSE; for (int i=0,cnt=node.ChildCount; i<cnt && !err; ++i) { n = node.Child[i]; pElem = LoadElem(n); if (pElem != NULL) elems.Add(pElem); else err = TRUE; } if (!err) return TRUE; for (int i=0; i<elems.GetCount(); ++i) delete elems[i]; elems.RemoveAll(); return FALSE; }
/** ****************************************************************************** * Name: CIccTagStruct::Read * * Purpose: * * Args: * * Return: ******************************************************************************/ bool CIccTagStruct::Read(icUInt32Number size, CIccIO *pIO) { icTagTypeSignature sig; m_tagSize = size; icUInt32Number headerSize = sizeof(icTagTypeSignature) + sizeof(icUInt32Number) + sizeof(icStructSignature) + sizeof(icUInt32Number); if (headerSize > size) return false; if (!pIO) { return false; } Cleanup(); m_tagStart = pIO->Tell(); if (!pIO->Read32(&sig)) return false; if (!pIO->Read32(&m_nReserved)) return false; if (!pIO->Read32(&m_sigStructType)) return false; icUInt32Number count, i; IccTagEntry TagEntry; TagEntry.pTag = NULL; if (!pIO->Read32(&count)) return false; if (headerSize + count*sizeof(icUInt32Number) > size) return false; //Read TagDir for (i=0; i<count; i++) { if (!pIO->Read32(&TagEntry.TagInfo.sig) || !pIO->Read32(&TagEntry.TagInfo.offset) || !pIO->Read32(&TagEntry.TagInfo.size)) { return false; } m_ElemEntries->push_back(TagEntry); } TagEntryList::iterator entry; for (entry=m_ElemEntries->begin(); entry!=m_ElemEntries->end(); entry++) { if (!LoadElem((IccTagEntry*)&(entry->TagInfo), pIO)) { Cleanup(); return false; } } return true; }