本文整理汇总了C++中Index::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::Add方法的具体用法?C++ Index::Add怎么用?C++ Index::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IndexClient
void IndexClient()
{
/// .Index and client types
/// In order to store elements to `Index`, they type must be `Moveable`, have deep copy and
/// defined the `operator==` and a `GetHashValue` function or method to compute the hash
/// code. It is recommended to use `CombineHash` to combine hash values of types that
/// already provide `GetHashValue`:
struct Person : Moveable<Person> {
String name;
String surname;
unsigned GetHashValue() const { return CombineHash(name, surname); }
bool operator==(const Person& b) const { return name == b.name && surname == b.surname; }
Person(String name, String surname) : name(name), surname(surname) {}
Person() {}
};
Index<Person> p;
p.Add(Person("John", "Smith"));
p.Add(Person("Paul", "Carpenter"));
p.Add(Person("Carl", "Engles"));
DUMP(p.Find(Person("Paul", "Carpenter")));
///
}
示例2: OutDir
String MakeBuild::OutDir(const Index<String>& cfg, const String& package, const VectorMap<String, String>& bm,
bool use_target)
{
Index<String> excl;
excl.Add(bm.Get("BUILDER", "GCC"));
excl.Add("MSC");
LocalHost().AddFlags(excl);
Vector<String> x;
bool dbg = cfg.Find("DEBUG_FULL") >= 0 || cfg.Find("DEBUG_MINIMAL") >= 0;
if(cfg.Find("DEBUG") >= 0) {
excl.Add("BLITZ");
if(cfg.Find("BLITZ") < 0)
x.Add("NOBLITZ");
}
else
if(dbg)
x.Add("RELEASE");
if(use_target)
excl.Add("MAIN");
for(int i = 0; i < cfg.GetCount(); i++)
if(excl.Find(cfg[i]) < 0)
x.Add(cfg[i]);
Sort(x);
for(int i = 0; i < x.GetCount(); i++)
x[i] = InitCaps(x[i]);
String outdir = GetVar("OUTPUT");
if(output_per_assembly)
outdir = AppendFileName(outdir, GetVarsName());
if(!use_target)
outdir = AppendFileName(outdir, package);
outdir = AppendFileName(outdir, GetFileTitle(method) + "." + Join(x, "."));
outdir = Filter(outdir, CharFilterSlash);
return outdir;
}
示例3: Load
void CodeBrowser::Load()
{
String find = ToUpper((String)~search);
String match = ToUpper((String)~search_scope);
String pm = GetPm();
Vector<String> txt;
Vector<Value> ndx;
Index<int> fi;
Index<String> fs;
for(int i = 0; i < CodeBase().GetCount(); i++) {
String s = CodeBase().GetKey(i);
const Array<CppItem>& n = CodeBase()[i];
if(s.GetCount())
if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find)) && MatchPm(n, pm)) {
txt.Add(s);
ndx.Add(s);
}
for(int i = 0; i < n.GetCount(); i++) {
int f = n[i].file;
if(fi.Find(f) < 0) {
String s = GetFileText(GetSourceFilePath(f));
if(s.StartsWith(pm) && MatchCib(s, match) &&
(IsNull(find) || MatchCib(s, find) || n[i].uname.StartsWith(find))) {
txt.Add(s);
ndx.Add(f);
fs.Add(s);
fi.Add(f);
}
}
}
}
const Workspace& wspc = GetIdeWorkspace();
for(int i = 0; i < wspc.GetCount(); i++) {
String pn = wspc[i];
const Package& p = wspc.GetPackage(i);
String pp = PackageDirectory(pn);
for(int j = 0; j < p.GetCount(); j++)
if(!p[j].separator) {
String fn = AppendFileName(pp, p[j]);
String s = GetFileText(AppendFileName(pn, p[j]));
if(fs.Find(s) < 0 && (IsNull(find) || MatchCib(s, find)) && MatchCib(s, match) && MatchPm(fn, pm)) {
int f = GetSourceFileIndex(SourcePath(pn, p[j]));
txt.Add(s);
ndx.Add(f);
fs.Add(s);
}
}
}
IndexSort(txt, ndx, ScopeLess());
Value key = scope.GetKey();
int sc = scope.GetCursorSc();
scope.Clear();
for(int i = 0; i < txt.GetCount(); i++)
scope.Add(IsString(ndx[i]) ? ndx[i] : Null, txt[i], ndx[i]);
if(scope.FindSetCursor(key))
scope.ScCursor(sc);
// clear.Enable(IsSearch());
}
示例4: Run
bool Thread::Run(Callback _cb)
{
LLOG("Thread::Run");
AtomicInc(sThreadCount);
if(!threadr)
#ifndef CPU_BLACKFIN
threadr = sMain = true;
#else
{
threadr = true;
//the sMain replacement
#ifdef PLATFORM_POSIX
pthread_t thid = pthread_self();
vm.Enter();
if(threadsv.Find(thid) < 0){
//thread not yet present, mark present
threadsv.Add(thid);
}
else
RLOG("BUG: Multiple Add in Mt.cpp");
vm.Leave();
#endif
}
#endif
Detach();
Callback *cb = new Callback(_cb);
#ifdef PLATFORM_WIN32
handle = (HANDLE)_beginthreadex(0, 0, sThreadRoutine, cb, 0, ((unsigned int *)(&thread_id)));
#endif
#ifdef PLATFORM_POSIX
if(pthread_create(&handle, 0, sThreadRoutine, cb))
handle = 0;
#endif
return handle;
}
示例5: ToIndex
void ToIndex(GtkTargetList *target_list, Index<String>& ndx)
{
gint n;
GtkTargetEntry *t = gtk_target_table_new_from_list(target_list, &n);
for(int i = 0; i < n; i++)
ndx.Add(t[i].target);
gtk_target_table_free(t, n);
gtk_target_list_unref(target_list);
}
示例6: LoadFonts
void LoadFonts(DropList *face, Index<String>& fni, bool fixed)
{
for(int i = 0; i < Font::GetFaceCount(); i++)
if(!!(Font::GetFaceInfo(i) & Font::FIXEDPITCH) == fixed) {
String n = Font::GetFaceName(i);
if(fni.Find(n) < 0) {
fni.Add(n);
face->Add(i, n);
}
}
}
示例7: FinishOldTable
void RichQtfParser::FinishOldTable()
{
FinishCell();
Index<int> pos;
Vector<int> srow;
RichTable& t = Table();
Tab& b = table.Top();
for(int i = 0; i < t.GetRows(); i++) {
int& s = srow.Add();
s = 0;
int nx = b.rown[i];
for(int j = 0; j < nx; j++)
s += t.GetSpan(i, j).cx;
int xn = 0;
for(int j = 0; j < nx; j++) {
pos.FindAdd(xn * 10000 / s);
xn += t.GetSpan(i, j).cx;
}
}
Vector<int> h = pos.PickKeys();
if(h.GetCount() == 0)
Error("table");
Sort(h);
pos = pick(h);
pos.Add(10000);
RichTable tab;
tab.SetFormat(t.GetFormat());
for(int i = 0; i < pos.GetCount() - 1; i++) {
tab.AddColumn(pos[i + 1] - pos[i]);
}
for(int i = 0; i < t.GetRows(); i++) {
int s = srow[i];
int nx = b.rown[i];
int xn = 0;
int xi = 0;
for(int j = 0; j < nx; j++) {
Size span = t.GetSpan(i, j);
xn += span.cx;
int nxi = pos.Find(xn * 10000 / s);
tab.SetPick(i, xi, t.GetPick(i, j));
tab.SetFormat(i, xi, t.GetFormat(i, j));
tab.SetSpan(i, xi, max(span.cy - 1, 0), nxi - xi - 1);
xi = nxi;
}
}
table.Drop();
if(table.GetCount())
table.Top().text.CatPick(pick(tab));
else
target.CatPick(pick(tab));
oldtab = false;
}
示例8: PackagePath
Index<String> MakeBuild::PackageConfig(const Workspace& wspc, int package,
const VectorMap<String, String>& bm, String mainparam,
Host& host, Builder& b, String *target)
{
String packagepath = PackagePath(wspc[package]);
const Package& pkg = wspc.package[package];
Index<String> cfg;
mainparam << ' ' << bm.Get(targetmode ? "RELEASE_FLAGS" : "DEBUG_FLAGS", NULL);
cfg = SplitFlags(mainparam, package == 0, wspc.GetAllAccepts(package));
cfg.FindAdd(bm.Get("BUILDER", "GCC"));
const TargetMode& m = GetTargetMode();
if(targetmode == 0)
cfg.FindAdd("DEBUG");
switch(m.linkmode) {
case 2:
cfg.FindAdd("SO");
case 1:
cfg.FindAdd("SHARED");
}
if(targetmode == 2)
cfg.FindAdd("FORCE_SPEED");
if(targetmode == 3)
cfg.FindAdd("FORCE_SIZE");
int q = m.package.Find(wspc[package]);
if(q >= 0) {
const PackageMode& p = m.package[q];
switch(p.debug >= 0 ? p.debug : m.def.debug) {
case 1: cfg.FindAdd("DEBUG_MINIMAL"); break;
case 2: cfg.FindAdd("DEBUG_FULL"); break;
}
if(!pkg.noblitz && (p.blitz >= 0 ? p.blitz : m.def.blitz))
cfg.FindAdd("BLITZ");
}
else {
switch(m.def.debug) {
case 1: cfg.FindAdd("DEBUG_MINIMAL"); break;
case 2: cfg.FindAdd("DEBUG_FULL"); break;
}
if(!pkg.noblitz && m.def.blitz)
cfg.FindAdd("BLITZ");
}
host.AddFlags(cfg);
b.AddFlags(cfg);
for(int i = 0; i < pkg.flag.GetCount(); i++) {
if(MatchWhen(pkg.flag[i].when, cfg.GetKeys()))
cfg.Add(pkg.flag[i].text);
}
if(target)
*target = Gather(pkg.target, cfg.GetKeys(), true);
return cfg;
}
示例9: GatherMethods
void GatherMethods(const String& type, VectorMap<String, bool>& inherited, bool g, Index<String>& done)
{
if(done.Find(type) >= 0) return;
done.Add(type);
int q = CodeBase().Find(type);
if(q < 0) return;
const Array<CppItem>& n = CodeBase()[q];
Index<String> set;
for(int i = 0; i < n.GetCount(); i++) {
const CppItem& m = n[i];
if(set.Find(m.qitem) < 0) {
set.Add(m.qitem);
if(m.IsType()) {
Vector<String> base = Split(m.qptype, ';');
for(int i = 0; i < base.GetCount(); i++)
GatherMethods(base[i], inherited, true, done);
}
if(m.IsCode() && g) {
bool& virt = inherited.GetAdd(m.qitem);
virt = virt || m.virt;
}
}
}
}
示例10:
Vector<String> Workspace::GetAllAccepts(int pk) const
{
Index<String> accepts;
Index<int> pkg;
pkg.Add(pk);
for(int i = 0; i < pkg.GetCount(); i++) {
const Package& p = package[pkg[i]];
FindAppend(accepts, p.accepts);
for(int u = 0; u < p.uses.GetCount(); u++) {
int f = package.Find(UnixPath(p.uses[u].text));
if(f >= 0)
pkg.FindAdd(f);
}
}
return accepts.PickKeys();
}
示例11: SyncList
void SelectPackageDlg::SyncList()
{
String n = GetCurrentName();
int asc = alist.GetScroll();
int csc = clist.GetSbPos();
packages.Clear();
String s = ~search;
int f = ~filter;
Index<String> added;
for(int i = 0; i < min((f & FIRST) ? 1 : data.GetCount(), data.GetCount()); i++) {
const ArrayMap<String, PkData>& nest = data[i];
for(int i = 0; i < nest.GetCount(); i++) {
const PkData& d = nest[i];
if(!nest.IsUnlinked(i) &&
d.ispackage &&
(!(f & MAIN) || d.main) &&
ToUpper(d.package + d.description + d.nest).Find(s) >= 0 &&
added.Find(d.package) < 0) {
packages.Add() = d;
added.Add(d.package);
}
}
}
Sort(packages);
alist.Clear();
clist.Clear();
ListCursor();
static PackageDisplay pd, bpd;
bpd.fnt.Bold();
for(int i = 0; i < packages.GetCount(); i++) {
const PkInfo& pkg = packages[i];
Image icon = pkg.icon;
if(IsNull(icon))
icon = pkg.main ? IdeImg::MainPackage() : IdeImg::Package();
clist.Add(pkg.package, icon);
alist.Add(pkg.package, pkg.nest, pkg.description, icon);
alist.SetDisplay(alist.GetCount() - 1, 0, pkg.main ? bpd : pd);
}
if(!alist.FindSetCursor(n))
alist.GoBegin();
if(!clist.FindSetCursor(n) && clist.GetCount())
clist.SetCursor(0);
alist.ScrollTo(asc);
clist.SetSbPos(csc);
alist.HeaderTab(0).SetText("Package (" + AsString(alist.GetCount()) + ")");
}
示例12: ScanFolder
void SelectPackageDlg::ScanFolder(const String& path, ArrayMap<String, PkData>& nd,
const String& nest, Index<String>& dir_exists,
const String& prefix)
{
for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next())
if(ff.IsFolder() && !ff.IsHidden()) {
dir_exists.Add(ff.GetPath());
String p = ff.GetPath();
bool nw = nd.Find(p) < 0; // Do we have any info loaded about this package?
PkData& d = nd.GetAdd(ff.GetPath());
d.package = prefix + ff.GetName();
d.nest = nest;
if(nw) { // No cached info available about the folder
d.ispackage = IsLetter(*d.package) && d.package.Find('.') < 0; // First heuristic guess
d.main = d.ispackage && prefix.GetCount() == 0; // Expect it is main
}
}
}
示例13: LoadPPConfig
void LoadPPConfig()
{
for(int i = 0; i < sAllMacros.GetCount(); i++)
if(sAllMacros[i].segment_id == 0 && !sAllMacros.IsUnlinked(i))
sAllMacros.Unlink(i);
s_namespace_macro.Clear();
s_namespace_end_macro.Clear();
StringStream ss(sDefs);
int linei = 0;
while(!ss.IsEof()) {
String l = ss.GetLine();
try {
CParser p(l);
if(p.Char('#')) {
if(p.Id("define")) {
CppMacro def;
String id = def.Define(p.GetPtr());
if(id.GetCount()) {
PPMacro m;
m.segment_id = 0;
m.line = linei;
m.macro = def;
sAllMacros.Put(id, m);
if(findarg(TrimBoth(def.body), "}", "};") >= 0)
s_namespace_end_macro.Add(id);
try {
CParser p(def.body);
if(p.Id("namespace") && p.IsId()) {
String n = p.ReadId();
if(p.Char('{') && p.IsEof())
s_namespace_macro.Add(id, n);
}
}
catch(CParser::Error) {}
}
}
}
}
catch(CParser::Error) {}
linei++;
}
}
示例14: GatherSources
void GatherSources(const String& master_path, const String& path_, Vector<int>& parents)
{
RHITCOUNT("GatherSources");
String path = NormalizeSourcePath(path_);
if(sSrcFile.Find(path) >= 0)
return;
int ii = sSrcFile.GetCount();
for(int i = 0; i < parents.GetCount(); i++)
sIncludes.Add(MAKEQWORD(parents[i], ii));
sSrcFile.Add(path, master_path);
parents.Add(ii);
const PPFile& f = GetPPFile(path);
for(int i = 0; i < f.includes.GetCount(); i++) {
String p = GetIncludePath(f.includes[i], GetFileFolder(path));
if(p.GetCount())
GatherSources(master_path, p, parents);
}
parents.Drop();
}
示例15: SimpleType
String Parser::SimpleType()
{
if(Key(tk_struct) || Key(tk_class) || Key(tk_union) || Key(tk_enum) || Key(tk_typename)) {
if(lex.IsId() || lex == t_dblcolon) Name();
if(lex == '{') EatBody();
return Null;
}
if(Key(tk_bool) || Key(tk_float) || Key(tk_double) || Key(tk_void))
return Null;
bool sgn = Key(tk_signed) || Key(tk_unsigned);
if(Key(tk_long)) {
Key(tk_int);
return Null;
}
if(Key(tk_short)) {
Key(tk_int);
return Null;
}
if(Key(tk_int) || Key(tk_char) ||
Key(tk___int8) || Key(tk___int16) || Key(tk___int32) || Key(tk___int64)) return Null;
if(sgn) return Null;
const char *p = lex.Pos();
int cs = 0;
Index<int> cix;
Key(t_dblcolon);
Check(lex.IsId(), "Name expected");
while(lex.IsId()) {
if(cix.Find(lex) >= 0)
cs++;
else
cix.Add(lex);
++lex;
if(lex == '<')
TemplateParams();
if(Key(t_dblcolon))
Key('~');
else
break;
}
return cs ? String(p, lex.Pos()) : String();
}