当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::QueryUnsignedAttribute方法代码示例

本文整理汇总了C++中TiXmlElement::QueryUnsignedAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::QueryUnsignedAttribute方法的具体用法?C++ TiXmlElement::QueryUnsignedAttribute怎么用?C++ TiXmlElement::QueryUnsignedAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::QueryUnsignedAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseNode


//.........这里部分代码省略.........
				printf("Error reading \"xyz3\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf %lf", &x3, &y3, &z3) != 3) {
				printf("Error parsing \"xyz3\" attribute!\n");
				throw InvalidXMLException();
			}

			MyTriangle *tri = new MyTriangle(x1, y1, z1, x2, y2, z2, x3, y3, z3);
			n->addPrimitive(tri);

			printf("Triangle\nxyz1: (%f,%f,%f)\nxyz2: (%f,%f,%f)\nxyz3: (%f,%f,%f)\n", x1, y1, z1, x2, y2, z2, x3, y3,
					z3);

		} else if (strcmp(child_type, "cylinder") == 0) {
			double cyl_base = 0, cyl_top = 0, cyl_height = 0;
			unsigned int cyl_slices = 0, cyl_stacks = 0;

			if (child->QueryDoubleAttribute("base", &cyl_base) != TIXML_SUCCESS) {
				printf("Error parsing base attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryDoubleAttribute("top", &cyl_top) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryDoubleAttribute("height", &cyl_height) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryUnsignedAttribute("slices", &cyl_slices) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryUnsignedAttribute("stacks", &cyl_stacks) != TIXML_SUCCESS) {
				printf("Error parsing stacks attribute!\n");
				throw InvalidXMLException();
			}

			MyCylinder *cyl = new MyCylinder(cyl_base, cyl_top, cyl_height, cyl_slices, cyl_stacks);
			n->addPrimitive(cyl);

			printf("Cylinder\nbase: %f\ntop: %f\nheight: %f\nslices: %d\nstacks: %d\n", cyl_base, cyl_top, cyl_height,
					cyl_slices, cyl_stacks);

		} else if (strcmp(child_type, "sphere") == 0) {
			double sph_rad = 0;
			unsigned int sph_slices = 0, sph_stacks = 0;

			if (child->QueryDoubleAttribute("radius", &sph_rad) != TIXML_SUCCESS) {
				printf("Error parsing radius attribute!\n");
			}

			if (child->QueryUnsignedAttribute("slices", &sph_slices) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
			}

			if (child->QueryUnsignedAttribute("stacks", &sph_stacks) != TIXML_SUCCESS) {
				printf("Error parsing stacks attribute!\n");
			}

			MySphere *sph = new MySphere(sph_rad, sph_slices, sph_stacks);
开发者ID:diogojapinto,项目名称:laig_proj1,代码行数:67,代码来源:XMLScene.cpp


注:本文中的TiXmlElement::QueryUnsignedAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。