Xonotic
datasource.qc
Go to the documentation of this file.
1 #include "datasource.qh"
2 
3  CONSTRUCTOR(StringSource, string str, string sep)
4  {
6  this.StringSource_str = str;
7  this.StringSource_sep = sep;
8  }
9  METHOD(StringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
10  {
11  int n = tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
12  if (i < 0 || i >= n) return DataSource_false;
13  string s = argv(i);
14  if (returns) returns(s, string_null);
15  return DataSource_true;
16  }
17  METHOD(StringSource, reload, int(entity this, string filter))
18  {
19  return tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
20  }
21 
22  CONSTRUCTOR(CvarStringSource, string cv, string sep)
23  {
25  this.CvarStringSource_cvar = cv;
26  this.StringSource_sep = sep;
27  }
28  METHOD(CvarStringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
29  {
30  string s = this.CvarStringSource_cvar;
31  this.StringSource_str = s ? cvar_string(s) : string_null;
32  return SUPER(CvarStringSource).getEntry(this, i, returns);
33  }
34  METHOD(CvarStringSource, reload, int(entity this, string filter))
35  {
36  string s = this.CvarStringSource_cvar;
37  this.StringSource_str = s ? cvar_string(s) : string_null;
38  return SUPER(CvarStringSource).reload(this, filter);
39  }
string string_null
Definition: nil.qh:9
entity() spawn
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
#define CONSTRUCT(cname,...)
Definition: oo.qh:111
#define SUPER(cname)
Definition: oo.qh:219
#define tokenizebyseparator
Definition: dpextensions.qh:21
#define CONSTRUCTOR(cname,...)
Definition: oo.qh:201