ultimatepp/uppsrc/ide/Browser/Iml.cpp
cxl 02fa76faa0 cpp: fixed issue with using namespace in .lay files
git-svn-id: svn://ultimatepp.org/upp/trunk@8543 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2015-06-14 12:53:41 +00:00

54 lines
1.2 KiB
C++

#include "Browser.h"
#define LDUMP(x) // DDUMP(x)
String PreprocessImlFile(const char *fn)
{
String s = LoadFile(fn);
CParser p(s);
String iml, i_ml;
try {
p.PassId("PREMULTIPLIED");
for(;;) {
if(p.Id("IMAGE_ID")) {
p.Char('(');
String id = p.ReadId();
i_ml << "I_" << id << ",\n";
iml << "static Image " << id << "();\n";
p.Char(')');
}
else
if(p.Id("IMAGE_META")) {
p.Char('(');
p.ReadString();
p.Char(',');
p.ReadString();
p.Char(')');
}
else
break;
}
}
catch(CParser::Error) {}
String r = "using namespace Upp;";
r << "struct " << GetFileTitle(fn) << "Img {\n";
if(iml.GetCount())
r << "enum {" << i_ml << "};\n" << iml;
r <<
"static Iml& Iml();"
"static int Find(const UPP::String& s);"
"static int Find(const char *s);"
"static int GetCount();"
"static String GetId(int i);"
"static Image Get(int i);"
"static Image Get(const char *s);"
"static Image Get(const UPP::String& s);"
"static void Set(int i, const UPP::Image& m);"
"static void Set(const char *s, const UPP::Image& m);"
"static void Reset();"
"};\n";
LDUMP(r);
return r;
}