void _CollectionOfDaata_v_writeText (_CollectionOfDaata* me, MelderFile file) { texputi4 (file, my size, U"size", 0,0,0,0,0); texputintro (file, U"item []: ", my size ? nullptr : U"(empty)", 0,0,0,0); for (long i = 1; i <= my size; i ++) { Daata thing = my at [i]; ClassInfo classInfo = thing -> classInfo; texputintro (file, U"item [", Melder_integer (i), U"]:", 0,0,0); if (! Thing_isa (thing, classDaata) || ! Data_canWriteText (thing)) Melder_throw (U"Objects of class ", classInfo -> className, U" cannot be written."); texputw2 (file, classInfo -> version > 0 ? Melder_cat (classInfo -> className, U" ", classInfo -> version) : classInfo -> className, U"class", 0,0,0,0,0); texputw2 (file, thing -> name, U"name", 0,0,0,0,0); Data_writeText (thing, file); texexdent (file); } texexdent (file); }
static void cb_ERPWindow_publication (Editor /* editor */, autoDaata publication) { /* * Keep the gate for error handling. */ try { bool isaSpectralSlice = Thing_isa (publication.get(), classSpectrum) && str32equ (Thing_getName (publication.get()), U"slice"); praat_new (publication.move()); praat_updateSelection (); if (isaSpectralSlice) { int IOBJECT; LOOP { iam (Spectrum); autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me); praat_installEditor (editor2.get(), IOBJECT); editor2.releaseToUser(); } } } catch (MelderError) { Melder_flushError (); } }
void _CollectionOfDaata_v_copy (_CollectionOfDaata* me, _CollectionOfDaata* thee) { thy at._elements = nullptr; // set to null in case the inherited v_copy crashes my structDaata :: v_copy (thee); thy _ownershipInitialized = my _ownershipInitialized; thy _ownItems = my _ownItems; thy _capacity = my _capacity; thy size = my size; if (my _capacity > 0) { thy at._elements = Melder_calloc (Daata, my _capacity); // filled with null pointers thy at._elements --; // immediately turn from base-0 into base-1 // BUG use NUMvector } for (long i = 1; i <= my size; i ++) { Daata itempie = my at [i]; if (my _ownItems) { if (! Thing_isa (itempie, classDaata)) Melder_throw (U"Cannot copy item of class ", Thing_className (itempie), U"."); thy at [i] = Data_copy (itempie).releaseToAmbiguousOwner(); } else { thy at [i] = itempie; // reference copy: if me doesn't own the items, then thee shouldn't either // NOTE: the items don't have to be Daata } } }