void visitAtoms(const QTAtomContainer &atoms, const QTAtom &parent, TPropertyGroup &pg) { QTAtom curr = 0; do { if (QTNextChildAnyType(atoms, parent, curr, &curr) != noErr) assert(false); if (curr == 0) break; QTAtomType atomType; QTAtomID id; QTGetAtomTypeAndID(atoms, curr, &atomType, &id); int sonCount = QTCountChildrenOfType(atoms, curr, 0); char buffer[1024]; sprintf(buffer, "%d %d %d", (int)atomType, (int)id, sonCount); string str(buffer); if (sonCount > 0) { pg.add(new TStringProperty(str, TString())); visitAtoms(atoms, curr, pg); } else { long size; UCHAR *atomData; if (QTGetAtomDataPtr(atoms, curr, &size, (char **)&atomData) != noErr) assert(false); string strapp; for (int i = 0; i < size; i++) { string num; if (atomData[i] == 0) { int count = 1; while ((i + 1) < size && atomData[i + 1] == 0) i++, count++; if (count > 1) { num = std::to_string(count); strapp = strapp + "z " + num + " "; continue; } } num = std::to_string(atomData[i]); strapp = strapp + string(num) + " "; } // unsigned short*buffer = new unsigned short[size]; // buffer[size]=0; // for (i=0; i<size; i++) // buffer[i] = atomData[i]+1; wstring data = ::to_wstring(strapp); pg.add(new TStringProperty(str, data)); } } while (curr != 0); }
void fromAtomsToProperties(const QTAtomContainer &atoms, TPropertyGroup &pg) { pg.clear(); visitAtoms(atoms, kParentAtomIsContainer, pg); }