/* * db_col_insert() - This function inserts a new element into the sequence at a * position immediately before the indexed element. This function is * normally used with collections of type DB_TYPE_SEQUENCE. If the index is * 0, the new element is added to the beginning of the sequence. All * elements in the sequence are moved down to make room for the new element. * The sequence increases in size by one element. * return : error status * col(in): collection * element_index(in): index of new element * value(in): value to insert */ int db_col_insert (DB_COLLECTION * col, int element_index, DB_VALUE * value) { int error = NO_ERROR; DB_TYPE coltype; CHECK_CONNECT_ERROR (); CHECK_1ARG_ERROR (col); /* Check if modifications are disabled only if the set is owned */ if (col->owner != NULL) { CHECK_MODIFICATION_ERROR (); } coltype = set_get_type (col); if (coltype == DB_TYPE_SEQUENCE) { error = set_insert_element (col, element_index, value); } else { error = set_add_element (col, value); } return error; }
/* * db_set_type() - This function returns the type identifier for a set. This * can be used in places where it is not known if a set descriptor is for * a set, multi-set or sequence. * return : set type identifier * set(in): set descriptor */ DB_TYPE db_set_type (DB_SET * set) { DB_TYPE type = DB_TYPE_NULL; if (set != NULL) { type = set_get_type (set); } return (type); }
/* * db_col_type() - This function returns the base type for this collection. * return : one of DB_TYPE_SET, DB_TYPE_MULTISET, or DB_TYPE_SEQUENCE. * col(in): collection */ DB_TYPE db_col_type (DB_COLLECTION * col) { DB_TYPE type = DB_TYPE_NULL; CHECK_CONNECT_ERROR (); CHECK_1ARG_ERROR_WITH_TYPE (col, DB_TYPE); type = set_get_type (col); return type; }
/* * read data to the set from a file overriding the current contents */ int update_set_from_file(Quark *pset) { int retval; Dataset *dsp; dsp = set_get_dataset(pset); if (!dsp) { retval = RETURN_FAILURE; } else { FILE *fp; RunTime *rt = rt_from_quark(pset); fp = gapp_openr(gapp_from_quark(pset), dsp->hotfile, dsp->hotsrc); killsetdata(pset); rt->curtype = set_get_type(pset); retval = uniread(get_parent_project(pset), fp, LOAD_SINGLE, dsp->hotfile); gapp_close(fp); } return retval; }
char *q_labeling(Quark *q) { Grace *grace = grace_from_quark(q); char *buf; tickmarks *t; DObject *o; region *r; if (!q) { return NULL; } buf = xmalloc(strlen(QIDSTR(q)) + 128); if (!buf) { return NULL; } switch (quark_fid_get(q)) { case QFlavorProject: sprintf(buf, "Project \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorSSD: sprintf(buf, "SpreadSheet \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorFrame: sprintf(buf, "Frame \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorGraph: sprintf(buf, "Graph \"%s%s\" (type: %s)", QIDSTR(q), quark_dirtystate_get(q) ? "*":"", graph_types(grace, graph_get_type(q))); break; case QFlavorSet: sprintf(buf, "Set \"%s%s\" (%s)", QIDSTR(q), quark_dirtystate_get(q) ? "*":"", set_types(grace, set_get_type(q))); break; case QFlavorAGrid: t = axisgrid_get_data(q); sprintf(buf, "%c AGrid \"%s%s\"", t->type == AXIS_TYPE_X ? 'X':'Y', QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorAxis: t = axisgrid_get_data(q); sprintf(buf, "Axis \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorDObject: o = object_get_data(q); sprintf(buf, "%s \"%s%s\"", object_type_descr(grace, o->type), QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorAText: sprintf(buf, "AText \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; case QFlavorRegion: r = region_get_data(q); sprintf(buf, "Region \"%s%s\" (%d pts)", QIDSTR(q), quark_dirtystate_get(q) ? "*":"", r->n); break; default: sprintf(buf, "??? \"%s%s\"", QIDSTR(q), quark_dirtystate_get(q) ? "*":""); break; } return buf; }