1 #include "datasource.qh"
3 CONSTRUCTOR(StringSource, string str, string sep)
5 CONSTRUCT(StringSource);
6 this.StringSource_str = str;
7 this.StringSource_sep = sep;
9 METHOD(StringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
11 int n = tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
12 if (i < 0 || i >= n) return DataSource_false;
14 if (returns) returns(s, string_null);
15 return DataSource_true;
17 METHOD(StringSource, reload, int(entity this, string filter))
19 return tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
22 CONSTRUCTOR(CvarStringSource, string cv, string sep)
24 CONSTRUCT(CvarStringSource);
25 this.CvarStringSource_cvar = cv;
26 this.StringSource_sep = sep;
28 METHOD(CvarStringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
30 string s = this.CvarStringSource_cvar;
31 this.StringSource_str = s ? cvar_string(s) : string_null;
32 return SUPER(CvarStringSource).getEntry(this, i, returns);
34 METHOD(CvarStringSource, reload, int(entity this, string filter))
36 string s = this.CvarStringSource_cvar;
37 this.StringSource_str = s ? cvar_string(s) : string_null;
38 return SUPER(CvarStringSource).reload(this, filter);