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


C++ XMLElement::DoubleAttribute方法代码示例

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


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

示例1: init

void VisualComponent::init(XMLElement *xmlData)
{
	XMLElement *visibleElt = xmlData->FirstChildElement("Visible");
	// if no visibility if specified, default to true
	if (visibleElt == nullptr)
		visible = true;
	else
	{
		visible = visibleElt->BoolAttribute("value");
	}

	XMLElement *textureElt = xmlData->FirstChildElement("Texture");
	// if no texture is specified, set it to null
	if (textureElt == nullptr)
		texture = nullptr;
	else
	{
		string texID = textureElt->Attribute("id");
		texture = TextureManager::get()->getTexture(texID);
	}

	XMLElement *dimElt = xmlData->FirstChildElement("Dimensions");
	// if both are null, we have no dimension data
	if (dimElt == nullptr && textureElt == nullptr)
		throw BAD_DIMENSION_ERR;
	// if no dimensions are specified, take them from the texture
	else if (dimElt == nullptr)
	{
		width = texture->width;
		height = texture->height;
	}
	else
	{
		width = dimElt->DoubleAttribute("w");
		height = dimElt->DoubleAttribute("h");
	}


	XMLElement *colorElt = xmlData->FirstChildElement("Color");
	// if no color is specified, default to white
	if (colorElt == nullptr)
		colorData = bm::Color(255, 255, 255, 255);
	else
	{
		int r = colorElt->IntAttribute("r");
		int g = colorElt->IntAttribute("g");
		int b = colorElt->IntAttribute("b");
		int a = colorElt->IntAttribute("a");
		colorData = bm::Color(r, g, b, a);
	}
}
开发者ID:beamery,项目名称:Quad-Pong,代码行数:51,代码来源:VisualComponent.cpp

示例2: gsv_parse

GSV* gsv_parse(char* xmlString)
{
#ifdef GSV_DEBUG
	printf("gsv_parse(%p)\n",xmlString);
	printf("XML = %s\n",xmlString);
#endif
	XMLDocument doc;
	doc.Parse(xmlString);
	
	GSV* gsvHandle = (GSV*) malloc(sizeof(GSV));
	if(gsvHandle == NULL)
		return NULL;
	
	*gsvHandle = GSVDefault;
	
	XMLElement* panoramaElement = doc.FirstChildElement("panorama");
	XMLElement* dataPropertiesElement = panoramaElement->FirstChildElement("data_properties");
	
	int error = dataPropertiesElement->QueryIntAttribute("image_width",&gsvHandle->dataProperties.imageWidth);
	GSV_WARNING("image_width",error);
	error = dataPropertiesElement->QueryIntAttribute("image_height",&gsvHandle->dataProperties.imageHeight);
	GSV_WARNING("image_height",error);
	error = dataPropertiesElement->QueryIntAttribute("tile_width",&gsvHandle->dataProperties.tileWidth);
	GSV_WARNING("tile_width",error);
	error = dataPropertiesElement->QueryIntAttribute("tile_height",&gsvHandle->dataProperties.tileHeight);
	GSV_WARNING("tile_height",error);
	
	char year[5];
	memset(year,'\0',sizeof(year)*sizeof(char));
	char month[3];
	memset(month,'\0',sizeof(month)*sizeof(char));
	const char* imageDate = dataPropertiesElement->Attribute("image_date");
	memcpy(year,imageDate,4*sizeof(char));
	memcpy(month,&imageDate[5],2*sizeof(char));
	struct tm imageDateTm = { 0, 0, 0, 1, atoi(month)-1, atoi(year)-1900, 0, 0, -1 };
	gsvHandle->dataProperties.imageDate = mktime(&imageDateTm);
	
	memcpy(gsvHandle->dataProperties.panoramaId,dataPropertiesElement->Attribute("pano_id"),GSV_PANORAMA_ID_LENGTH);
	error = dataPropertiesElement->QueryIntAttribute("num_zoom_levels",&gsvHandle->dataProperties.numZoomLevels);
	GSV_WARNING("num_zoom_levels",error);
	error = dataPropertiesElement->QueryDoubleAttribute("lat",&gsvHandle->dataProperties.latitude);
	GSV_WARNING("lat",error);
	error = dataPropertiesElement->QueryDoubleAttribute("lng",&gsvHandle->dataProperties.longitude);
	GSV_WARNING("lng",error);
	error = dataPropertiesElement->QueryDoubleAttribute("original_lat",&gsvHandle->dataProperties.longitude);
	GSV_WARNING("original_lat",error);
	error = dataPropertiesElement->QueryDoubleAttribute("original_lng",&gsvHandle->dataProperties.longitude);
	GSV_WARNING("original_lng",error);
	gsv_copy_string(dataPropertiesElement->FirstChildElement("copyright")->GetText(),&gsvHandle->dataProperties.copyright);
	gsv_copy_string(dataPropertiesElement->FirstChildElement("text")->GetText(),&gsvHandle->dataProperties.text);
	gsv_copy_string(dataPropertiesElement->FirstChildElement("street_range")->GetText(),&gsvHandle->dataProperties.streetRange);
	gsv_copy_string(dataPropertiesElement->FirstChildElement("region")->GetText(),&gsvHandle->dataProperties.region);
	gsv_copy_string(dataPropertiesElement->FirstChildElement("country")->GetText(),&gsvHandle->dataProperties.country);
	
	XMLElement* projectionPropertiesElement = panoramaElement->FirstChildElement("projection_properties");
	gsv_copy_string(projectionPropertiesElement->Attribute("projection_type"),&gsvHandle->projectionProperties.projectionType);
	gsvHandle->projectionProperties.panoramaYaw = projectionPropertiesElement->DoubleAttribute("pano_yaw_deg");
	gsvHandle->projectionProperties.tiltYaw = projectionPropertiesElement->DoubleAttribute("tilt_yaw_deg");
	gsvHandle->projectionProperties.tiltYaw = projectionPropertiesElement->DoubleAttribute("tilt_pitch_deg");
	
	XMLElement* annotationProperties = panoramaElement->FirstChildElement("annotation_properties");
	XMLElement* linkElement = annotationProperties->FirstChildElement("link");
	
	while(linkElement != NULL)
	{
		gsvHandle->annotationProperties.links = (gsvLink*) realloc(gsvHandle->annotationProperties.links,(gsvHandle->annotationProperties.numLinks+1)*sizeof(gsvLink));
		gsvLink* link = &gsvHandle->annotationProperties.links[gsvHandle->annotationProperties.numLinks];
		
		error = linkElement->QueryDoubleAttribute("yaw_deg",&link->yaw);
		GSV_WARNING("yaw_deg",error);
		
		memcpy(link->panoramaId,linkElement->Attribute("pano_id"),GSV_PANORAMA_ID_LENGTH);
		
		const char* road_argb = linkElement->Attribute("road_argb");
		*((unsigned int*)&link->roadColour) = (unsigned int)strtoul(&road_argb[2],NULL,16);
		link->scene = linkElement->IntAttribute("scene");
		
		XMLElement* linkTextElement = linkElement->FirstChildElement("link_text");
		gsv_copy_string(linkTextElement->GetText(),&link->text);
		
		gsvHandle->annotationProperties.numLinks++;
		
		XMLNode* siblingNode = linkElement->NextSibling();
		if(siblingNode == NULL)
			break;
		linkElement = siblingNode->ToElement();
	}
	
	return gsvHandle;
}
开发者ID:8W9aG,项目名称:cstreetview,代码行数:90,代码来源:googlestreetview.c

示例3: fillData

bool RoadPatch::fillData(XMLElement* titleElement)
{
  m_number_of_diversions = 0;

  // create strip collection and end pose collection of this roadPatch instance
  m_strip_collection = std::make_shared<TrajectoryConstContainer>();    //< all strips
  m_diversion_collection = std::make_shared<DiversionConstContainer>();   //< driving strips by diversion
  m_endpose_collection = std::make_shared<PoseContainer>();

  // check titleElement
  int tmp = titleElement->IntAttribute(XML_TITLE_ID_);
  if (tmp >= (int)PatchType::PATCH_COUNT)  //< Error non valid ID
    return false;
  m_patch_type = (PatchType)tmp;

  //****** ITERATE OVER DIVERSIONS *******/
  u_int8_t current_diversion_id = 0;
  XMLElement* diversion = titleElement->FirstChildElement(XML_DIVERSION_ELEMENT);

  while( diversion != nullptr )
  {
    // read current diversion id
    int32_t diversion_id = diversion->IntAttribute(XML_DIVERSION_ID);

    if (diversion_id < 0 || diversion_id > 255)
      return false;   //< error invalid diversion ID

    // read tags in correct order, skip wrong ids first
    if ((u_int8_t)diversion_id != current_diversion_id)
    {
      diversion = diversion->NextSiblingElement(XML_DIVERSION_ELEMENT);
      continue;
    }

    // Read diversion direction attribute
    int32_t reverse_tag;
    bool forward = true;
    if (diversion->QueryIntAttribute(XML_DIVERSION_DIRECTION_ATTRIB, &reverse_tag) == tinyxml2::XML_SUCCESS)
    {
      if (reverse_tag == 1)
        forward = false;
    }

    TrajectoryConstContainer current_diversion;


    //****** ITERATE OVER STRIPS ***********/
    u_int8_t current_strip_id = 0;
    XMLElement* strip = diversion->FirstChildElement(XML_STRIP_ELEMENT);
    while ( strip != nullptr )
    {
      // read current strip id
      int32_t strip_id = strip->IntAttribute(XML_STRIP_ID);
      if (strip_id < 0 || strip_id > 255)
        return false;   //< error invalid strip ID

      // read tags in correct order, skip wrong ids first
      if ((u_int8_t)strip_id != current_strip_id)
      {
        strip = strip->NextSiblingElement(XML_STRIP_ELEMENT);
        continue;
      }


      //************ READ STRIP *************/
      TrajectoryPtr driving_strip = std::make_shared<Trajectory2d>();
      driving_strip->isForwardTrajectory() = forward;

      // iterate over points of strip
      for (XMLElement* p_child = strip->FirstChildElement(XML_POINT_ELEMENT); p_child != nullptr; p_child = p_child->NextSiblingElement(XML_POINT_ELEMENT))
      {
        ExtendedPose2d p;
        PoseTraits<Pose2d>::fromPositionAndOrientationRPY(p.pose(),
                                                          p_child->DoubleAttribute(XML_POINT_X),
                                                          p_child->DoubleAttribute(XML_POINT_Y),
                                                          p_child->DoubleAttribute(XML_POINT_YAW));
        driving_strip->push_back(p);
      }

      if (driving_strip->empty())   //< this is an error (empty file?)
        return false;

      // save strip as strip of current diversion
      current_diversion.push_back(driving_strip);
      // save strip in complete strip container
      m_strip_collection->push_back(driving_strip);

      // prepare search for next strip_id -> begin searching again at first strip
      current_strip_id++;
      strip = diversion->FirstChildElement(XML_STRIP_ELEMENT);
    }

    if (current_diversion.empty())
      return false;

    // Save strips of this diversion
    m_diversion_collection->push_back(current_diversion);

    //*********** READ ENDPOSE *************/
    XMLElement* p_endpose = diversion->FirstChildElement(XML_ENDPOSE_ELEMENT);
//.........这里部分代码省略.........
开发者ID:KAtana-Karlsruhe,项目名称:AADC_2015_KAtana,代码行数:101,代码来源:RoadPatch.cpp


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