예제 #1
0
void tmc_set_suite_points(Suite *s, const char *s_name, const char *points)
{
    SuitePoints *sp = (SuitePoints*) malloc(sizeof(SuitePoints));
    sp->s = s;
    sp->points = points;
    sp->s_name = s_name;
    sp->next = suite_points;
    suite_points = sp;

    parse_points(points, &all_points);
}
예제 #2
0
void tmc_set_tcase_points(TCase *tc, const char *tc_name, const char *points)
{
    PointsAssoc *pa = (PointsAssoc*)malloc(sizeof(PointsAssoc));
    pa->tc = tc;
    pa->tc_name = tc_name;
    pa->points = points;
    pa->next = points_assocs;
    points_assocs = pa;

    parse_points(points, &all_points);
}
예제 #3
0
파일: tmx_xml.c 프로젝트: V0idExp/tmx
static int parse_object(xmlTextReaderPtr reader, tmx_object *obj) {
	int curr_depth;
	const char *name;
	char *value;

	/* parses each attribute */
	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"x"))) { /* x */
		obj->x = atof(value);
		tmx_free_func(value);
	} else {
		tmx_err(E_MISSEL, "xml parser: missing 'x' attribute in the 'object' element");
		return 0;
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"y"))) { /* y */
		obj->y = atof(value);
		tmx_free_func(value);
	} else {
		tmx_err(E_MISSEL, "xml parser: missing 'y' attribute in the 'object' element");
		return 0;
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"name"))) { /* name */
		obj->name = value;
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"visible"))) { /* visible */
		obj->visible = (char)atoi(value);
		tmx_free_func(value);
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"height"))) { /* height */
		obj->shape = S_SQUARE;
		obj->height = atof(value);
		tmx_free_func(value);
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"width"))) { /* width */
		obj->width = atof(value);
		tmx_free_func(value);
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"gid"))) { /* gid */
		obj->shape = S_TILE;
		obj->gid = atoi(value);
		tmx_free_func(value);
	}

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"rotation"))) { /* rotation */
		obj->rotation = atof(value);
		tmx_free_func(value);
	}

	/* If it has a child, then it's a polygon or a polyline or an ellipse */
	curr_depth = xmlTextReaderDepth(reader);
	if (!xmlTextReaderIsEmptyElement(reader)) {
		do {
			if (xmlTextReaderRead(reader) != 1) return 0; /* error_handler has been called */

			if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
				name = (char*)xmlTextReaderConstName(reader);
				if (!strcmp(name, "properties")) {
					if (!parse_properties(reader, &(obj->properties))) return 0;
				} else if (!strcmp(name, "ellipse")) {
					obj->shape = S_ELLIPSE;
				} else {
					if (!strcmp(name, "polygon")) {
						obj->shape = S_POLYGON;
					} else if (!strcmp(name, "polyline")) {
						obj->shape = S_POLYLINE;
					}
					/* Unknow element, skip its tree */
					else if (xmlTextReaderNext(reader) != 1) return 0;
					if (!parse_points(reader, &(obj->points), &(obj->points_len))) return 0;
				}
			}
		} while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT ||
		         xmlTextReaderDepth(reader) != curr_depth);
	}
	return 1;
}