-
Notifications
You must be signed in to change notification settings - Fork 74
Add a const qualified version of search #69
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
Conversation
| * @param[in] query The object keys and array indexes to search for. | ||
| * @param[in] queryLength Length of the key. | ||
| * @param[out] outValue A pointer to receive the address of the value found. | ||
| * @param[out] outValue A pointer to receive the index of the value found. |
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.
Maybe call it outOffset or outValueOffset?
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's already something of a convention that a size_t value or outValue is an index. I don't want to make sweeping changes for only a negligible benefit.
| JSONTypes_t * outType ) | ||
| { | ||
| JSONStatus_t ret; | ||
| size_t value; |
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.
better to call it offset.
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.
See prior comment.
source/include/core_json.h
Outdated
| * @param[out] outType An enum indicating the JSON-specific type of the value. | ||
| */ | ||
| /* @[declare_json_searchtc] */ | ||
| JSONStatus_t JSON_SearchTc( const char * buf, |
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's a JSON_Search API, maybe add another JSON_SearchConst?
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.
changed
Prior attempts to have the search function accept a const buffer and populate a non-const output pointer were problematic, generating MISRA violations. I settled for having the search function use non-const for both. This PR adds a variation of the search function that accepts a const buffer and populates a const output pointer.