Skip to content
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

add Key() method to the Handler concept #134

Merged
merged 11 commits into from
Sep 5, 2014

Conversation

Kosta-Github
Copy link
Contributor

For more details see: #132

This commit tries to minimize the required code changes and forwards the Handler::Key() calls to Handler::String() wherever possible in order to not break existing code; or at least not code deriving from BaseReaderHandler when implementing a custom Handler.

For more details see: Tencent#132

This commit tries to minimize the required code changes and forwards the `Handler::Key()` calls to `Handler::String()` wherever possible in order to not break existing code; or at least not code deriving from `BaseReaderHandler` when implementing a custom `Handler`.
@Kosta-Github
Copy link
Contributor Author

This is the absolute minimal set of changes I can come up with to get all the unit tests compile and pass as well as all the sample snippets...

@@ -17,6 +17,7 @@ struct MyHandler {
return true;
}
bool StartObject() { cout << "StartObject()" << endl; return true; }
bool Key(const char* str, SizeType length, bool copy) { return String(str, length, copy); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyHandler should inherit from BaseReaderhandler (which would provide this forwarding already):

struct MyHandler : BaseReaderHandler<UTF8<>, MyHandler> {

Secondly, if you add the explicit handler function, you should probably print "Key(" ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said: this is the absolute minimum to get started.

now the door is open for improvements...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pah do you suggest to derive all the custom Handlers that needed the forwarding Key() -> String() call from BaseReaderHandler?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I would suggest this as the preferred solution to the API change in the documentation. And we should eat our own dog food.

} else {
if (!handler.String(stack_.template Pop<typename TargetEncoding::Ch>(stackStream.length_), stackStream.length_ - 1, true))
RAPIDJSON_PARSE_ERROR(kParseErrorTermination, s.Tell());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment in #133.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one is calling handler.Key() and the other handler.String() ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm calling Key() and String() in my comment, too.

@pah
Copy link
Contributor

pah commented Sep 4, 2014

LGTM now. 👍

miloyip added a commit that referenced this pull request Sep 5, 2014
add `Key()` method to the `Handler` concept
@miloyip miloyip merged commit 5e03cbf into Tencent:master Sep 5, 2014
@Kosta-Github Kosta-Github deleted the Kosta/add_key_method branch September 5, 2014 08:36
pah added a commit to pah/nativejson-benchmark that referenced this pull request Sep 9, 2014
Inherit from BaseReaderHandler<> to properly handle calls to
the new `Key` function after updating RapidJSON to a current
version (see Tencent/rapidjson#132, Tencent/rapidjson#134).
bj174f7 added a commit to bj174f7/nativejson-benchmark that referenced this pull request Sep 11, 2024
Inherit from BaseReaderHandler<> to properly handle calls to
the new `Key` function after updating RapidJSON to a current
version (see Tencent/rapidjson#132, Tencent/rapidjson#134).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants