ultimatepp/uppsrc/ide/Browser/Util.cpp
cxl 6ccdd7cd0a One more A++ fix...
git-svn-id: svn://ultimatepp.org/upp/trunk@521 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-10-12 22:03:45 +00:00

37 lines
731 B
C++

#include "Browser.h"
void SplitCodeRef(const String& s, String& scope, String& item)
{
int q = s.Find('(');
q = q >= 0 ? s.ReverseFind(':', q) : s.ReverseFind(':');
if(q < 0) {
scope.Clear();
item = s;
}
else {
scope = s.Mid(0, max(q - 1, 0));
item = s.Mid(q + 1);
}
}
String MakeCodeRef(const String& nest, const String& item)
{
if(nest.GetCount())
return nest + "::" + item;
return item;
}
const CppItem *GetCodeRefItem(const String& ref)
{
String scope;
String item;
SplitCodeRef(ref, scope, item);
int q = CodeBase().Find(scope);
if(q < 0)
return NULL;
const Array<CppItem>& n = CodeBase()[q];
q = FindItem(n, item);
if(q < 0)
return NULL;
return &n[q];
}