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

API: Added printf-style formatted builder functions #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

snej
Copy link
Contributor

@snej snej commented Apr 30, 2021

These functions let you create complex nested Fleece structures with
a single call. It's basically JSON with values substituted from
arguments using printf-style "%" specs. You can

  • Create a mutable array or dict
  • Add to an existing mutable array or dict
  • Write to an encoder

See doc-comments in Fleece.h for details. BuilderTests.cc has a bunch of examples.


API: Added [Core]Foundation-to-Fleece conversions

Unlike the existing FLEncoder_WriteCFObject, these functions create
mutable object trees. They're needed by the formatted builder so it
can accept complex CF/NS values using the %@ specifier.

@snej snej force-pushed the feature/printf branch 2 times, most recently from 0a7efd6 to 70a5f6c Compare May 1, 2021 00:50
Base automatically changed from dev to master May 18, 2021 16:44
@snej snej force-pushed the feature/printf branch 2 times, most recently from 44a9d4b to 47e451c Compare November 3, 2021 18:58
@snej snej requested a review from pasin February 2, 2022 01:12
Copy link
Contributor

@pasin pasin left a comment

Choose a reason for hiding this comment

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

Look great. Found a few small things.

switch ((c = get())) {
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\n'; break;
Copy link
Contributor

Choose a reason for hiding this comment

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

\t ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, fixed. And I added a check for 0x7F (DEL), which counts as a control character.

API/fleece/Fleece.h Outdated Show resolved Hide resolved
@throws an NSException if the object is not of a class that can be converted, or if it
contains such an object.
\note You must call \ref FLValue_Release when finished with the result. */
FLValue FLValue_FromNSObject(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in exp file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@borrrden
Copy link
Member

Is this still valid? A lot of this stuff seems already present.

Unlike the existing `FLEncoder_WriteCFObject`, these functions create
mutable object trees. They're needed by the formatted builder so it
can accept complex CF/NS values using the `%@` specifier.
@snej snej force-pushed the feature/printf branch 2 times, most recently from d9a761d to ef11c42 Compare January 27, 2024 01:08
These functions let you create complex nested Fleece structures with
a single call. It's basically JSON with values substituted from
arguments using printf-style "%" specs.

See comments in Builder.hh for details.
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.

None yet

3 participants