aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
AgeCommit message (Collapse)AuthorFilesLines
2022-01-28Provide a full output stream implementation for SerdBufferDavid Robillard1-28/+0
Essentially replaces serd_buffer_sink_finish() with serd_buffer_close(), which makes writing to a buffer consistent with writing to a file or anything else.
2022-01-28Put rdf:type properties first when pretty-printingDavid Robillard1-1/+1
This is a common convention in Turtle and TriG because the special "a" syntax for rdf type as the first property looks nice, makes things easier to read, and can be useful for streaming implementations because the type of the instance is known before reading its properties. Also significantly clean up the pretty-printing implementation in the process.
2022-01-28Fix TriG graph indentationDavid Robillard1-5/+10
2022-01-28Ensure that indentation is always reset with the writer contextDavid Robillard1-3/+1
2022-01-28Fix pretty-printing nested empty lists and add test suiteDavid Robillard1-0/+5
The earlier "test" was just hitting the code without actually checking the output. This new suite is a set of pretty-printed documents which serd must reproduce from a model exactly to pass. This should make it easy to add cases in the future, since each case is just a document, as it should look.
2022-01-28Make blank node prefixing automaticDavid Robillard1-29/+1
Though potentially useful, I don't think the complexity cost of the old interface (both to the implementation and to the user) is worth it. A special tool to transform blank node labels (for example with regular expressions) would be a better approach to this if it's ever needed in the future.
2022-01-28Preserve anonymous graph syntax in TriGDavid Robillard1-1/+2
2022-01-28Make serd_writer_set_root_uri() take a string viewDavid Robillard1-3/+3
This is generally more convenient, and the node was just being copied anyway.
2022-01-28Simplify reader and writer flagsDavid Robillard1-4/+4
2022-01-28Support writing all escapes in Turtle and TriG prefixed namesDavid Robillard1-66/+85
2022-01-28Add assertions for all non-null pointers in the public APIDavid Robillard1-0/+18
Clang issues warnings at build time based on the SERD_NONNULL annotations, which is a much better approach in general. However, it does not cover cases where the API is being used with another compiler, or without a compiler that can statically check things at all (such as Python or other dynamic language bindings). In those situations, getting a clear assertion message is a lot less confusing than a random crash somewhere in serd, and it makes it clear that the bug is in the caller, so I think it's worth the tedious verbosity.
2022-01-14Preserve long or short quoting from input documentsDavid Robillard1-2/+1
2022-01-14Add serd_node_from_syntax() and serd_node_to_syntax()David Robillard1-0/+8
2022-01-14Remove SERD_CURIE node datatype entirelyDavid Robillard1-41/+11
2022-01-14Make serd_env_expand_in_place() take a string view instead of a nodeDavid Robillard1-1/+2
2022-01-14Move SerdEnv mutation from writer to readerDavid Robillard1-31/+27
Writing having side-effects seems questionable in general, and this prepares things for expanding URIs in the reader.
2022-01-14Add extensible logging APIDavid Robillard1-19/+33
2022-01-13Add support for parsing variablesDavid Robillard1-0/+15
This adds a reader flag and serdi option for extending a syntax with support for SPARQL-like variables, for storing things like patterns or simple queries.
2022-01-13Split up serd_internal.hDavid Robillard1-1/+0
2022-01-13Factor out TRY macroDavid Robillard1-7/+1
2022-01-13Reduce complexity of string writing functionsDavid Robillard1-78/+98
2022-01-13Reduce complexity of URI node writing functionsDavid Robillard1-21/+38
2022-01-13Reduce complexity of statement writing functionsDavid Robillard1-89/+212
2022-01-13Make Writer always write to a ByteSinkDavid Robillard1-15/+13
2022-01-13Add empty syntax type for suppressing outputDavid Robillard1-11/+10
2022-01-13Use a manual type-safe stack in writerDavid Robillard1-38/+28
This fixes alignment issues on ARM. Since this stack is just for WriteContext which has a fixed size, using SerdStack here just made things more confusing anyway.
2022-01-13Replace SERD_WRITE_STRICT flag with SERD_WRITE_LAXDavid Robillard1-4/+4
The unset value for flags should represent the best default, which in this case is strict parsing. Lax parsing is the riskier opt-in option.
2022-01-13Improve writer error handlingDavid Robillard1-197/+278
2022-01-13Add support for writing terse collectionsDavid Robillard1-11/+24
2022-01-13Tolerate popping writer contexts with no predicateDavid Robillard1-1/+2
2022-01-13Reset writer to empty when finished to avoid spurious blank linesDavid Robillard1-0/+1
2022-01-13Pass context flags to write_sep()David Robillard1-20/+22
2022-01-13Add initial flags to write contextDavid Robillard1-21/+24
2022-01-13Simplify internal writer context APIDavid Robillard1-32/+30
2022-01-13Strengthen writer statement preconditionsDavid Robillard1-1/+3
2022-01-13Add option for writing terse output without newlinesDavid Robillard1-4/+8
2022-01-13Factor out writing top level separatorDavid Robillard1-7/+10
2022-01-13Simplify streaming API and improve pretty printingDavid Robillard1-152/+232
This removes the obligation from the caller to correctly maintain flags to describe the current anonymous context, instead making the writer handle this itself as much as possible. Flags remain for the cases the writer can not infer from context: the start of anonymous subject and object nodes.
2022-01-13Simplify SerdEnv APIDavid Robillard1-2/+2
2022-01-13Separate ByteSink from writerDavid Robillard1-7/+6
2022-01-13Expose SerdByteSink in public APIDavid Robillard1-5/+4
2022-01-13Simplify writer style optionsDavid Robillard1-2/+3
2022-01-13Replace multiple stream callbacks with SerdEventDavid Robillard1-5/+21
This makes plumbing easier since everything goes through the same "stream" and only one callback is required to handling everything. It's also more easily extensible in case more event types need to be added in the future.
2022-01-13Cache commonly used nodes in the worldDavid Robillard1-9/+8
2022-01-13Add SerdStatementDavid Robillard1-6/+8
2022-01-13Add SerdField to public APIDavid Robillard1-47/+41
A statement field enum was previously only used by the writer internally, but will be used in the public API (without a sentinel value) in following commits.
2022-01-13Move error handling to worldDavid Robillard1-27/+17
2022-01-13Add SerdWorld for shared library stateDavid Robillard1-14/+6
2022-01-13Handle writer stack overflows gracefullyDavid Robillard1-7/+18
2022-01-13Add SerdSink interface and hide implementationsDavid Robillard1-5/+18