Generates the schema instead of downloading the pre-generated

This commit is contained in:
Ernesto Castellotti 2019-05-04 22:22:10 +02:00 committed by GitHub
parent ec1e334f4c
commit 257010deee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -1,18 +1,16 @@
module dscheme;
import tlscheme2json;
enum DEFAULT_SCHEME_URL = "https://raw.githubusercontent.com/ErnyTech/TLScheme2Json/master/TLScheme.json";
class DScheme {
private static TLClass[] tlClasses;
static this() {
import std.stdio : writeln;
import std.net.curl : get;
import asdf : deserialize;
writeln("Obtaining TLScheme Json from " , DEFAULT_SCHEME_URL);
auto jsonScheme = get(DEFAULT_SCHEME_URL).dup;
auto parser = new TLScheme2Json();
parser.parse;
auto jsonScheme = parser.toJson;
auto tljson = deserialize!TLJson(jsonScheme);
this.tlClasses = tljson.tl_classes;
}
@ -20,4 +18,4 @@ class DScheme {
static TLClass get() {
return this.tlClasses;
}
}
}