Exemplo n.º 1
0
bool GetObjectResponseSerializer::ItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
	Item * item;
	if (strcmp(element.Name(), "recorded_tv") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
		int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
		int channelSubnumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
		RECORDEDTV_STATE state = (RECORDEDTV_STATE)  Util::GetXmlFirstChildElementTextAsInt(&element, "state");

		item = new RecordedTV(objectId, parentId, url,thumbnail,channelName,canBeDeleted,size,creationTime,channelNumber,channelSubnumber, state);

		tinyxml2::XMLElement * vElement = (tinyxml2::XMLElement*)(&element)->FirstChildElement("video_info");

		VideoInfoSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, ((RecordedTV*) item)->VInfo);
		
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "video") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");

		item = new Video(objectId, parentId, url,thumbnail,canBeDeleted,size,creationTime);
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "audio") == 0) 
	{     
		item = new Audio();
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "image") == 0) 
	{     
		item = new Image();
		m_items.push_back(item);
		return false;
	}

	return true;

}
Exemplo n.º 2
0
bool	CStacksmithXMLPrinter::CompactMode( const tinyxml2::XMLElement& elem )
{
	if( strcmp(elem.Name(),"text") == 0 || strcmp(elem.Name(),"script") == 0 || strcmp(elem.Name(),"td") == 0
		|| strcmp(elem.Name(),"body") == 0 )	// For htmlText property.
		return true;
	const tinyxml2::XMLElement*	firstElem = elem.FirstChildElement();
	const tinyxml2::XMLNode*	firstChild = elem.FirstChild();
	if( firstChild && firstElem && firstChild == elem.LastChild() && firstElem == firstChild	// Exactly one child, and it's an element?
		&& firstElem->FirstChild() == NULL )	// And this element has no children? I.e. is self-closing?
	{
		return true;
	}
	
	return false;
}
Exemplo n.º 3
0
/**
 * Processes the current element within the context of the attributed object.
 */
bool XmlProcessor::ReadElement( Context & ctxt, const tinyxml2::XMLElement & elem, AccessorAdaptorBase* pAdaptor)
{
	TranslatorId id = TE_END;
	const char* szNodeName = elem.Name();

	//Use the current translator if available to lookup appropriate
	//translator for the current element.   If not available,
	//do a global search.
	if( ctxt.pParent != NULL)
	{
		id = TranslatorIdFromElemName( szNodeName, ctxt.pParent->GetAllowedNodes() );	
	}
	else //Do a global lookup.  
	{
		for( int i = 0; i < COUNT_TRANSLATORS && id == TE_END; i++)
		{
			NodeEntry* pNodes = _Translators[i].translator.GetAllowedNodes();
			if(pNodes == NULL) continue;

			id = TranslatorIdFromElemName( szNodeName, pNodes);	
		}
	}

	//Get the translator and attempt to process the current
	//element.
	Translator& trans = TranslatorFromId( id);
	return trans.OnRead( ctxt, elem, pAdaptor);
}
Exemplo n.º 4
0
bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
    if (strcmp(element.Name(), "favorite") == 0)
    {
        std::string id = Util::GetXmlFirstChildElementText(&element, "id");
        std::string name = Util::GetXmlFirstChildElementText(&element, "name");

        //channels
        ChannelFavorite::favorite_channel_list_t channels;
        const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
        if (channels_element != NULL)
        {
            const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
            while (channel_element != NULL)
            {
                if (strcmp(channel_element->Name(), "channel") == 0)
                {
                    if (channel_element->GetText() != NULL)
                        channels.push_back(channel_element->GetText());
                }
                channel_element = channel_element->NextSiblingElement();
            }

        }

        ChannelFavorite cf(id, name, channels);

        m_favoritesList.favorites_.push_back(cf);

        return false;
    }

    return true;
}
Exemplo n.º 5
0
bool GetChannelsResponseSerializer::GetChannelsResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
  if (strcmp(element.Name(), "channel") == 0) 
  {     
    long channelDvbLinkId = Util::GetXmlFirstChildElementTextAsLong(&element, "channel_dvblink_id");
    std::string channelId = Util::GetXmlFirstChildElementText(&element, "channel_id");
    std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
    int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
    int channelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
    Channel::DVBLinkChannelType channelType = (Channel::DVBLinkChannelType)Util::GetXmlFirstChildElementTextAsInt(&element, "channel_type");
    std::string channelLogoUrl = Util::GetXmlFirstChildElementText(&element, "channel_logo");

    Channel* channel = new Channel(channelId, channelDvbLinkId, channelName, channelType, channelLogoUrl, channelNumber, channelSubNumber);

    if (m_parent.HasChildElement(*&element, "channel_child_lock"))
    {
      channel->ChildLock = Util::GetXmlFirstChildElementTextAsBoolean(&element, "channel_child_lock");
    }

    m_channelList.push_back(channel);

    return false;
  }

  return true;
}
bool GetSchedulesResponseSerializer::GetSchedulesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{

  if (strcmp(element.Name(), "schedule") == 0) 
  {    
	
    std::string scheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
    std::string userParam = Util::GetXmlFirstChildElementText(&element, "user_param");
    bool forceadd = Util::GetXmlFirstChildElementTextAsBoolean(&element, "force_add");

	tinyxml2::XMLElement* epg = (tinyxml2::XMLElement*)(&element)->FirstChildElement("by_epg");
	tinyxml2::XMLElement* manual = (tinyxml2::XMLElement*)(&element)->FirstChildElement("manual");

	 Schedule* s = NULL;
		
	if (epg->FirstChildElement("program_id") != NULL) //byEPG
	{
	
		std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
		std::string programid = Util::GetXmlFirstChildElementText(epg, "program_id");

		bool repeat = Util::GetXmlFirstChildElementTextAsBoolean(epg, "repeat");
		bool newonly = Util::GetXmlFirstChildElementTextAsBoolean(epg, "new_only");
		bool recordseriesanytime = Util::GetXmlFirstChildElementTextAsBoolean(epg, "record_series_anytime");
		bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
		tinyxml2::XMLElement* pEl = (tinyxml2::XMLElement*)(epg)->FirstChildElement("program");
		Program* p = new Program();
		ProgramSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *pEl, *p);
		s = new Schedule(scheduleId,channelid,programid, p, recordings_to_keep,userParam,forceadd,repeat,newonly,recordings_to_keep);

	}else{

		std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
		std::string title = Util::GetXmlFirstChildElementText(epg, "title");

		long starttime = Util::GetXmlFirstChildElementTextAsLong(epg, "start_time");
		int duration = Util::GetXmlFirstChildElementTextAsLong(epg, "duration");
		DayMask daymask = (DayMask)Util::GetXmlFirstChildElementTextAsInt(epg, "day_mask");
		bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
		s= new Schedule(scheduleId,channelid,title,starttime,duration,daymask,recordings_to_keep,userParam,forceadd);

	}
	
	if (s != NULL)
	m_scheduleList.push_back(s);

    return false;
  }

  return true;
}
Exemplo n.º 7
0
bool GetObjectResponseSerializer::ContainerXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{

	if (strcmp(element.Name(), "container") == 0) 
	{     
	 std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
	 std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
	 std::string name = Util::GetXmlFirstChildElementText(&element, "name");
	 std::string description = Util::GetXmlFirstChildElementText(&element, "description");
	 std::string logo = Util::GetXmlFirstChildElementText(&element, "logo");
	 dvblinkremote::CONTAINER_TYPE containerType = (dvblinkremote::CONTAINER_TYPE) Util::GetXmlFirstChildElementTextAsInt(&element, "container_type");
	 CONTENT_TYPE contentType = (CONTENT_TYPE) Util::GetXmlFirstChildElementTextAsInt(&element, "content_type");
	 int totalcount = Util::GetXmlFirstChildElementTextAsInt(&element, "total_count");
	 std::string sourceId = Util::GetXmlFirstChildElementText(&element, "source_id");
	 Container * container = new Container(objectId,parentId,name,description,logo,sourceId,containerType,contentType,totalcount);
	 m_containers.push_back(container);

	return false;
	}
	return true;
}
Exemplo n.º 8
0
bool Translator::ReadFirstElement( const char* pszelem, 
	const tinyxml2::XMLElement& container,  
	bool bRequired, bool bDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return bDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required boolean element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return (strcmp( pchild->GetText(),"false")==0);
	}
}
Exemplo n.º 9
0
/** sample ParaEngine mesh xml file
<mesh version=1 type=0>
	<boundingbox minx=0 miny=0 minz=0 maxx=1 maxy=1 maxz=1/>
	<shader index=3/>
	<submesh loddist=10 filename="LOD_10.x"/>
	<submesh loddist=50 filename="LOD_50.x"/>
</mesh>
*/
bool ParaEngine::CParaMeshXMLFile::LoadFromBuffer(const char* pData, int nSize)
{
#ifdef PARAENGINE_MOBILE
    namespace TXML = tinyxml2;
    try
    {
        TXML::XMLDocument doc(true, TXML::COLLAPSE_WHITESPACE);
        doc.Parse(pData, nSize);
        TXML::XMLElement* pRoot = doc.RootElement();
        if (pRoot)
        {
            pRoot->QueryIntAttribute("version", &m_nVersion);
            if (m_nVersion < SUPPORTED_MESH_FILE_VERSION)
            {
                OUTPUT_LOG("can not load para mesh xml file. because of a lower file version.\n");
            }
            int nType = 0;
            pRoot->QueryIntAttribute("type", &nType);
            m_nType = (ParaMeshXMLType)nType;

            for (TXML::XMLNode* pChild = pRoot->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
            {
                TXML::XMLElement* pElement = pChild->ToElement();
                if (pElement)
                {
                    std::string tagName = pElement->Name();
                    if (tagName == "boundingbox")
                    {
                        pElement->QueryFloatAttribute("minx", &m_vMinPos.x);
                        pElement->QueryFloatAttribute("miny", &m_vMinPos.y);
                        pElement->QueryFloatAttribute("minz", &m_vMinPos.z);
                        pElement->QueryFloatAttribute("maxx", &m_vMaxPos.x);
                        pElement->QueryFloatAttribute("maxy", &m_vMaxPos.y);
                        pElement->QueryFloatAttribute("maxz", &m_vMaxPos.z);
                    }
                    else if (tagName == "shader")
                    {
                        pElement->QueryIntAttribute("index", &m_nPrimaryShader);
                        // TODO: for shader parameters
                        for (TXML::XMLNode* pSubChild = pElement->FirstChild(); pSubChild != 0; pSubChild = pSubChild->NextSibling())
                        {
                            TXML::XMLElement* pParamElement = pSubChild->ToElement();
                            if (pParamElement)
                            {
                                std::string tagName = pParamElement->Name();
                                if (tagName == "params")
                                {
                                    CParameter p;
                                    // param name
                                    p.SetName(pParamElement->Attribute("name", ""));
                                    p.SetTypeByString(pParamElement->Attribute("type", ""));
                                    p.SetValueByString(pParamElement->GetText());
                                    m_paramBlock.AddParameter(p);
                                }
                            }
                        }
                    }
                    else if (tagName == "submesh")
                    {
                        CSubMesh meshInfo;
                        pElement->QueryFloatAttribute("loddist", &meshInfo.m_fToCameraDist);
                        std::string filepath = pElement->Attribute("filename");
                        // check if it is relative path or absolute path
                        if (filepath.find('/') != string::npos || filepath.find('\\') != string::npos)
                            meshInfo.m_sFileName = filepath;
                        else
                            meshInfo.m_sFileName = m_sParentDirectory + filepath;
                        m_SubMeshes.push_back(meshInfo);
                    }
                }
            }
        }
    }
    catch (...)
    {
        OUTPUT_LOG("error parsing xml file %s**.xml \n", m_sParentDirectory.c_str());
        return false;
    }
    return m_SubMeshes.size() > 0;
#else
    TiXmlDocument doc;
    try
    {
        doc.Parse(pData, 0, TIXML_DEFAULT_ENCODING);
        TiXmlElement* pRoot =  doc.RootElement();
        {
            // get mesh file version
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/@version");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                const TiXmlAttribute* att = pNodeSet->XAp_get_attribute_in_set(0);
                m_nVersion = att->IntValue();
            }
        }
        if(m_nVersion < SUPPORTED_MESH_FILE_VERSION)
        {
            OUTPUT_LOG("can not load para mesh xml file. because of a lower file version.\n");
        }

        {
            // get mesh type
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/@type");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                const TiXmlAttribute* att = pNodeSet->XAp_get_attribute_in_set(0);
                m_nType = (ParaMeshXMLType)att->IntValue();
            }
        }

        {
            // get mesh bounding box
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/boundingbox");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                const TiXmlElement* pElem = pNodeSet->XNp_get_node_in_set(0)->ToElement();
                // parse attributes
                const TiXmlAttribute* pAttr = pElem->FirstAttribute();
                if (pAttr) {
                    m_bHasBoundingBox = true;
                    for (; pAttr; pAttr = pAttr->Next())
                    {
                        string sName = pAttr->Name();
                        if(sName == "minx")
                        {
                            m_vMinPos.x = (float)(pAttr->DoubleValue());
                        }
                        else if(sName == "miny")
                        {
                            m_vMinPos.y = (float)(pAttr->DoubleValue());
                        }
                        else if(sName == "minz")
                        {
                            m_vMinPos.z = (float)(pAttr->DoubleValue());
                        }
                        else if(sName == "maxx")
                        {
                            m_vMaxPos.x = (float)(pAttr->DoubleValue());
                        }
                        else if(sName == "maxy")
                        {
                            m_vMaxPos.y = (float)(pAttr->DoubleValue());
                        }
                        else if(sName == "maxz")
                        {
                            m_vMaxPos.z = (float)(pAttr->DoubleValue());
                        }
                    }
                }
            }
        }

        {
            // get shader index.
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/shader/@index");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                const TiXmlAttribute* att = pNodeSet->XAp_get_attribute_in_set(0);
                m_nPrimaryShader = att->IntValue();
            }
        }
        {
            // get shader parameters.
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/shader/param");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                int nCount = pNodeSet->u_get_nb_node_in_set();

                for(int i=0; i<nCount; ++i)
                {
                    // for each parameter
                    const TiXmlNode* node = pNodeSet->XNp_get_node_in_set(i);

                    CParameter p;
                    {
                        // param name
                        TinyXPath::xpath_processor xpathProc1(node->ToElement(), "@name");
                        TinyXPath::expression_result res1 = xpathProc1.er_compute_xpath();
                        TinyXPath::node_set* pNodeSet1 = res1.nsp_get_node_set();
                        if(pNodeSet1!=0 && pNodeSet1->u_get_nb_node_in_set()>0)
                        {
                            const TiXmlAttribute* att = pNodeSet1->XAp_get_attribute_in_set(0);
                            p.SetName(att->Value());
                        }
                    }

                    {
                        // get type
                        TinyXPath::xpath_processor xpathProc1(node->ToElement(), "@type");
                        TinyXPath::expression_result res1 = xpathProc1.er_compute_xpath();
                        TinyXPath::node_set* pNodeSet1 = res1.nsp_get_node_set();
                        if(pNodeSet1!=0 && pNodeSet1->u_get_nb_node_in_set()>0)
                        {
                            const TiXmlAttribute* att = pNodeSet1->XAp_get_attribute_in_set(0);
                            p.SetTypeByString(att->Value());
                        }
                    }
                    const TiXmlElement * pParamElement =  node->ToElement();
                    if(pParamElement)
                    {
                        // get text value
                        p.SetValueByString(pParamElement->GetText());
                        m_paramBlock.AddParameter(p);
                    }
                }
            }
        }
        {
            // get mesh info.
            TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/submesh");
            TinyXPath::expression_result res = xpathProc.er_compute_xpath();
            TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
            if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
            {
                int nCount = pNodeSet->u_get_nb_node_in_set();
                m_SubMeshes.resize(nCount);

                for(int i=0; i<nCount; ++i)
                {
                    // for each sub meshes
                    const TiXmlNode* node = pNodeSet->XNp_get_node_in_set(i);

                    CSubMesh& meshInfo = m_SubMeshes[i];

                    {
                        // LOD to camera distance
                        TinyXPath::xpath_processor xpathProc1(node->ToElement(), "@loddist");
                        TinyXPath::expression_result res1 = xpathProc1.er_compute_xpath();
                        TinyXPath::node_set* pNodeSet1 = res1.nsp_get_node_set();
                        if(pNodeSet1!=0 && pNodeSet1->u_get_nb_node_in_set()>0)
                        {
                            const TiXmlAttribute* att = pNodeSet1->XAp_get_attribute_in_set(0);
                            meshInfo.m_fToCameraDist = (float)(att->DoubleValue());
                        }
                    }

                    {
                        // file name of the mesh
                        TinyXPath::xpath_processor xpathProc1(node->ToElement(), "@filename");
                        TinyXPath::expression_result res1 = xpathProc1.er_compute_xpath();
                        TinyXPath::node_set* pNodeSet1 = res1.nsp_get_node_set();
                        if(pNodeSet1!=0 && pNodeSet1->u_get_nb_node_in_set()>0)
                        {
                            const TiXmlAttribute* att = pNodeSet1->XAp_get_attribute_in_set(0);
                            string filepath = att->Value();
                            // check if it is relative path or absolute path
                            if(filepath.find('/')!=string::npos || filepath.find('\\')!=string::npos)
                                meshInfo.m_sFileName = filepath;
                            else
                                meshInfo.m_sFileName = m_sParentDirectory + filepath;
                        }
                    }
                }
            }
        }
    }
    catch (...)
    {
        OUTPUT_LOG("error parsing xml file %s**.xml \n", m_sParentDirectory.c_str());
        return false;
    }
    return true;
#endif
}
Exemplo n.º 10
0
bool GetPlaybackObjectResponseSerializer::PlaybackItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
  if (strcmp(element.Name(), "recorded_tv") == 0 ||
      strcmp(element.Name(), "video") == 0) 
  {
    PlaybackItem* item;
    std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
    std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
    std::string playbackUrl = Util::GetXmlFirstChildElementText(&element, "url");
    std::string thumbnailUrl = Util::GetXmlFirstChildElementText(&element, "thumbnail");    

    if (strcmp(element.Name(), "recorded_tv") == 0) 
    {     
      tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
      RecordedTvItemMetadata* metadata = new RecordedTvItemMetadata();
      ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
      RecordedTvItem* recordedTvitem = new RecordedTvItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);

      if (m_parent.HasChildElement(element, "channel_name")) 
      {
        recordedTvitem->ChannelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
      }

      if (m_parent.HasChildElement(element, "channel_number")) 
      {
        recordedTvitem->ChannelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
      }
      
      if (m_parent.HasChildElement(element, "channel_subnumber")) 
      {
        recordedTvitem->ChannelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
      }

      if (m_parent.HasChildElement(element, "state")) 
      {
        recordedTvitem->State = (RecordedTvItem::DVBLinkRecordedTvItemState)Util::GetXmlFirstChildElementTextAsInt(&element, "state");
      }

      if (m_parent.HasChildElement(element, "schedule_id"))
      {
          recordedTvitem->ScheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
      }

      if (m_parent.HasChildElement(element, "schedule_name"))
      {
          recordedTvitem->ScheduleName = Util::GetXmlFirstChildElementText(&element, "schedule_name");
      }

      if (m_parent.HasChildElement(element, "schedule_series"))
      {
          recordedTvitem->SeriesSchedule = true;
      }

      item = (PlaybackItem*)recordedTvitem;
    }
    else if (strcmp(element.Name(), "video") == 0) 
    {     
      tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
      VideoItemMetadata* metadata = new VideoItemMetadata();
      ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
      VideoItem* videoItem = new VideoItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);
      item = (PlaybackItem*)videoItem;
    }

    if (item) 
    {
      if (m_parent.HasChildElement(element, "can_be_deleted")) 
      {
        item->CanBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
      }

      if (m_parent.HasChildElement(element, "size")) 
      {
        item->Size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
      }

      if (m_parent.HasChildElement(element, "creation_time")) 
      {
        item->CreationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
      }

      m_playbackItemList.push_back(item);
    }
  
    return false;
  }

  return true;
}
Exemplo n.º 11
0
size_t Translator::ReadFirstElement( const char* pszelem, 
		const tinyxml2::XMLElement& container, 
		bool bRequired,  size_t iDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return iDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required unsigned integer element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return atol( pchild->GetText());
	}
}