eitd/SIevents.cpp: change SIcomponents and SIparentalRatings from set to vector -

no need to sort them, this decrease SIevent size
This commit is contained in:
[CST] Focus
2012-05-29 16:32:07 +04:00
parent ace0f4828b
commit 01f50bba06
3 changed files with 19 additions and 8 deletions

View File

@@ -176,14 +176,16 @@ void SIevent::parse(Event &event)
std::transform(lang.begin(), lang.end(), lang.begin(), tolower); std::transform(lang.begin(), lang.end(), lang.begin(), tolower);
int table = getCountryCodeDefaultMapping(lang); int table = getCountryCodeDefaultMapping(lang);
c.component = stringDVBUTF8(d->getText(), table, tsidonid); c.component = stringDVBUTF8(d->getText(), table, tsidonid);
components.insert(c); //components.insert(c);
components.push_back(c);
} }
else if(dtype == PARENTAL_RATING_DESCRIPTOR) { else if(dtype == PARENTAL_RATING_DESCRIPTOR) {
const ParentalRatingDescriptor *d = (ParentalRatingDescriptor*) *dit; const ParentalRatingDescriptor *d = (ParentalRatingDescriptor*) *dit;
const ParentalRatingList *plist = d->getParentalRatings(); const ParentalRatingList *plist = d->getParentalRatings();
for (ParentalRatingConstIterator it = plist->begin(); it != plist->end(); ++it) { for (ParentalRatingConstIterator it = plist->begin(); it != plist->end(); ++it) {
SIparentalRating p((*it)->getCountryCode(), (*it)->getRating()); SIparentalRating p((*it)->getCountryCode(), (*it)->getRating());
ratings.insert(p); //ratings.insert(p);
ratings.push_back(p);
} }
} }
else if(dtype == LINKAGE_DESCRIPTOR) { else if(dtype == LINKAGE_DESCRIPTOR) {
@@ -312,7 +314,8 @@ void SIevent::parseContentDescriptor(const uint8_t *buf, unsigned maxlen)
void SIevent::parseComponentDescriptor(const uint8_t *buf, unsigned maxlen) void SIevent::parseComponentDescriptor(const uint8_t *buf, unsigned maxlen)
{ {
if(maxlen>=sizeof(struct descr_component_header)) if(maxlen>=sizeof(struct descr_component_header))
components.insert(SIcomponent((const struct descr_component_header *)buf)); components.push_back(SIcomponent((const struct descr_component_header *)buf));
//components.insert(SIcomponent((const struct descr_component_header *)buf));
} }
void SIevent::parseParentalRatingDescriptor(const uint8_t *buf, unsigned maxlen) void SIevent::parseParentalRatingDescriptor(const uint8_t *buf, unsigned maxlen)
@@ -322,7 +325,8 @@ void SIevent::parseParentalRatingDescriptor(const uint8_t *buf, unsigned maxlen)
return; return;
const uint8_t *s=buf+sizeof(struct descr_generic_header); const uint8_t *s=buf+sizeof(struct descr_generic_header);
while(s<buf+sizeof(struct descr_generic_header)+cont->descriptor_length-4) { while(s<buf+sizeof(struct descr_generic_header)+cont->descriptor_length-4) {
ratings.insert(SIparentalRating(std::string((const char *)s, 3), *(s+3))); //ratings.insert(SIparentalRating(std::string((const char *)s, 3), *(s+3)));
ratings.push_back(SIparentalRating(std::string((const char *)s, 3), *(s+3)));
s+=4; s+=4;
} }
} }
@@ -336,7 +340,7 @@ void SIevent::parseLinkageDescriptor(const uint8_t *buf, unsigned maxlen)
char SIevent::getFSK() const char SIevent::getFSK() const
{ {
for (SIparentalRatings::iterator it = ratings.begin(); it != ratings.end(); ++it) for (SIparentalRatings::const_iterator it = ratings.begin(); it != ratings.end(); ++it)
{ {
if (it->countryCode == "DEU") if (it->countryCode == "DEU")
{ {

View File

@@ -224,7 +224,8 @@ class SIcomponent
} }
}; };
typedef std::multiset <SIcomponent, std::less<SIcomponent> > SIcomponents; //typedef std::multiset <SIcomponent, std::less<SIcomponent> > SIcomponents;
typedef std::vector <SIcomponent> SIcomponents;
// Fuer for_each // Fuer for_each
struct printSIcomponent : public std::unary_function<class SIcomponent, void> struct printSIcomponent : public std::unary_function<class SIcomponent, void>
@@ -272,7 +273,8 @@ class SIparentalRating
(countryCode != p.countryCode); (countryCode != p.countryCode);
} }
}; };
typedef std::set <SIparentalRating, std::less<SIparentalRating> > SIparentalRatings; //typedef std::set <SIparentalRating, std::less<SIparentalRating> > SIparentalRatings;
typedef std::vector <SIparentalRating> SIparentalRatings;
// Fuer for_each // Fuer for_each
struct printSIparentalRating : public std::unary_function<SIparentalRating, void> struct printSIparentalRating : public std::unary_function<SIparentalRating, void>

View File

@@ -369,12 +369,17 @@ void *insertEventsfromFile(void * data)
c.componentType = xmlGetNumericAttribute(node, "type", 16); c.componentType = xmlGetNumericAttribute(node, "type", 16);
c.componentTag = xmlGetNumericAttribute(node, "tag", 16); c.componentTag = xmlGetNumericAttribute(node, "tag", 16);
c.component = std::string(xmlGetAttribute(node, "text")); c.component = std::string(xmlGetAttribute(node, "text"));
e.components.insert(c); //e.components.insert(c);
e.components.push_back(c);
node = node->xmlNextNode; node = node->xmlNextNode;
} }
while (xmlGetNextOccurence(node, "parental_rating") != NULL) { while (xmlGetNextOccurence(node, "parental_rating") != NULL) {
#if 0
e.ratings.insert(SIparentalRating(std::string(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "country"))), e.ratings.insert(SIparentalRating(std::string(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "country"))),
(unsigned char) xmlGetNumericAttribute(node, "rating", 10))); (unsigned char) xmlGetNumericAttribute(node, "rating", 10)));
#endif
e.ratings.push_back(SIparentalRating(std::string(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "country"))),
(unsigned char) xmlGetNumericAttribute(node, "rating", 10)));
node = node->xmlNextNode; node = node->xmlNextNode;
} }
while (xmlGetNextOccurence(node, "linkage") != NULL) { while (xmlGetNextOccurence(node, "linkage") != NULL) {