utilitiec/src/regex/match_struct.h
2024-06-13 16:51:46 +02:00

31 lines
764 B
C

#ifndef UTILITIEC_REGEX_MATCHSTRUCT_H
#define UTILITIEC_REGEX_MATCHSTRUCT_H
#include "../StringView/StringView.h"
#include "../dynamicarray/dynamicarray.h"
typedef struct RegexCapture_s {
// potentially unowned string, depending on Regex Options
char* name;
size_t number;
// Reference to string passed to match()
StringView match;
size_t match_start;
size_t match_end;
} RegexCapture;
typedef struct RegexMatch_s {
// entire match
StringView match;
// numbered and named captures intermixed, ordered
DynamicArray captures;
} RegexMatch;
bool RegexMatch_HaveNumberedCapture(RegexMatch* match, size_t number);
RegexCapture* RegexMatch_GetNumberedCapture(RegexMatch* match, size_t number);
void RegexMatch_Destroy(RegexMatch* match);
#endif