本文整理汇总了C++中NameCollection类的典型用法代码示例。如果您正苦于以下问题:C++ NameCollection类的具体用法?C++ NameCollection怎么用?C++ NameCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NameCollection类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFilenamesForCoordinate
const NameCollection CoordModelMapping::getFilenamesForCoordinate(unsigned int pMapId, int xPos, int yPos)
{
NameCollection result;
Array<std::string> rawNames;
CMappingEntry *entry = getCMappingEntry(CMappingEntry::getKeyString(pMapId, xPos, yPos));
if(entry != 0)
{
rawNames = entry->getFilenames();
int pos = 0;
while(pos < rawNames.size())
{
char namebuffer[500];
int noVerc;
int startName = findPosChar(rawNames[pos].c_str(), ' ', 1) + 1;
int endName = (int) rawNames[pos].length();
sscanf(rawNames[pos].c_str(), "%d", &noVerc);
memcpy(namebuffer, &rawNames[pos].c_str()[startName], endName-startName);
namebuffer[endName-startName] = 0;
sscanf(rawNames[pos].c_str(), "%d", &noVerc);
std::string modelPosFileName = std::string(namebuffer);
if(noVerc > MIN_VERTICES_FOR_OWN_CONTAINER_FILE)
{
result.appendToSingle(modelPosFileName);
}
else
{
result.appendToMain(modelPosFileName);
}
++pos;
}
}
return result;
}
示例2: reserve
NameCollection::NameCollection(const NameCollection& other)
{
reserve( other.size() );
for( const_iterator it = other.begin();
it != other.end();
++it ) {
push_back( new Name(**it) );
}
}
示例3: MC2_ASSERT
void
MapModuleNoticeContainer::loadMapSupCoverage( DataBuffer* db ){
MC2_ASSERT(db != NULL);
// Read number of elements
uint32 nbrElements = db->readNextLong();
for (uint32 i=0; i<nbrElements; i++){
// Read bounding box
uint32 maxLat = db->readNextLong();
uint32 minLat = db->readNextLong();
uint32 maxLon = db->readNextLong();
uint32 minLon = db->readNextLong();
MC2BoundingBox bBox;
bBox.setMaxLat(maxLat);
bBox.setMinLat(minLat);
bBox.setMaxLon(maxLon);
bBox.setMinLon(minLon);
// Read supplier name.
MapGenEnums::mapSupplier mapSupplier =
static_cast<MapGenEnums::mapSupplier>(db->readNextLong());
m_mapSupCoverage.push_back(make_pair(bBox, mapSupplier));
}
mc2dbg << "[MMNC]: Loaded " << m_mapSupCoverage.size()
<< " map supplier coverage bounding boxes." << endl;
// Read coverage tree.
nbrElements = db->readNextLong();
m_mapSupCoverageTree.reserve(nbrElements);
for (uint32 i=0; i<nbrElements; i++){
uint32 parent = db->readNextLong();
uint32 child = db->readNextLong();
m_mapSupCoverageTree.push_back(make_pair(parent, child));
}
MC2_ASSERT(m_mapSupCoverageTree.size() == nbrElements);
// Load map supplier names.
uint32 nbrToRead = db->readNextLong();
for (uint32 i=0; i<nbrToRead; i++){
NameCollection tmpNames;
MapGenEnums::mapSupplier mapSup =
static_cast<MapGenEnums::mapSupplier>(db->readNextLong());
tmpNames.load(db);
m_mapSupNamesByMapSup.insert(make_pair(mapSup, tmpNames));
}
mc2dbg << "[MMNC]: Loaded " << m_mapSupNamesByMapSup.size()
<< " map supplier names." << endl;
} // MapModuleNoticeContainer::loadMapSupCoverage
示例4: fopen
//=================================================================
bool TileAssembler::convertWorld()
{
#ifdef _ASSEMBLER_DEBUG
# ifdef _DEBUG
::g_df = fopen("../TileAssembler_debug.txt", "wb");
# else
::g_df = fopen("../TileAssembler_release.txt", "wb");
# endif
#endif
bool result = true;
printf("Reading coordinate mappings...\n");
std::string fname = iSrcDir;
fname.append("/");
fname.append("dir");
iCoordModelMapping->setModelNameFilterMethod(iFilterMethod);
iCoordModelMapping->readCoordinateMapping(fname);
Array<unsigned int> mapIds = iCoordModelMapping->getMaps();
if(mapIds.size() == 0)
{
result = false;
}
for(int i=0; i<mapIds.size() && result; ++i)
{
unsigned int mapId = mapIds[i];
printf("Converting map %lu...\n", mapId);
#ifdef _ASSEMBLER_DEBUG
if(mapId == 0) // "Azeroth" just for debug
{
for(int x=28; x<29 && result; ++x) //debug
{
for(int y=28; y<29 && result; ++y)
{
#else
// ignore DeeprunTram (369) it is too large for short vector and not important
// ignore test (13), Test (29) , development (451)
if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451)
{
for(int x=0; x<66 && result; ++x)
{
for(int y=0; y<66 && result; ++y)
{
#endif
printf("Converting cell [%lu][%lu] on map %lu...\n", x, y, mapId);
Array<ModelContainer*> mc;
std::string dirname;
char buffer[100];
if(iCoordModelMapping->isWorldAreaMap(mapId) && x<65 && y<65)
{
sprintf(buffer, "%03u_%d_%d",mapId,x,y); // Let's flip x and y here
dirname = std::string(buffer);
}
else
{
sprintf(buffer, "%03u",mapId);
dirname = std::string(buffer);
}
result = fillModelContainerArray(dirname, mapId, x, y, mc);
emptyArray(mc);
}
}
}
}
#ifdef _ASSEMBLER_DEBUG
if(::g_df) fclose(::g_df);
#endif
return result;
}
//=================================================================
bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC)
{
bool result = true;
ModelContainer* modelContainer;
NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos);
if(nameCollection.size() > 0)
{
result = false;
char dirfilename[500];
sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str());
FILE *dirfile = fopen(dirfilename, "ab");
if(dirfile)
{
result = true;
char destnamebuffer[500];
char fullnamedestnamebuffer[500];
if(nameCollection.iMainFiles.size() >0)
{
sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pXPos, pYPos); // flip it here too
std::string checkDoubleStr = std::string(dirfilename);
checkDoubleStr.append("##");
checkDoubleStr.append(std::string(destnamebuffer));
// Check, if same file already is in the same dir file
if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
//.........这里部分代码省略.........
示例5: X
bool
XMLIndata::parseName( const DOMNode* name,
NameCollection& names )
{
if ( XMLString::equals( name->getNodeName(), "name" ) ) {
// Get attributes
DOMNamedNodeMap* attributes = name->getAttributes();
LangTypes::language_t lang;
ItemTypes::name_t nameType;
// Note that language attribute is #REQUIRED.
DOMNode* attribute =
attributes->getNamedItem( X( "language" ) );
MC2_ASSERT( attribute != NULL );
MC2String langStr =
XMLUtility::transcodefromucs(attribute->getNodeValue() );
// Replace any occurance of '_' with space.
for (MC2String::iterator strIt = langStr.begin();
strIt != langStr.end(); ++strIt){
if ( *strIt == '_' ){
*strIt = ' ';
}
}
lang = LangTypes::getStringAsLanguage( langStr.c_str(), true );
if ( lang == LangTypes::invalidLanguage ){
mc2log << error << "Could not interpret language code of string"
<< endl;
MC2_ASSERT(false);
}
// Note that type attribute is always present.
attribute =
attributes->getNamedItem( X( "type" ) );
MC2_ASSERT( attribute != NULL );
const char* tmpStr = XMLUtility::transcodefromucs(
attribute->getNodeValue() );
nameType = ItemTypes::getStringAsNameType( tmpStr );
delete [] tmpStr;
// Get the name.
tmpStr = XMLUtility::getChildTextValue( name );
// Add name
Name* tmpName = new Name( tmpStr, lang, nameType );
names.addName( tmpName );
mc2dbg << "Added name: " << (*tmpName) << endl;
mc2dbg8 << "All names: " << names << endl;
delete tmpStr;
return true;
} else {
// Not a name node.
mc2log << warn
<< "XMLIndata::parseName:"
<< " not a name node."
<< name->getNodeName() << endl;
return false;
}
}