mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-20 06:06:52 -06:00
reorganizing repo
git-svn-id: svn://ultimatepp.org/upp/trunk@9206 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7d17505cfe
commit
e3e8d627f5
3840 changed files with 0 additions and 1161578 deletions
|
|
@ -1,106 +0,0 @@
|
|||
#include "Core.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
struct TopicData__ : Moveable<TopicData__> {
|
||||
String title;
|
||||
const byte *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
VectorMap<String, VectorMap<String, VectorMap<String, TopicData__ > > >& Topics__()
|
||||
{
|
||||
static VectorMap<String, VectorMap<String, VectorMap<String, TopicData__ > > > x;
|
||||
return x;
|
||||
}
|
||||
|
||||
VectorMap<String, VectorMap<String, Vector<String> > >& TopicBase()
|
||||
{
|
||||
static VectorMap<String, VectorMap<String, Vector<String> > > tb;
|
||||
return tb;
|
||||
}
|
||||
|
||||
String TopicLinkString(const TopicLink& tl)
|
||||
{
|
||||
String s;
|
||||
s << "topic://" << tl.package << '/' << tl.group << '/' << tl.topic;
|
||||
if(tl.label.GetCount())
|
||||
s << '#' << tl.label;
|
||||
return s;
|
||||
}
|
||||
|
||||
TopicLink ParseTopicLink(const char *link)
|
||||
{
|
||||
TopicLink tl;
|
||||
const char *end = link + strlen(link);
|
||||
const char *lbl = strchr(link, '#');
|
||||
if(lbl) {
|
||||
end = lbl;
|
||||
tl.label = lbl + 1;
|
||||
}
|
||||
if(memcmp(link, "topic://", 8) == 0)
|
||||
link += 8;
|
||||
do {
|
||||
if(!IsNull(tl.package))
|
||||
tl.package << '/';
|
||||
tl.package.Cat(tl.group);
|
||||
tl.group = tl.topic;
|
||||
const char *b = link;
|
||||
while(link < end && *link != '/')
|
||||
link++;
|
||||
tl.topic = String(b, link);
|
||||
}
|
||||
while(link++ < end);
|
||||
return tl;
|
||||
}
|
||||
|
||||
static StaticCriticalSection sTopicLock;
|
||||
|
||||
Topic GetTopic(const String& package, const String& group, const String& topic)
|
||||
{
|
||||
INTERLOCKED_(sTopicLock) {
|
||||
VectorMap<String, VectorMap<String, TopicData__> > *p = Topics__().FindPtr(package);
|
||||
if(p) {
|
||||
VectorMap<String, TopicData__> *g = p->FindPtr(group);
|
||||
if(g) {
|
||||
const TopicData__ *d = g->FindPtr(topic);
|
||||
if(d) {
|
||||
Topic t;
|
||||
t.title = d->title;
|
||||
t.text = ZDecompress(d->data, d->len);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Topic();
|
||||
}
|
||||
|
||||
Topic GetTopic(const char *path)
|
||||
{
|
||||
TopicLink tl = ParseTopicLink(path);
|
||||
Topic t = GetTopic(tl.package, tl.group, tl.topic);
|
||||
t.label = tl.label;
|
||||
tl.label.Clear();
|
||||
t.link = TopicLinkString(tl);
|
||||
return t;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
void RegisterTopic__(const char *topicfile, const char *topic, const char *title,
|
||||
const UPP::byte *data, int len)
|
||||
{
|
||||
INTERLOCKED_(UPP::sTopicLock) {
|
||||
ASSERT(*topicfile == '<');
|
||||
ASSERT(*UPP::GetFileName(topicfile).Last() == '>');
|
||||
UPP::String q = UPP::GetFileFolder(topicfile + 1);
|
||||
UPP::String group = UPP::GetFileTitle(q);
|
||||
UPP::String package = UPP::UnixPath(UPP::GetFileFolder(q));
|
||||
UPP::TopicData__& d = UPP::Topics__().GetAdd(package).GetAdd(group).GetAdd(topic);
|
||||
d.title = title;
|
||||
d.data = data;
|
||||
d.len = len;
|
||||
UPP::TopicBase().GetAdd(package).GetAdd(group).Add(topic);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue