[CDRIVER-20] Not-null-terminated string support Created: 27/Jul/10 Updated: 19/Oct/16 Resolved: 08/Apr/11 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.2 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Stanis?aw Pitucha | Assignee: | Kyle Banker |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I'd like to propose a new set of functions that can deal with not null terminated strings. It would really help in situations where names are part of a longer string. (just like there are strcpy and strncpy) For example for: Same idea affects other types (symbol, code, regex, ...) |
| Comments |
| Comment by auto [ 14/Apr/11 ] |
|
Author: {u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}Message: minor: credits for |
| Comment by auto [ 14/Apr/11 ] |
|
Author: {u'login': u'algernon', u'name': u'Gergely Nagy', u'email': u'algernon@balabit.hu'}Message: Added bson_append_string_n, bson_append_symbol_n, bson_append_code_n |
| Comment by auto [ 08/Apr/11 ] |
|
Author: {u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}Message: minor: credits for |
| Comment by auto [ 08/Apr/11 ] |
|
Author: {u'login': u'algernon', u'name': u'Gergely Nagy', u'email': u'algernon@balabit.hu'}Message: Added bson_append_string_n, bson_append_symbol_n, bson_append_code_n |
| Comment by Gergely Nagy [ 07/Jan/11 ] |
|
I added the neccessary functions (see https://github.com/algernon/mongo-c-driver/tree/j/CDRIVER-20 ), and sent a pull request aswell. string, code, symbol and code_w_scope received an _n variant, those four made sense to me. Tests were added to the test_all_types test case. |
| Comment by Gergely Nagy [ 07/Jan/11 ] |
|
I would like to second this request. Just today, I ran into an issue where I had a string buffer, of which I wanted to insert the first N bytes into a bson buffer, but there was no ready made function for that. I will have a patch ready, that implements _n for the _append functions where it makes sense. GitHub pull request will follow soon after. For the record, my situation is as follows: I take a string, and find patterns in it, whenever a pattern is found, I record the starting position within the string, and the length. Now, I want to put the matches into mongodb. Either I copy the values, which I really do not want to, or I add the _append_n functions. The latter solution is much more preferable, in my opinion, and there's plenty of good reasons to want them anyway. |
| Comment by Stanis?aw Pitucha [ 27/Jul/10 ] |
|
Actually, there could also be a version for non-terminated, known-size `name` for every append function... |