本文整理汇总了C++中NameMap类的典型用法代码示例。如果您正苦于以下问题:C++ NameMap类的具体用法?C++ NameMap怎么用?C++ NameMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NameMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteNameMap
void VerilatedVcd::makeNameMap() {
// Take signal information from each module and build m_namemapp
deleteNameMap();
m_nextCode = 1;
m_namemapp = new NameMap;
for (vluint32_t ent = 0; ent< m_callbacks.size(); ent++) {
VerilatedVcdCallInfo *cip = m_callbacks[ent];
cip->m_code = nextCode();
(cip->m_initcb) (this, cip->m_userthis, cip->m_code);
}
// Though not speced, it's illegal to generate a vcd with signals
// not under any module - it crashes at least two viewers.
// If no scope was specified, prefix everything with a "top"
// This comes from user instantiations with no name - IE Vtop("").
bool nullScope = false;
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
const char* hiername = (*it).first.c_str();
if (hiername[0] == '\t') nullScope=true;
}
if (nullScope) {
NameMap* newmapp = new NameMap;
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
const string& hiername = it->first;
const string& decl = it->second;
string newname = string("top");
if (hiername[0] != '\t') newname += ' ';
newname += hiername;
newmapp->insert(make_pair(newname,decl));
}
deleteNameMap();
m_namemapp = newmapp;
}
}
示例2: MakeFileList
bool ArcApp::Create()
{
// turn m_args into a list of files, i.e. expand wildcards, recurse
// directories and remove duplicates
NameMap files;
MakeFileList(files);
wxOutputStreamPtr out(MakeOutputStream());
if (!out.get()) return false;
wxArchiveOutputStreamPtr arc(m_factory->NewStream(*out));
for (NameMap::iterator it = files.begin(); it != files.end(); ++it) {
wxString name = it->second;
wxDateTime dt(wxFileModificationTime(name));
*m_info << "adding " << name.mb_str() << std::endl;
if (wxDirExists(name)) {
if (!arc->PutNextDirEntry(name, dt))
return false;
}
else {
wxFFileInputStream in(name);
if (in.Ok()) {
if (!arc->PutNextEntry(name, dt, in.GetSize()) ||
!arc->Write(in) || !in.Eof())
return false;
}
}
}
return arc->Close() && out->Close();
}
示例3: bitch_about_junk_files
void bitch_about_junk_files(const NameMap &junk) {
if (junk.size()) {
if (junk.size() == 1) {
FAIL() << "Junk file \"" << junk.begin()->first << '"';
} else {
FAIL() << "Found " << junk.size() << " junk files, including "
<< '"' << junk.begin()->first << '"';
}
}
}
示例4: user_list
void
user_list(void)
{
NameMap users;
ServerPrx server;
server = meta->getServer(serverId, ctx);
users = server->getRegisteredUsers("", ctx);
for (NameMap::iterator ii=users.begin(); ii != users.end(); ii++)
cout << setw(8) << right << (*ii).first << " " << left << (*ii).second << endl;
}
示例5: lookupHash
virtual void lookupHash(const URI &namedUri, const Callback &cb) {
{
boost::shared_lock<boost::shared_mutex> lookuplock(mMut);
NameMap::const_iterator iter = mLookupCache.find(namedUri);
if (iter != mLookupCache.end()) {
RemoteFileId rfid ((*iter).second); // copy, because the map could change.
lookuplock.unlock();
cb(namedUri, &rfid);
return;
}
}
NameLookupManager::lookupHash(namedUri, cb);
}
示例6: directoryContents
StringList AbstractFileManager::resolveSearchpaths(const String& rootPath, const StringList& searchPaths) {
typedef std::map<String, String> NameMap;
NameMap nameMap;
StringList contents = directoryContents(rootPath, "", true, false);
for (size_t i = 0; i < contents.size(); i++)
nameMap[Utility::toLower(contents[i])] = contents[i];
StringList result;
for (size_t i = 0; i < searchPaths.size(); i++) {
NameMap::iterator it = nameMap.find(Utility::toLower(searchPaths[i]));
if (it != nameMap.end())
result.push_back(appendPath(rootPath, it->second));
}
return result;
}
示例7: printContributors
void printContributors(const std::string& changeLog, bool printNumEntries)
{
NameMap names;
buildContributors(names);
if (!changeLog.empty())
{
readContributors(names, changeLog);
}
typedef multimap<unsigned int, NamePair> SortedNameMap;
SortedNameMap sortedNames;
for (NameMap::iterator itr = names.begin(); itr != names.end(); ++itr)
{
sortedNames.insert(SortedNameMap::value_type(itr->second, itr->first));
}
cout << names.size() << " Contributors:" << endl << endl;
if (printNumEntries)
{
cout << "Entries Firstname Surname" << endl;
cout << "-------------------------" << endl;
for (SortedNameMap::reverse_iterator sitr = sortedNames.rbegin(); sitr != sortedNames.rend(); ++sitr)
{
cout << sitr->first << "\t" << sitr->second.first;
if (!sitr->second.second.empty()) cout << " " << sitr->second.second;
cout << endl;
}
}
else
{
cout << "Firstname Surname" << endl;
cout << "-----------------" << endl;
for (SortedNameMap::reverse_iterator sitr = sortedNames.rbegin(); sitr != sortedNames.rend(); ++sitr)
{
cout << sitr->second.first;
if (!sitr->second.second.empty()) cout << " " << sitr->second.second;
cout << endl;
}
}
}
示例8: outputMAE
void OutputInfo::outputMAE(InputData* pData)
{
const int numExamples = pData->getNumExamples();
table& g = _gTableMap[pData];
vector<Label>::const_iterator lIt,maxlIt,truelIt;
float maxDiscriminant,mae = 0.0,mse = 0.0,tmpVal;
char maxLabel;
// Get label values: they must be convertible to float
vector<float> labelValues;
NameMap classMap = pData->getClassMap();
for (int l = 0;l < classMap.getNumNames(); ++l)
labelValues.push_back(atof(classMap.getNameFromIdx(l).c_str()));
// Building the strong learner (discriminant function)
for (int i = 0; i < numExamples; ++i){
const vector<Label>& labels = pData->getLabels(i);
maxDiscriminant = -numeric_limits<float>::max();
maxLabel = -100;
for (lIt = labels.begin(); lIt != labels.end(); ++lIt ) {
if ( g[i][lIt->idx] > maxDiscriminant ) {
maxDiscriminant = g[i][lIt->idx];
maxlIt = lIt;
}
if ( lIt->y > maxLabel ) {
maxLabel = lIt->y;
truelIt = lIt;
}
}
tmpVal = labelValues[truelIt->idx] - labelValues[maxlIt->idx];
mae += fabs(tmpVal);
mse += tmpVal * tmpVal;
}
_outStream << '\t' << mae/(float)(numExamples) << '\t' << sqrt(mse/(float)(numExamples));
}
示例9: readContributors
void readContributors(NameMap& names, const string& file)
{
osgDB::ifstream fin(file.c_str());
Words words;
while(fin)
{
string keyword;
fin >> keyword;
words.push_back(keyword);
}
string blank_string;
for(unsigned int i = 0; i < words.size(); ++i)
{
if (submissionsSequence(words, i))
{
if (i + 2 < words.size() && validName(words[i + 1]))
{
NamePair name = createName(words[i + 1], words[i + 2]);
nameCorrection(name);
if (!name.first.empty()) ++names[name];
i += 2;
}
else if (i + 1 < words.size() && validName(words[i + 1]))
{
NamePair name = createName(words[i + 1], blank_string);
nameCorrection(name);
if (!name.first.empty()) ++names[name];
i += 1;
}
}
else
{
if (words[i] == "robert")
{
++names[NameRobertOsfield];
}
else if (words[i] == "don")
{
++names[NameDonBurns];
}
}
}
// reassign fisrt name entries to their full names entries
if (names.size() > 1)
{
for (NameMap::iterator itr = names.begin(); itr != names.end(); )
{
if (itr->first.second.empty())
{
NameMap::iterator next_itr = itr;
++next_itr;
if (next_itr != names.end() && itr->first.first == next_itr->first.first)
{
next_itr->second += itr->second;
names.erase(itr);
itr = next_itr;
}
else
{
++itr;
}
}
else
{
++itr;
}
}
}
// remove the double entries from Robert's contributions
if (names.size() > 1)
{
for (NameMap::iterator itr = names.begin(); itr != names.end(); ++itr)
{
if (itr->first != NameRobertOsfield && itr->first != NameDonBurns)
{
names[NameRobertOsfield] -= itr->second;
}
}
}
}
示例10: MakeRelationGraphR
RelationGraphR* MakeRelationGraphR(string &inputFile){
ifstream myfile(inputFile.c_str());
if (myfile.is_open()){
string line;
getline (myfile,line);
int numDomains = atoi(line.c_str()); //get the number of domains
getline (myfile,line);
int numContexts = atoi(line.c_str()); //get the number of contexts
if(numContexts + 1 != numDomains) {
string errMsg = "Number of domains and number of contexts are not consistent";
Error(errMsg);
}
vector<string> domainNames;
map<string,int> domainName_id_map;
map<int,int> domainId_size_map; //map domain number to number of elements
vector<NameMap*> nameMaps;
//get set names and thier name files
for(int i=0; i < numDomains; i++){
getline(myfile,line); //this is the domain name
//the line is split into name and number of elements
vector<string> tkns;
Tokenize(line, tkns, ";");
//first token is name of domain
domainNames.push_back(tkns[0]);
//second token is number of elements
domainId_size_map[i+1] = atoi(tkns[1].c_str());
domainName_id_map[tkns[0]]=i+1;
getline(myfile,line); //this is the path to the namefile
NameMap *nmp = new NameMap(line,atoi(tkns[1].c_str()));
nmp->SetId(i+1);
nameMaps.push_back(nmp);
}
//now get contexts and relation graph
RelationGraphR *grph = new RelationGraphR();
for(int i=0; i < numContexts; i++){
getline(myfile,line); //this line specifies the two domains
vector<string> currDomainNames;
string ctxName;
Tokenize(line,currDomainNames,"--");
int dId1 = domainName_id_map[currDomainNames[0]];
//check if a new element was inserted indicating an error
if(domainName_id_map.size() > numDomains) {
string errMsg = "Error specifying context..."+currDomainNames[0]+" does not match any previoulsy defined domain";
Error(errMsg);
}
int dId2 = domainName_id_map[currDomainNames[1]];
//check if a new element was inserted indicating an error
if(domainName_id_map.size() > numDomains) {
string errMsg = "Error specifying context..."+currDomainNames[1]+" does not match any previoulsy defined domain";
Error(errMsg);
}
ctxName = currDomainNames[0]+"__"+currDomainNames[1];
getline(myfile,line); //this line specifies the fimi file
grph->AddRContext(MakeRContext(line,dId1,dId2,ctxName,i+1,nameMaps[dId1-1],nameMaps[dId2-1], domainId_size_map[dId1],domainId_size_map[dId2]));
}
myfile.close();
return grph;
}
else{
string errMsg="Could not open the input file: "+inputFile;
Error(errMsg);
}
}
示例11: while
//.........这里部分代码省略.........
}
int mission_num;
if(link)
{
gLogger->logMsgF("MissionManager : found db destroy missions",MSG_HIGH);
//now set the stf
char s[255];
sprintf(s,"mission/%s",link->missiontype->stf.getAnsi());
mission->setTitleFile(s);
//the mission within the stf
mission_num = (gRandom->getRand() % link->content)+1;
mission->setNum(mission_num);
//Mission Title
sprintf(mt,"m%dt",mission_num);
mission->setTitle(mt);
//Mission Description
sprintf(md,"m%dd",mission_num);
mission->setDetailFile(s);
mission->setDetail(md);
//still have to sort out the names of the mission givers
}
else
{
gLogger->logMsgF("MissionManager : No mission file associated :(",MSG_HIGH);
return NULL;
}
missionTargets missionTarget[4] =
{
{0xB9BA5440, "@lair_n:naboo_otolla_gungan_camp_neutral_large_theater"},
{0x6D4C33E5, "@lair_n:naboo_capper_spineflap_nest_neutral_large"},
{0xA0057DAE, "@lair_n:naboo_kaadu_lair_neutral_medium_boss_01"},
{0xFA6FD53A, "@lair_n:lair_base"},
};
//Randomly choose a target
int target = gRandom->getRand() % 4;
//END TEMP
//Position
//int radius = 500; //500m radius
Location destination;
glm::vec3 new_vector = glm::gtx::random::vecRand3(50.0f, 500.0f);
new_vector.y = 0;
destination.Coordinates = mission->getOwner()->mPosition + new_vector;
destination.CellID = 0;
destination.PlanetCRC = BString(gWorldManager->getPlanetNameThis()).getCrc();
mission->setDestination(destination);
//Creator
sprintf(mo,"m%do",mission_num);
string moS(mo);
gLogger->logMsgF("MissionManager : creator :%s",MSG_HIGH,moS.getAnsi());
NameMap nameMap = link->missiontype->names;
NameMap::iterator NameMapIt = nameMap.find(moS.getCrc());
if(NameMapIt != nameMap.end())
{
sprintf(mo,"%s",(*NameMapIt).second->name.getAnsi());
mission->setCreator(mo);
//mo = (*NameMapIt).second->name.getAnsi();
}
else
{
uint32 selected = gRandom->getRand() % this->mNameMap.size();
NameMap::iterator it = mNameMap.find(selected);
mission->setCreator((*it).second->name.getAnsi());
}
//Difficulty
mission->setDifficulty((gRandom->getRand() % 90)+5);
//Payment
mission->setReward((gRandom->getRand() % 10000)+1000);
//Target
mission->setTargetModel(missionTarget[target].crc);
mission->setTarget(missionTarget[target].name);
return mission;
}
示例12: locale
void ArffParser::readHeader( ifstream& in, NameMap& classMap,
vector<NameMap>& enumMaps, NameMap& attributeNameMap,
vector<RawData::eAttributeType>& attributeTypes )
{
bool isData = false;
string tmpStr;
string tmpAttrType;
locale labelsLocale = locale(locale(), new nor_utils::white_spaces("{,}"));
while ( !isData )
{
switch ( getNextTokenType(in) )
{
case TT_DATA:
isData = true;
break;
case TT_COMMENT:
getline(in, tmpStr); // ignore line
break;
case TT_RELATION:
in >> _headerFileName;
break;
case TT_ATTRIBUTE:
in >> tmpStr;
if ( nor_utils::cmp_nocase(tmpStr, "class") )
{
// It's a class!!
char firstChar = 0;
while ( isspace(firstChar = in.get()) && !in.eof() );
in.putback(firstChar);
getline(in, tmpStr);
stringstream ss(tmpStr);
ss.imbue(labelsLocale);
// read the classes
for (;;)
{
ss >> tmpStr;
if ( ss.eof() )
break;
tmpStr = nor_utils::trim(tmpStr);
if (!tmpStr.empty())
classMap.addName(tmpStr);
}
in.putback( '\n' );
}
else if ( nor_utils::cmp_nocase(tmpStr.substr(0,5), "class") )
{
classMap.addName(tmpStr.substr(5));
_hasAttributeClassForm = true;
}
else
{
NameMap enumMap;
in >> tmpAttrType;
if ( nor_utils::cmp_nocase(tmpAttrType, "numeric") ||
nor_utils::cmp_nocase(tmpAttrType, "real") ||
nor_utils::cmp_nocase(tmpAttrType, "integer") )
{
attributeNameMap.addName(tmpStr);
attributeTypes.push_back(RawData::ATTRIBUTE_NUMERIC);
}
else if ( nor_utils::cmp_nocase(tmpAttrType, "string") )
{
if (attributeNameMap.getNumNames() == 0)
_hasName = true;
else
{
cerr << "ERROR: One can specify the name of an example only as the first attribute, otherwise string types are not supported!!" << endl;
exit(1);
}
}
else
{
// enum attributeTypes
// For the time being the enumeration cannot contain spaces, we should
// correct it.
if (tmpAttrType[0] == '{')
{
attributeNameMap.addName(tmpStr);
attributeTypes.push_back(RawData::ATTRIBUTE_ENUM);
stringstream ss(tmpAttrType);
ss.imbue(labelsLocale);
for (;;)
{
ss >> tmpAttrType;
if ( ss.eof() )
break;
tmpAttrType = nor_utils::trim(tmpAttrType);
if (!tmpAttrType.empty())
enumMap.addName(tmpAttrType);
}
}
//.........这里部分代码省略.........
示例13: addToCache
virtual void addToCache(const URI &origNamedUri, const RemoteFileId &toFetch) {
boost::unique_lock<boost::shared_mutex> updatecache(mMut);
mLookupCache.insert(NameMap::value_type(origNamedUri, toFetch));
}
示例14: VFS_Archive_CreateFromFileList
// Create an Archive from the specified File List.
VFS_BOOL VFS_Archive_CreateFromFileList( const VFS_String& strArchiveFileName, const VFS_FileNameMap& Files, const VFS_FilterNameList& UsedFilters )
{
static VFS_BYTE Chunk[ FILE_COPY_CHUNK_SIZE ];
// If there's already an Archive with the same File Name and it's open...
VFS_EntityInfo Info;
if( VFS_Archive_GetInfo( ToLower( strArchiveFileName ), Info ) )
{
// Check if the Archive is open.
if( GetOpenArchives().find( ToLower( Info.strPath ) ) != GetOpenArchives().end() )
{
// Check if the Reference Count is != 0.
if( GetOpenArchives()[ ToLower( Info.strPath ) ]->GetRefCount() > 0 )
{
// We don't want to manipulate an open Archive, do we?
SetLastError( VFS_ERROR_IN_USE );
return VFS_FALSE;
}
else
{
// Free the Archive.
delete GetOpenArchives()[ ToLower( Info.strPath ) ];
GetOpenArchives().erase( ToLower( Info.strPath ) );
}
}
}
else
{
Info.strPath = ToLower( strArchiveFileName );
SetLastError( VFS_ERROR_NONE );
}
// Check the Filter Names and make a List of all Filter Pointers.
VFS_FilterList Filters;
for( VFS_FilterNameList::const_iterator iter = UsedFilters.begin(); iter != UsedFilters.end(); iter++ )
{
// Bad Filter Name?
if( !VFS_ExistsFilter( *iter ) )
{
SetLastError( VFS_ERROR_INVALID_PARAMETER );
return VFS_FALSE;
}
// Add the Filter.
Filters.push_back( VFS_GetFilter( *iter ) );
}
// Check all Files.
for( VFS_FileNameMap::const_iterator iter2 = Files.begin(); iter2 != Files.end(); iter2++ )
{
if( !VFS_File_Exists( ( *iter2 ).first ) )
{
SetLastError( VFS_ERROR_NOT_FOUND );
return VFS_FALSE;
}
VFS_String strName;
VFS_Util_GetName( ( *iter2 ).second, strName );
if( strName.size() > VFS_MAX_NAME_LENGTH )
{
SetLastError( VFS_ERROR_INVALID_PARAMETER );
return VFS_FALSE;
}
}
// Make a list of the Directories to create.
typedef vector< VFS_String > NameMap;
NameMap Dirs;
for( VFS_FileNameMap::const_iterator iter3 = Files.begin(); iter3 != Files.end(); iter3++ )
{
VFS_String strDir;
VFS_Util_GetPath( ( *iter3 ).second, strDir );
strDir = ToLower( strDir );
if( strDir != VFS_TEXT( "" ) && find( Dirs.begin(), Dirs.end(), strDir ) == Dirs.end() )
{
// Add the top-level Dirs.
while( strDir.rfind( VFS_PATH_SEPARATOR ) != VFS_String::npos )
{
if( find( Dirs.begin(), Dirs.end(), strDir ) != Dirs.end() )
break;
Dirs.push_back( ToLower( strDir ) );
if( strDir.size() > VFS_MAX_NAME_LENGTH )
{
SetLastError( VFS_ERROR_INVALID_PARAMETER );
return VFS_FALSE;
}
strDir = strDir.substr( 0, strDir.rfind( VFS_PATH_SEPARATOR ) );
}
if( find( Dirs.begin(), Dirs.end(), strDir ) == Dirs.end() )
{
Dirs.push_back( ToLower( strDir ) );
if( strDir.size() > VFS_MAX_NAME_LENGTH )
{
SetLastError( VFS_ERROR_INVALID_PARAMETER );
return VFS_FALSE;
}
}
//.........这里部分代码省略.........
示例15: pop
void pop(const State& offset)
{
variables.pop(offset[0]);
typedefs.pop(offset[1]);
generics.pop(offset[2]);
}