---
name: "sratom"
section: "3"
platform: "linux"
package: "libsratom-doc"
version: "0.6.0~dfsg0-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/sratom"
---

# sratom(3)

Sratom

## NAME

sratom - Sratom

## Detailed Description

An LV2 Atom RDF serialisation library.

### Typedefs

typedef struct SratomImpl **Sratom**\

### Enumerations

enum **SratomObjectMode** { **SRATOM\_OBJECT\_MODE\_BLANK**, **SRATOM\_OBJECT\_MODE\_BLANK\_SUBJECT** }\

### Functions

**Sratom** \* **sratom\_new** (LV2\_URID\_Map \*map)\
 void **sratom\_free** (**Sratom** \*sratom)\
 void **sratom\_set\_env** (**Sratom** \*sratom, SerdEnv \*env)\
 void **sratom\_set\_sink** (**Sratom** \*sratom, const char \*base\_uri, SerdStatementSink sink, SerdEndSink end\_sink, void \*handle)\
 void **sratom\_set\_pretty\_numbers** (**Sratom** \*sratom, bool pretty\_numbers)\
 void **sratom\_set\_object\_mode** (**Sratom** \*sratom, **SratomObjectMode** object\_mode)\
 int **sratom\_write** (**Sratom** \*sratom, LV2\_URID\_Unmap \*unmap, uint32\_t flags, const SerdNode \*subject, const SerdNode \*predicate, uint32\_t type, uint32\_t size, const void \*body)\
 void **sratom\_read** (**Sratom** \*sratom, LV2\_Atom\_Forge \*forge, SordWorld \*world, SordModel \*model, const SordNode \*subject)\
 char \* **sratom\_to\_turtle** (**Sratom** \*sratom, LV2\_URID\_Unmap \*unmap, const char \*base\_uri, const SerdNode \*subject, const SerdNode \*predicate, uint32\_t type, uint32\_t size, const void \*body)\
 LV2\_Atom \* **sratom\_from\_turtle** (**Sratom** \*sratom, const char \*base\_uri, const SerdNode \*subject, const SerdNode \*predicate, const char \*str)\
 LV2\_Atom\_Forge\_Ref **sratom\_forge\_sink** (LV2\_Atom\_Forge\_Sink\_Handle handle, const void \*buf, uint32\_t size)\
 LV2\_Atom \* **sratom\_forge\_deref** (LV2\_Atom\_Forge\_Sink\_Handle handle, LV2\_Atom\_Forge\_Ref ref)\

## Typedef Documentation

### typedef struct SratomImpl Sratom

Atom serialiser.

## Enumeration Type Documentation

### enum SratomObjectMode

Mode for reading resources to LV2 Objects. This affects how resources (which are either blank nodes or have URIs) are read by **sratom\_read()**, since they may be read as simple references (a URI or blank node ID) or a complete description (an atom 'Object').

Currently, blank nodes are always read as Objects, but support for reading blank node IDs may be added in the future.

**Enumerator**

- *SRATOM\_OBJECT\_MODE\_BLANK*

  *Read blank nodes as Objects, and named resources as URIs.*

- *SRATOM\_OBJECT\_MODE\_BLANK\_SUBJECT*

  *Read blank nodes and the main subject as Objects, and any other named resources as URIs. The 'main subject' is the subject parameter passed to* **sratom\_read()***; if this is a resource it will be read as an Object, but all other named resources encountered will be read as URIs.*

## Function Documentation

### Sratom\* sratom\_new (LV2\_URID\_Map \* map)

*Create a new Atom serialiser.*

### void sratom\_free (Sratom \* sratom)

*Free an Atom serialisation.*

### void sratom\_set\_env (Sratom \* sratom, SerdEnv \* env)

*Set the environment for reading or writing Turtle. This can be used to set namespace prefixes and a base URI for* **sratom\_to\_turtle()** *and* **sratom\_from\_turtle()***.*

### void sratom\_set\_sink (Sratom \* sratom, const char \* base\_uri, SerdStatementSink sink, SerdEndSink end\_sink, void \* handle)

*Set the sink(s) where sratom will write its output. This must be called before calling* **sratom\_write()***.*

### void sratom\_set\_pretty\_numbers (Sratom \* sratom, bool pretty\_numbers)

*Write pretty numeric literals. If* `pretty_numbers` *is true, numbers will be written as pretty Turtle literals, rather than string literals with precise types. The cost of this is that the types might get fudged on a round-trip to RDF and back.*

### void sratom\_set\_object\_mode (Sratom \* sratom, SratomObjectMode object\_mode)

*Configure how resources will be read to form LV2 Objects.*

### int sratom\_write (Sratom \* sratom, LV2\_URID\_Unmap \* unmap, uint32\_t flags, const SerdNode \* subject, const SerdNode \* predicate, uint32\_t type, uint32\_t size, const void \* body)

*Write an Atom to RDF. The serialised atom is written to the sink set by* **sratom\_set\_sink()***.*

**Returns:**

*0 on success, or a non-zero error code otherwise.*

### void sratom\_read (Sratom \* sratom, LV2\_Atom\_Forge \* forge, SordWorld \* world, SordModel \* model, const SordNode \* subject)

*Read an Atom from RDF. The resulting atom will be written to* `forge`*.*

### char\* sratom\_to\_turtle (Sratom \* sratom, LV2\_URID\_Unmap \* unmap, const char \* base\_uri, const SerdNode \* subject, const SerdNode \* predicate, uint32\_t type, uint32\_t size, const void \* body)

*Serialise an Atom to a Turtle string. The returned string must be free()'d by the caller.*

### LV2\_Atom\* sratom\_from\_turtle (Sratom \* sratom, const char \* base\_uri, const SerdNode \* subject, const SerdNode \* predicate, const char \* str)

*Read an Atom from a Turtle string. The returned atom must be free()'d by the caller.*

### LV2\_Atom\_Forge\_Ref sratom\_forge\_sink (LV2\_Atom\_Forge\_Sink\_Handle handle, const void \* buf, uint32\_t size)

*A convenient resizing sink for LV2\_Atom\_Forge. The handle must point to an initialized SerdChunk.*

### LV2\_Atom\* sratom\_forge\_deref (LV2\_Atom\_Forge\_Sink\_Handle handle, LV2\_Atom\_Forge\_Ref ref)

*The corresponding deref function for sratom\_forge\_sink.*

## Author

*Generated automatically by Doxygen for Sratom from the source code.*
