HiBONregex

Undocumented in source.

Constructors

this
this(Name name, HType record_type, Types types)
Undocumented in source.
this
this(Name name)
Undocumented in source.
this
this(Name name, HType record_type)
Undocumented in source.

Members

Aliases

RegexT
alias RegexT = Regex!char
Undocumented in source.

Functions

match
bool match(T rec)
Undocumented in source. Be warned that the author may not have intended to support it.
match
bool match(Document doc)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

name
string name;
Undocumented in source.
record_type
string record_type;
Undocumented in source.
regex_name
RegexT regex_name;
Undocumented in source.
regex_record_type
RegexT regex_record_type;
Undocumented in source.
types
uint[] types;
Undocumented in source.

Examples

enum record_type_name = "Some_type";
@recordType(record_type_name)
static struct RegexDoc {
    string name;
    int x;
    @label("12") bool flag;
    mixin HiBONRecord!(q{
        this(string name, int x, bool flag) {
            this.name=name;
            this.x=x;
            this.flag=flag;
        }
    });
}

static struct NoRecordType {
    int x;
    mixin HiBONRecord;
}

const no_record_type_doc = NoRecordType.init.toDoc;
const regex_doc = RegexDoc("text", 42, false);
const doc = regex_doc.toDoc;
{ // Test hibon key name match
    assert(HiBONregex("name").match(doc));
    assert(HiBONregex(regex(`\d+`)).match(doc));
    assert(!HiBONregex("no match").match(doc));
    assert(!HiBONregex(regex(`no match`)).match(doc));

}
{ // Test hibon record type match
    assert(HiBONregex(string.init, record_type_name).match(doc));
    assert(!HiBONregex(string.init, "Not found").match(doc));
    assert(HiBONregex(string.init, regex(`_\w+`)).match(doc));
    assert(!HiBONregex(string.init, regex(`_\d+`)).match(doc));
    assert(!HiBONregex(string.init, "!").match(doc));
    assert(HiBONregex(string.init, "!").match(no_record_type_doc));
}
{ // Test hibon record type match
    assert(HiBONregex(string.init, string.init, Type.STRING).match(doc));
    assert(!HiBONregex(string.init, string.init, Type.BINARY).match(doc));
    assert(HiBONregex(string.init, string.init, [Type.BINARY, Type.STRING]).match(doc));
    assert(!HiBONregex(string.init, string.init, [Type.BINARY, Type.BIGINT]).match(doc));
}

Meta