class jnc.Regex

class Regex {
    // fields

    jnc.RegexKind readonly m_regexKind;
    jnc.RegexFlags readonly m_flags;
    size_t readonly m_captureCount;
    size_t readonly m_switchCaseCount;

    // properties

    string_t const property m_pattern;
    string_t const indexed property m_switchCasePattern(uint_t id);
    size_t const indexed property m_switchCaseCaptureCount(uint_t id);

    // construction

    construct();
    construct(string_t pattern);

    construct(
        jnc.RegexFlags flags,
        string_t pattern
    );
    destruct();

    // methods

    void clear();

    bool errorcode compile(
        string_t source,
        jnc.RegexFlags flags = 0
    );

    void createSwitch(jnc.RegexFlags flags = 0);
    uint_t errorcode compileSwitchCase(string_t source);
    bool errorcode finalizeSwitch();

    size_t errorcode load(
        void const* p,
        size_t size
    );

    size_t errorcode save(std.Buffer* buffer);
    std.Buffer* errorcode save();

    jnc.RegexExecResult exec(
        jnc.RegexState* state,
        string_t chunk
    ) const;

    jnc.RegexMatch const* exec(
        string_t text,
        jnc.RegexExecFlags flags = 0
    ) const;

    jnc.RegexExecResult execEof(
        jnc.RegexState* state,
        string_t lastChunk,
        int eofChar = RegexEofChar
    ) const;

    jnc.RegexExecResult execEof(
        jnc.RegexState* state,
        int eofChar = RegexEofChar
    ) const;

    size_t errorcode captureSubmatches(
        uint64_t matchOffset,
        string_t matchText,
        jnc.RegexCapture* submatchArray,
        size_t count
    ) const;

    size_t errorcode captureSubmatches(
        jnc.RegexCapture const* match,
        jnc.RegexCapture* submatchArray,
        size_t count
    ) const;

    size_t errorcode captureSwitchCaseSubmatches(
        uint_t switchCaseId,
        uint64_t matchOffset,
        string_t matchText,
        jnc.RegexCapture* submatchArray,
        size_t count
    ) const;

    size_t errorcode captureSwitchCaseSubmatches(
        uint_t switchCaseId,
        jnc.RegexCapture const* match,
        jnc.RegexCapture* submatchArray,
        size_t count
    ) const;
};