void initSimpleTable(const Deck& deck, const std::string& keywordName, std::vector<TableType>& tableVector) { if (!deck.hasKeyword(keywordName)) return; // the table is not featured by the deck... if (deck.count(keywordName) > 1) { complainAboutAmbiguousKeyword(deck, keywordName); return; } const auto& tableKeyword = deck.getKeyword(keywordName); for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); ++tableIdx) { const auto& dataItem = tableKeyword.getRecord( tableIdx ).getItem( 0 ); if (dataItem.size() == 0) { // for simple tables, an empty record indicates that the previous table // should be copied... if (tableIdx == 0) { std::string msg = "The first table for keyword "+keywordName+" must be explicitly defined! Ignoring keyword"; OpmLog::warning(Log::fileMessage(tableKeyword.getFileName(), tableKeyword.getLineNumber(), msg)); return; } tableVector.push_back(tableVector.back()); continue; } tableVector.push_back(TableType()); tableVector[tableIdx].init(dataItem); } }
QString MasterGuideTable::toStringXML(uint indent_level) const { QString indent_0 = xml_indent(indent_level); QString indent_1 = xml_indent(indent_level + 1); QString indent_2 = xml_indent(indent_level + 2); QString str = QString("%1<MasterGuideSection table_count=\"%2\" " "global_descriptors_length=\"%3\"\n%4%5>\n") .arg(indent_0) .arg(TableCount()) .arg(GlobalDescriptorsLength()) .arg(indent_1) .arg(PSIPTable::XMLValues(indent_level + 1)); vector<const unsigned char*> gdesc = MPEGDescriptor::Parse(GlobalDescriptors(), GlobalDescriptorsLength()); for (uint i = 0; i < gdesc.size(); i++) { str += MPEGDescriptor(gdesc[i], 300) .toStringXML(indent_level + 1) + "\n"; } if (_ptrs.size() < TableCount()) LOG(VB_GENERAL, LOG_ERR, "MasterGuideTable::toStringXML(): Table count mismatch"); for (uint i = 0; i < TableCount() && i < _ptrs.size(); i++) { str += QString( "%1<Table pid=\"0x%2\" version=\"%3\"" "\n%4type=\"0x%5\" type_desc=\"%6\"" "\n%7number_bytes=\"%8\" table_descriptors_length=\"%9\"") .arg(indent_1) .arg(TablePID(i),4,16,QChar('0')) .arg(TableVersion(i)) .arg(indent_1) .arg(TableType(i),4,16,QChar('0')) .arg(TableClassString(i)) .arg(indent_2) .arg(TableDescriptorsBytes(i)) .arg(TableDescriptorsLength(i)); vector<const unsigned char*> desc = MPEGDescriptor::Parse( TableDescriptors(i), TableDescriptorsLength(i)); str += (desc.empty()) ? " />\n" : ">\n"; for (uint i = 0; i < desc.size(); i++) { str += MPEGDescriptor(desc[i], 300) .toStringXML(indent_level + 2) + "\n"; } if (!desc.empty()) str += indent_1 + "</Table>\n"; } return str + "</MasterGuideSection>"; }
QString MasterGuideTable::toString(void) const { QString str; str.append(QString("Master Guide Section\n%1" " table_count(%2)\n") .arg(PSIPTable::toString()) .arg(TableCount())); if (_ptrs.size() < TableCount()) LOG(VB_GENERAL, LOG_ERR, "MasterGuideTable::toString(): Table count mismatch"); for (uint i = 0; i < TableCount() && i < _ptrs.size(); i++) { str.append(QString(" Table #%1 ").arg(i, 2, 10)); str.append(QString("pid(0x%1) ver(%2) ") .arg(TablePID(i), 0, 16).arg(TableVersion(i), 2, 10)); str.append(QString("size(%1) desc_len(%2) type: %4 %3 \n") .arg(TableDescriptorsBytes(i), 4, 10) .arg(TableDescriptorsLength(i)) .arg(TableClassString(i)).arg(TableType(i))); if (0 != TableDescriptorsLength(i)) { vector<const unsigned char*> desc = MPEGDescriptor::Parse(TableDescriptors(i), TableDescriptorsLength(i)); for (uint i = 0; i < desc.size(); i++) str.append(QString(" %1\n") .arg(MPEGDescriptor(desc[i]).toString())); } } if (0 != GlobalDescriptorsLength()) { str.append(QString(" global descriptors length(%1) ") .arg(GlobalDescriptorsLength())); vector<const unsigned char*> desc = MPEGDescriptor::Parse(GlobalDescriptors(), GlobalDescriptorsLength()); str.append(QString("count: %1\n").arg(desc.size())); for (uint i = 0; i < desc.size(); i++) { str.append(QString(" %1\n") .arg(MPEGDescriptor(desc[i]).toString())); } } return str; }
int MasterGuideTable::TableClass(uint i) const { const int tt = TableType(i); if (tt < 6) { return tt; } else if (tt < 0x300) { if (tt < 0x200) return TableClass::EIT; return TableClass::ETTe; } else if (tt >= 0x1400 && tt < 0x1500) return TableClass::DCCT; else if (tt < 0x400) return TableClass::RRT; return TableClass::UNKNOWN; }
QString MasterGuideTable::toString(void) const { QString str; str.append(QString("MGT: tables(%1)\n").arg(TableCount())); for (uint i = 0; i < TableCount(); i++) { str.append(QString("Table #%1 ").arg(i, 2, 10)); str.append(QString("pid(0x%1) ver(%2) ") .arg(TablePID(i), 0, 16).arg(TableVersion(i), 2, 10)); str.append(QString("size(%1) desc_len(%2) type: %4 %3 \n") .arg(TableDescriptorsBytes(i), 4, 10) .arg(TableDescriptorsLength(i)) .arg(TableClassString(i)).arg(TableType(i))); if (0 != TableDescriptorsLength(i)) { vector<const unsigned char*> desc = MPEGDescriptor::Parse(TableDescriptors(i), TableDescriptorsLength(i)); for (uint i = 0; i < desc.size(); i++) str.append(QString(" %1\n") .arg(MPEGDescriptor(desc[i]).toString())); } } if (0 != GlobalDescriptorsLength()) { str.append(QString("Global descriptors length: %1\n") .arg(GlobalDescriptorsLength())); vector<const unsigned char*> desc = MPEGDescriptor::Parse(GlobalDescriptors(), GlobalDescriptorsLength()); for (uint i = 0; i < desc.size(); i++) str.append(QString(" %1\n") .arg(MPEGDescriptor(desc[i]).toString())); } return str; }
POIImageIdentificationTable:: POIImageIdentificationTable( const ServerTileMapFormatDesc& desc ) { // setup code tables // OBS! strict ordering!, // Do NOT comment out any line. // If a line has to be removed an empty string can take its place // including the cc(); // e.g { ItemTypes::nbr_pointOfInterest, "", cc(), false } CodeCounter cc; struct PreTableType { ItemTypes::pointOfInterest_t m_poiType; ImageName m_image; CodeType m_code; bool m_isUnique; bool m_showInSearches; } types[] = { { ItemTypes::postOffice, "sepostoffice", cc(), false, false }, { ItemTypes::postOffice, "sepostofficebusinesscenter", cc(), false, false }, { ItemTypes::petrolStation, "bestprice", cc(), false, false }, // Add when fixed... { ItemTypes::touristAttraction, "toureiffel", cc(), true, false }, { ItemTypes::postOffice, "stampseller", cc(), false, false }, { ItemTypes::postOffice, "mailbox", cc(), false, false }, { ItemTypes::subwayStation, "germanyberlinsubway", cc(), false, true }, { ItemTypes::subwayStation, "uklondonsubway", cc(), false, true }, { ItemTypes::subwayStation, "franceparissubway", cc(), false, true }, { ItemTypes::subwayStation, "portugallisbonsubway", cc(), false, true }, { ItemTypes::subwayStation, "portugalportosubway", cc(), false, true }, { ItemTypes::subwayStation, "spainmadridsubway", cc(), false, true }, }; const uint32 typesSize = sizeof ( types ) / sizeof ( types[ 0 ] ); // Build the table using the server tile map format desc. // The server tile map format desc is used to fetch the prefix for // images for each poi type. for ( uint32 i = 0; i < typesSize; ++i ) { if ( types[ i ].m_image.empty() ) { continue; } MC2String imageName; const char* imagePrefix = NULL; // first lets see if we need an image. // i.e if the image is a unique image we dont want prefix. if ( types[ i ].m_isUnique ) { imageName = types[ i ].m_image; } else { // setup image name and prefix imagePrefix = desc.getPOIImageName( types[ i ].m_poiType ); imageName = "_" + types[ i ].m_image; } m_images.push_back( TableType( types[ i ].m_poiType, imageName, imagePrefix, types[ i ].m_code, types[ i ].m_showInSearches ) ); } sort( m_images.begin(), m_images.end(), SortByImageNameAndPOI() ); // fill upp codes with default data; 0, 1, 2, 3, 4 ... n // and then sort it according to code in TableType. m_codes.resize( m_images.size() ); generate( m_codes.begin(), m_codes.end(), STLUtility::Counter<uint32>( 0 ) ); // this must be done after sorting of images. sort( m_codes.begin(), m_codes.end(), SortByCode( m_images ) ); // setup the code index in the image table. for ( uint32 i = 0; i < m_codes.size(); ++i ) { m_images[ m_codes[ i ] ].setCodeIndex( i ); } }