-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MONGOCRYPT-755 Implement StrEncode #928
Open
marksg07
wants to merge
25
commits into
mongodb:master
Choose a base branch
from
marksg07:marksg07/mongocrypt-755
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,389
−0
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
70e2ef4
MONGOCRYPT-755 Implement StrEncode
marksg07 fe6f93b
Comments + cleanup
marksg07 c8678c8
more comments
marksg07 5215b80
fix
marksg07 e5e8c58
fix ff
marksg07 92bfeb0
fix
marksg07 ceacd48
f
marksg07 cbd420d
windows
marksg07 54f6815
ll
marksg07 481f378
lld
marksg07 85a12ba
Merge branch 'master' into marksg07/mongocrypt-755
marksg07 723427d
unicode
marksg07 0286858
comment
marksg07 b0c023f
comments
marksg07 cb6bcf2
const
marksg07 10792c2
windows
marksg07 4bcba8a
Hashset
marksg07 3e0301e
PR fixes
marksg07 dad5688
fix bug
marksg07 48f80c1
a
marksg07 59e5944
more leaks
marksg07 67b5d07
Merge branch 'master' into marksg07/mongocrypt-755
marksg07 d8f11cb
Fixes
marksg07 95786df
Merge branch 'master' into marksg07/mongocrypt-755
marksg07 b75e949
pr
marksg07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2024-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef MONGOCRYPT_STR_ENCODE_STRING_SETS_PRIVATE_H | ||
#define MONGOCRYPT_STR_ENCODE_STRING_SETS_PRIVATE_H | ||
|
||
#include "mongocrypt-buffer-private.h" | ||
#include "mongocrypt.h" | ||
|
||
// Represents a valid unicode string with the bad character 0xFF appended to the end. This is our base string which | ||
// we build substring trees on. Stores all the valid code points in the string, plus one code point for 0xFF. | ||
// Exposed for testing. | ||
typedef struct { | ||
_mongocrypt_buffer_t buf; | ||
uint32_t *codepoint_offsets; | ||
uint32_t codepoint_len; | ||
} mc_utf8_string_with_bad_char_t; | ||
|
||
// Initialize by copying buffer into data and adding the bad character. | ||
mc_utf8_string_with_bad_char_t *mc_utf8_string_with_bad_char_from_buffer(const char *buf, uint32_t len); | ||
|
||
void mc_utf8_string_with_bad_char_destroy(mc_utf8_string_with_bad_char_t *utf8); | ||
|
||
// Set of affixes of a shared base string. Does not do any duplicate prevention. | ||
typedef struct _mc_affix_set_t mc_affix_set_t; | ||
|
||
// Initialize affix set from base string and number of entries (this must be known as a prior). | ||
mc_affix_set_t *mc_affix_set_new(const mc_utf8_string_with_bad_char_t *base_string, uint32_t n_indices); | ||
|
||
void mc_affix_set_destroy(mc_affix_set_t *set); | ||
|
||
// Insert affix into set. base_start/end_idx are codepoint indices. base_end_idx is exclusive. Returns true if | ||
// inserted, false otherwise. | ||
bool mc_affix_set_insert(mc_affix_set_t *set, uint32_t base_start_idx, uint32_t base_end_idx); | ||
|
||
// Insert the base string count times into the set. Treated as a special case, since this is the only affix that | ||
// will appear multiple times. Returns true if inserted, false otherwise. | ||
bool mc_affix_set_insert_base_string(mc_affix_set_t *set, uint32_t count); | ||
|
||
// Iterator on affix set. | ||
typedef struct { | ||
mc_affix_set_t *set; | ||
uint32_t cur_idx; | ||
} mc_affix_set_iter_t; | ||
|
||
// Point the iterator to the first affix of the given set. | ||
void mc_affix_set_iter_init(mc_affix_set_iter_t *it, mc_affix_set_t *set); | ||
|
||
// Get the next affix, its length in bytes, and its count. Returns false if the set does not have a next element, true | ||
// otherwise. | ||
bool mc_affix_set_iter_next(mc_affix_set_iter_t *it, const char **str, uint32_t *byte_len, uint32_t *count); | ||
|
||
// Set of substrings of a shared base string. Prevents duplicates. | ||
typedef struct _mc_substring_set_t mc_substring_set_t; | ||
|
||
mc_substring_set_t *mc_substring_set_new(const mc_utf8_string_with_bad_char_t *base_string); | ||
|
||
void mc_substring_set_destroy(mc_substring_set_t *set); | ||
|
||
// Insert the base string count times into the set. Treated as a special case, since this is the only substring that | ||
// will appear multiple times. Always inserts successfully. | ||
void mc_substring_set_increment_fake_string(mc_substring_set_t *set, uint32_t count); | ||
|
||
// Insert substring into set. base_start/end_idx are codepoint indices. base_end_idx is exclusive. Returns true if | ||
// inserted, false otherwise. | ||
bool mc_substring_set_insert(mc_substring_set_t *set, uint32_t base_start_idx, uint32_t base_end_idx); | ||
|
||
// Iterator on substring set. | ||
typedef struct { | ||
mc_substring_set_t *set; | ||
void *cur_node; | ||
uint32_t cur_idx; | ||
} mc_substring_set_iter_t; | ||
|
||
// Point the iterator to the first substring of the given set. | ||
void mc_substring_set_iter_init(mc_substring_set_iter_t *it, mc_substring_set_t *set); | ||
|
||
// Get the next substring, its length in bytes, and its count. Returns false if the set does not have a next element, | ||
// true otherwise. | ||
bool mc_substring_set_iter_next(mc_substring_set_iter_t *it, const char **str, uint32_t *byte_len, uint32_t *count); | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a clarifying comment above.