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-06-15 19:06:14 +00:00
|
|
|
/* TODO(allen):
|
|
|
|
|
|
|
|
Time to rewrite _ALL_ of this s***f.
|
2019-06-21 02:31:22 +00:00
|
|
|
[x] 1. String matching optimization study
|
|
|
|
[x] 2. Redesign and reimplement find_all_in_range
|
|
|
|
[x] 3. Filtering and reversing string lists
|
|
|
|
[ ] 4. Clean prefix match iterator
|
|
|
|
[ ] 5. Reimplement commands in 4coder_search.cpp
|
|
|
|
[ ] 6. Ditch all the old s***f we don't want anymore
|
|
|
|
[ ] 7. Reorganize, rename, etc.
|
2019-06-15 19:06:14 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2019-06-21 02:31:22 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
// TODO(allen): deprecate all this
|
2019-06-15 19:06:14 +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
|
|
|
|
|