本文整理汇总了C++中GMap类的典型用法代码示例。如果您正苦于以下问题:C++ GMap类的具体用法?C++ GMap怎么用?C++ GMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_chunks
static void
display_chunks(ByteStream & out_str, IFFByteStream &iff,
const GUTF8String &head, DjVmInfo djvminfo)
{
size_t size;
GUTF8String id, fullid;
GUTF8String head2 = head + " ";
GPMap<int,DjVmDir::File> djvmmap;
int rawoffset;
GMap<GUTF8String, int> counters;
while ((size = iff.get_chunk(id, &rawoffset)))
{
if (!counters.contains(id)) counters[id]=0;
else counters[id]++;
GUTF8String msg;
msg.format("%s%s [%d] ", (const char *)head, (const char *)id, size);
out_str.format( "%s", (const char *)msg);
// Display DJVM is when adequate
if (djvminfo.dir)
{
GP<DjVmDir::File> rec = djvminfo.map[rawoffset];
if (rec)
{
GUTF8String id = rec->get_load_name();
GUTF8String title = rec->get_title();
out_str.format( "{%s}", (const char*) id);
if (rec->is_include())
out_str.format(" [I]");
if (rec->is_thumbnails())
out_str.format(" [T]");
if (rec->is_shared_anno())
out_str.format(" [S]");
if (rec->is_page())
out_str.format(" [P%d]", rec->get_page_num()+1);
if (id != title)
out_str.format(" (%s)", (const char*)title);
}
}
// Test chunk type
iff.full_id(fullid);
for (int i=0; disproutines[i].id; i++)
if (fullid == disproutines[i].id || id == disproutines[i].id)
{
int n = msg.length();
while (n++ < 14+(int) head.length()) putchar(out_str, ' ');
if (!iff.composite()) out_str.format( " ");
(*disproutines[i].subr)(out_str, iff, head2,
size, djvminfo, counters[id]);
break;
}
// Default display of composite chunk
out_str.format( "\n");
if (iff.composite())
display_chunks(out_str, iff, head2, djvminfo);
// Terminate
iff.close_chunk();
}
}
示例2: makeccid
// -- Helper for merge_and_split_ccs
static int
makeccid(const Grid_x_Color &x, GMap<Grid_x_Color,int> &map, int &ncc)
{
GPosition p = map.contains(x);
if (p) return map[p];
return map[x] = ncc++;
}
示例3: mapname
void
lt_XMLParser::Impl::parse_anno(
const int width,
const int height,
const lt_XMLTags &GObject,
GMap<GUTF8String,GP<lt_XMLTags> > &Maps,
DjVuFile &dfile )
{
GP<lt_XMLTags> map;
{
GPosition usemappos=GObject.get_args().contains("usemap");
if(usemappos)
{
const GUTF8String mapname(GObject.get_args()[usemappos]);
GPosition mappos=Maps.contains(mapname);
if(!mappos)
{
G_THROW((ERR_MSG("XMLAnno.map_find") "\t")+mapname );
}else
{
map=Maps[mappos];
}
}
}
if(map)
{
ChangeAnno(width,height,dfile,*map);
}
}
示例4: BorderTypeMap
static const GMap<GUTF8String,GMapArea::BorderType> &
BorderTypeMap(void)
{
static GMap<GUTF8String,GMapArea::BorderType> typeMap;
if (! typeMap.size())
{
typeMap["none"]=GMapArea::NO_BORDER;
typeMap["xor"]=GMapArea::XOR_BORDER;
typeMap["solid"]=GMapArea::SOLID_BORDER;
typeMap["default"]=GMapArea::SOLID_BORDER;
typeMap["shadowout"]=GMapArea::SHADOW_OUT_BORDER;
typeMap["shadowin"]=GMapArea::SHADOW_IN_BORDER;
typeMap["etchedin"]=GMapArea::SHADOW_EIN_BORDER;
typeMap["etchedout"]=GMapArea::SHADOW_EOUT_BORDER;
}
return typeMap;
}
示例5: lock
void
DjVuPortcaster::compute_closure(const DjVuPort * src, GPList<DjVuPort> &list, bool sorted)
{
GCriticalSectionLock lock(&map_lock);
GMap<const void*, void*> set;
if (route_map.contains(src))
{
GList<void *> & list=*(GList<void *> *) route_map[src];
for(GPosition pos=list;pos;++pos)
{
DjVuPort * dst=(DjVuPort *) list[pos];
if (dst==src) add_to_closure(set, src, 0);
else add_to_closure(set, dst, 1);
}
}
// Compute list
GPosition pos;
if (sorted)
{
// Sort in depth order
int max_dist=0;
for(pos=set;pos;++pos)
if (max_dist < (int)(long)set[pos])
max_dist = (int)(long)set[pos];
GArray<GList<const void*> > lists(0,max_dist);
for(pos=set;pos;++pos)
lists[(int)(long)set[pos]].append(set.key(pos));
for(int dist=0;dist<=max_dist;dist++)
for(pos=lists[dist];pos;++pos)
{
GP<DjVuPort> p = is_port_alive((DjVuPort*) lists[dist][pos]);
if (p) list.append(p);
}
}
else
{
// Gather ports without order
for(pos=set;pos;++pos)
{
GP<DjVuPort> p = is_port_alive((DjVuPort*) set.key(pos));
if (p) list.append(p);
}
}
}
示例6: appendPath
static void
appendPath(const GURL &url,
GMap<GUTF8String,void *> &map,
GList<GURL> &list)
{
if( !url.is_empty() && !map.contains(url.get_string()) )
{
map[url.get_string()]=0;
list.append(url);
}
}
示例7:
void
DjVuPalette::allocate_hist()
{
if (! hist)
{
hist = new GMap<int,int>;
mask = 0;
}
else
{
GMap<int,int> *old = hist;
hist = new GMap<int,int>;
mask = (mask<<1)|(0x010101);
for (GPosition p = *old; p; ++p)
{
int k = old->key(p);
int w = (*old)[p];
(*hist)[k | mask] += w;
}
delete old;
}
}
示例8: getExecDir
GURL
getExecDir(void)
{
// This is the same as GetModulePath in DjVuMessage.cpp
GURL retval;
GUTF8String &xprogramname=DjVuMessage::programname();
if(xprogramname.length())
{
if(xprogramname[1]=='/'
||!xprogramname.cmp("../",3)
||!xprogramname.cmp("./",2))
{
retval=GURL::Filename::UTF8(xprogramname);
}
if(retval.is_empty() || !retval.is_file())
{
GList<GURL> paths(parsePATH());
GMap<GUTF8String,void *> pathMAP;
for(GPosition pos=paths;pos;++pos)
{
retval=GURL::UTF8(xprogramname,paths[pos]);
const GUTF8String path(retval.get_string());
if(!pathMAP.contains(path))
{
if(retval.is_file())
break;
pathMAP[path]=0;
}
}
}
if (! retval.is_empty() )
retval = retval.follow_symlinks();
if (! retval.is_empty() )
retval = retval.base();
}
return retval;
}
示例9:
void
DjVuPortcaster::add_to_closure(GMap<const void *, void *> & set,
const DjVuPort * dst, int distance)
{
// Assuming that the map's already locked
// GCriticalSectionLock lock(&map_lock);
set[dst]= (void*) (unsigned long) distance;
if (route_map.contains(dst))
{
GList<void *> & list=*(GList<void *> *) route_map[dst];
for(GPosition pos=list;pos;++pos)
{
DjVuPort * new_dst=(DjVuPort *) list[pos];
if (!set.contains(new_dst))
add_to_closure(set, new_dst, distance+1);
}
}
}
示例10: writeDictReportLocal
void GLogicProcessor::writeDictReportLocal(string &srcStr){
int id=1;
//int print=1;
string str,dL,line;
vector<dictKey> keyArray;
ostringstream out;
GMemory *longMemory=(GMemory*)inputData.longMemory;
GMap *dict;
GVector *dt;
int translationMode=((GStr<int>*)inputData.pref)->get(22);
GVector *dk;
GMap *d;
if(translationMode==TRANSLATE_ENG){
str="translationDictEng";
}else{
str="translationDictRus";
}
longMemory->loadTable(str);
dk=longMemory->table[str].data;
indexRecord indexRec=longMemory->createIndex(longMemory->table[str], 0, HASH_SEARCH);
d=indexRec.mIndex;
str="mainDict";
longMemory->loadTable(str);
indexRec=longMemory->createIndex(longMemory->table[str], 0, HASH_SEARCH);
dt=longMemory->table[str].data;
GMap *dictKey=indexRec.mIndex;
vector<uint>searchResult;
//d->getKey(srcStr, searchResult,HASH_FIND);
searchResult.push_back(d->getHKey(srcStr,0));
for(int m=0;m<searchResult.size();m++) {
TString st;
dk->getTStr(searchResult[m], &st);
str="="+st[1];
out<<"["<<linkDict(st[0].c_str(),&id)<<linkEdit(str,&id)<<"]<hr>\n"<<endl;
}
searchResult.resize(0);
//d->getKey(srcStr, searchResult,HASH_FIND);
searchResult.push_back(d->getHKey(srcStr,0));
for(int m=0;m<searchResult.size();m++) {
TString st;
dk->getTStr(searchResult[m], &st);
str="="+st[1];
str=str_replace(":|:YP", "", str);
out<<"["<<linkDict(st[0].c_str(),&id)<<linkEdit(str,&id)<<"]<hr>\n"<<endl;
}
searchResult.resize(0);
inputData.start=1;
dict->getHKey(searchResult,srcStr,0);
//dict->getKey(srcStr, searchResult,HASH_FIND);
//cout<<"searchResult="<<searchResult.size()<<endl;
vector<string>report;
report.resize(25);
for(int m=0;m<searchResult.size();m++) {
TString st;
dt->getTStr(searchResult[m], &st);
str=st[2];
line=st[1];
if(str.find("[MG]")!=-1){
report[0]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[HP]")!=-1){
report[1]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[TD]")!=-1){
report[2]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[MV]")!=-1){
report[3]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[VD]")!=-1){
report[4]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[EP]")!=-1){
report[5]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[RE]")!=-1){
report[6]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[SD]")!=-1){
report[7]=line+"<br>\n"+st[2];
continue;
}
if(str.find("[IW]")!=-1){
report[8]=line+"<br>\n"+st[2];
continue;
}
//.........这里部分代码省略.........
示例11: set_two
static int set_two(const void *pKey, void *pValue, void *tmp)
{
GMap *gm = (GMap *)tmp;
gm->update(pKey, (void *)2);
return 0;
}
示例12: saveToTranslationDictionary
void GLogicProcessor::saveToTranslationDictionary(string &srcStr){
vector<string>text=explode("[",srcStr);
int index;
string key,value;
GMemory *longMemory=(GMemory*)inputData.longMemory;
int translationMode=((GStr<int>*)inputData.pref)->get(22);
GVector *dv;
GMap *d;
if(translationMode==TRANSLATE_ENG){
dv=longMemory->translationDictEng;
d=longMemory->translationDictGMapEng;
}else{
dv=longMemory->translationDictRus;
d=longMemory->translationDictGMapRus;
}
//GMap *dictKey=longMemory->dictionaryGMap;
for(int i=0;i<text.size();i++){
string line=text[i];
string reStr="<[^>]*>";
std::regex key_regex(reStr);
line = std::regex_replace(line, key_regex, "");
reStr=".*=.*";
std::regex key_regex_(reStr);
line = std::regex_replace(line, key_regex_, "");
if(line.size()<3)continue;
index=(int)line.find("/");
if(index<3)continue;
index=(int)line.find("]");
if(index<3)continue;
line=substr(0, index, line);
line=str_replace("/_", "/", line);
vector<string>data=explode("/",line);
if(data.size()<2)continue;
key=data[0];
value=data[1];
key=key+"་";
key=str_replace(" ","",key);
key=str_replace("་་","་",key);
value=str_replace("__","#",value);
value=str_replace("[email protected]","@",value);
value=str_replace("#","__",value);
value+="@";
value=str_replace("@@","@",value);
value=str_replace("{","༼",value);
value=str_replace("«","༼",value);
value=str_replace("}","༽",value);
value=str_replace("»","༽",value);
value=str_replace("༼༼","༼",value);
value=str_replace("༽༽","༽",value);
if(value.size()<3)continue;
//cout<<"key="<<key<<" value="<<value<<endl;
index=d->getHKey(key,0);
//cout<<"index="<<index;
TString st;
if(value!="---"){
st+=key;
st+=value;
}else{
st+="";
st+="";
}
if(index>-1){
dv->putTStr(index, &st);
}else{
d->addRecord(&st);
}
}
}
示例13: getbodies
static GUTF8String
getbodies(
GList<GURL> &paths,
const GUTF8String &MessageFileName,
GPList<lt_XMLTags> &body,
GMap<GUTF8String, void *> & map )
{
GUTF8String errors;
bool isdone=false;
GPosition firstpathpos=paths;
for(GPosition pathpos=firstpathpos;!isdone && pathpos;++pathpos)
{
const GURL::UTF8 url(MessageFileName,paths[pathpos]);
if(url.is_file())
{
map[MessageFileName]=0;
GP<lt_XMLTags> gtags;
{
GP<ByteStream> bs=ByteStream::create(url,"rb");
G_TRY
{
gtags=lt_XMLTags::create(bs);
}
G_CATCH(ex)
{
GUTF8String mesg(failed_to_parse_XML+("\t"+url.get_string()));
if(errors.length())
{
errors+="\n"+mesg;
}else
{
errors=mesg;
}
errors+="\n"+GUTF8String(ex.get_cause());
}
G_ENDCATCH;
}
if(gtags)
{
lt_XMLTags &tags=*gtags;
GPList<lt_XMLTags> Bodies=tags.get_Tags(bodystring);
if(! Bodies.isempty())
{
isdone=true;
for(GPosition pos=Bodies;pos;++pos)
{
body.append(Bodies[pos]);
}
}
GPList<lt_XMLTags> Head=tags.get_Tags(headstring);
if(! Head.isempty())
{
isdone=true;
GMap<GUTF8String, GP<lt_XMLTags> > includes;
lt_XMLTags::get_Maps(includestring,namestring,Head,includes);
for(GPosition pos=includes;pos;++pos)
{
const GUTF8String file=includes.key(pos);
if(! map.contains(file))
{
GList<GURL> xpaths;
xpaths.append(url.base());
const GUTF8String err2(getbodies(xpaths,file,body,map));
if(err2.length())
{
if(errors.length())
{
errors+="\n"+err2;
}else
{
errors=err2;
}
}
}
}
}
}
}
}
示例14: envp
GList<GURL>
DjVuMessage::GetProfilePaths(void)
{
static bool first=true;
static GList<GURL> realpaths;
if(first)
{
first=false;
GMap<GUTF8String,void *> pathsmap;
GList<GURL> paths;
GURL path;
const GUTF8String envp(GOS::getenv(DjVuEnv));
if(envp.length())
appendPath(GURL::Filename::UTF8(envp),pathsmap,paths);
#if defined(WIN32) || defined(UNIX)
GURL mpath(GetModulePath());
if(!mpath.is_empty() && mpath.is_dir())
{
#if defined(UNIX) && !defined(AUTOCONF) && !defined(NDEBUG)
appendPath(GURL::UTF8(DebugModuleDjVuDir,mpath),pathsmap,paths);
#endif
appendPath(mpath,pathsmap,paths);
mpath=mpath.base();
appendPath(GURL::UTF8(ModuleDjVuDir,mpath),pathsmap,paths);
mpath=mpath.base();
appendPath(GURL::UTF8(ModuleDjVuDir,mpath),pathsmap,paths);
}
#endif
#if defined(AUTOCONF)
GURL dpath = GURL::Filename::UTF8(DjVuDataDir);
appendPath(dpath,pathsmap,paths);
#endif
#ifdef WIN32
appendPath(RegOpenReadConfig(HKEY_CURRENT_USER),pathsmap,paths);
appendPath(RegOpenReadConfig(HKEY_LOCAL_MACHINE),pathsmap,paths);
#else
GUTF8String home=GOS::getenv("HOME");
# if HAVE_GETPWUID
if (! home.length()) {
struct passwd *pw=0;
if ((pw = getpwuid(getuid())))
home=GNativeString(pw->pw_dir);
}
# endif
if (home.length()) {
GURL hpath = GURL::UTF8(LocalDjVuDir,GURL::Filename::UTF8(home));
appendPath(hpath,pathsmap,paths);
}
#endif
#ifdef LT_DEFAULT_PREFIX
appendPath(GURL::Filename::UTF8(DjVuPrefixDir),pathsmap,paths);
#endif
appendPath(GURL::Filename::UTF8(RootDjVuDir),pathsmap,paths);
pathsmap.empty();
GPosition pos;
GList< GMap<GUTF8String,GP<lt_XMLTags> > > localemaps;
for(pos=paths;pos;++pos)
{
path=GURL::UTF8(LanguageFile,paths[pos]);
if(path.is_file())
{
const GP<lt_XMLTags> xml(lt_XMLTags::create(ByteStream::create(path,"rb")));
const GPList<lt_XMLTags> Body(xml->get_Tags(bodystring));
GPosition pos=Body;
if(!pos || (pos != Body.lastpos()))
{
G_THROW( ERR_MSG("XMLAnno.extra_body") );
}
const GP<lt_XMLTags> GBody(Body[pos]);
if(!GBody)
{
G_THROW( ERR_MSG("XMLAnno.no_body") );
}
GMap<GUTF8String,GP<lt_XMLTags> > localemap;
lt_XMLTags::get_Maps(languagestring,localestring,Body,localemap);
localemaps.append(localemap);
}
}
GList<GURL> localepaths;
GList<GURL> osilocalepaths;
// Need to do it the right way!
GUTF8String defaultlocale = getenv("LANGUAGE");
if (! defaultlocale)
{
const GUTF8String oldlocale(setlocale(LC_MESSAGES,0));
defaultlocale = setlocale(LC_MESSAGES,"");
setlocale(LC_MESSAGES,(const char *)oldlocale);
}
// Unfathomable search.
for(int loop=0; loop<2; loop++)
{
static const char sepchars[]=" [email protected]";
const char *p=sepchars+sizeof(sepchars)-1;
do
{
int sepcharpos=p[0]?defaultlocale.search(p[0]):defaultlocale.length();
if(sepcharpos > 0)
{
//.........这里部分代码省略.........
示例15: lineTextTranslation
/** @brief translate text lines and write result in destString*/
void GLogicProcessor::lineTextTranslation(string &destString){
GMemory *longMemory=(GMemory*)inputData.longMemory;
int translationMode=((GStr<int>*)inputData.pref)->get(22);
string ln=inputData.data["ln"];
if(ln!=""){
if(ln=="rus")translationMode=TRANSLATE_RUS;
if(ln=="eng")translationMode=TRANSLATE_ENG;
}
GVector *dk;
GMap *d;
string str;
if(translationMode==TRANSLATE_ENG){
str="translationDictEng";
}else{
str="translationDictRus";
}
longMemory->loadTable(str);
dk=longMemory->table[str].data;
indexRecord indexRec=longMemory->createIndex(longMemory->table[str], 0, HASH_SEARCH);
d=indexRec.mIndex;
str="mainDict";
longMemory->loadTable(str);
indexRec=longMemory->createIndex(longMemory->table[str], 0, HASH_SEARCH);
GMap *dictKey=indexRec.mIndex;
string src,line,ld,l1,c,c1,c2,report,res,resD;
int i,j,start,end,lng,index;
int mode=inputData.mode;
destString=str_replace("། ","།\n",destString);
destString=str_replace("།་","།\n",destString);
destString=str_replace("༎","།\n",destString);
destString=str_replace("༔ ","༔\n",destString);
destString=str_replace("༴ ","༴\n",destString);
destString=str_replace("ག ","ག\n",destString);
vector<string>text=explode("\n",destString);
int id=1;
//text.resize(1); text[0]="གང་ཟག་ཏུ་ལྟ་(༦)བའམ།";
//line="རྣམས་";
//TString st;
//dk->getTStr(109073, &st);
//cout<<"st="<<st.size()<<" st[0]="<<st[0]<<endl;
//exit(0);
//index=d->getHKey(line);
//cout<<"index="<<index<<endl;
//exit(0);
//cout<<"text.size()="<<text.size()<<endl;
//dictKey->hashError=0;
//dictKey->maxHashError=0;
//dictKey->hashCount=0;
report="";
int step=0;
for(int lineIndex=0;lineIndex<text.size();lineIndex++){
if(step==1000){
print(lineIndex<<" from "<<text.size());
step=0;
}
step++;
str=text[lineIndex];
//cout<<"str="<<str<<endl;
src=str;
lng=(int)str.size();
if(lng<2)continue;
if(str.find("་")==-1){
report+=src+"\n<br>";
continue;
}
str=clearText(str);
//str=str_replace("[ _\d\ " \"\*\(\)\{\}\[\]@//\%\&༄༅༔༴༡༢༣༤༥༦༧༨༩༠༎།༑༈༌༐༼༽ऀ-ॿ]","་",str)
str=str_replace("ཿ","་ཿ་",str);
str=str_replace("│","",str);
str=str+"་།";
str=str_replace("་་","་",str);
//str=str_replace("([^་])འོ་།","\1་(точка)་",str);
//str=str_replace("([^་])འམ་།","\1་[འམ=или]་",str);
str=str_replace("ག་གོ་།","ག་(¶)་",str);
str=str_replace("ང་ངོ་།","ང་(¶)་",str);
str=str_replace("ད་དོ་།","ད་(¶)་",str);
str=str_replace("ན་ནོ་།","ན་(¶)་",str);
str=str_replace("བ་བོ་།","བ་(¶)་",str);
str=str_replace("མ་མོ་།","མ་(¶)་",str);
str=str_replace("ར་རོ་།","ར་(¶)་",str);
str=str_replace("ལ་ལོ་།","ལ་(¶)་",str);
str=str_replace("ས་སོ་།","ས་(¶)་",str);
str=str_replace("་ཏོ་།","་(¶)་",str);
//str=str_replace("་པའང་","་པ་[འང=уступ.]་",str);
//str=str_replace("་བའང་","་བ་[འང=уступ.]་",str);
vector<string>l=explode("་",str);
res="";
resD="";
//.........这里部分代码省略.........