2017-11-29 23:00:14 +00:00
|
|
|
/*
|
|
|
|
4coder_search.h - Types that are used in the search accross all buffers procedures.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FCODER_SEARCH_H)
|
|
|
|
#define FCODER_SEARCH_H
|
|
|
|
|
2019-02-26 23:17:53 +00:00
|
|
|
typedef i32 Seek_Potential_Match_Direction;
|
2018-05-10 08:12:47 +00:00
|
|
|
enum{
|
|
|
|
SeekPotentialMatch_Forward = 0,
|
|
|
|
SeekPotentialMatch_Backward = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum{
|
|
|
|
FindResult_None,
|
|
|
|
FindResult_FoundMatch,
|
|
|
|
FindResult_PastEnd,
|
|
|
|
};
|
|
|
|
|
2019-02-26 23:17:53 +00:00
|
|
|
typedef i32 Search_Range_Type;
|
2018-05-10 08:12:47 +00:00
|
|
|
enum{
|
|
|
|
SearchRange_FrontToBack = 0,
|
|
|
|
SearchRange_BackToFront = 1,
|
|
|
|
SearchRange_Wave = 2,
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
2019-02-26 23:17:53 +00:00
|
|
|
typedef u32 Search_Range_Flag;
|
2017-11-29 23:00:14 +00:00
|
|
|
enum{
|
|
|
|
SearchFlag_MatchWholeWord = 0x0000,
|
|
|
|
SearchFlag_MatchWordPrefix = 0x0001,
|
|
|
|
SearchFlag_MatchSubstring = 0x0002,
|
|
|
|
SearchFlag_MatchMask = 0x00FF,
|
|
|
|
SearchFlag_CaseInsensitive = 0x0100,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Search_Range{
|
2019-04-02 20:06:49 +00:00
|
|
|
Search_Range_Type type;
|
|
|
|
Search_Range_Flag flags;
|
|
|
|
Buffer_ID buffer;
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 start;
|
|
|
|
i32 size;
|
|
|
|
i32 mid_start;
|
|
|
|
i32 mid_size;
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Search_Set{
|
|
|
|
Search_Range *ranges;
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 count;
|
|
|
|
i32 max;
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Search_Key{
|
2019-06-01 23:58:28 +00:00
|
|
|
u8 *base;
|
|
|
|
umem base_size;
|
|
|
|
umem min_size;
|
|
|
|
String_Const_u8 words[16];
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 count;
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Search_Iter{
|
|
|
|
Search_Key key;
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 pos;
|
|
|
|
i32 back_pos;
|
|
|
|
i32 i;
|
|
|
|
i32 range_initialized;
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Search_Match{
|
2019-04-02 20:06:49 +00:00
|
|
|
Buffer_ID buffer;
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 start;
|
|
|
|
i32 end;
|
|
|
|
i32 match_word_index;
|
|
|
|
i32 found_match;
|
2017-11-29 23:00:14 +00:00
|
|
|
};
|
|
|
|
|
2018-05-10 08:12:47 +00:00
|
|
|
struct Word_Complete_State{
|
|
|
|
Search_Set set;
|
|
|
|
Search_Iter iter;
|
|
|
|
Table hits;
|
|
|
|
String_Space str;
|
2019-02-26 23:17:53 +00:00
|
|
|
i32 word_start;
|
|
|
|
i32 word_end;
|
|
|
|
i32 initialized;
|
2018-05-10 08:12:47 +00:00
|
|
|
};
|
|
|
|
|
2017-11-29 23:00:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// BOTOTM
|
|
|
|
|