Declares the C ABI atom-selection parser interface.
Represents an owned atom-selection evaluator in the C ABI.
A selector shares ownership of the native PSF supplied at construction. The PSF handle is borrowed by apo_atom_selector_create and may be destroyed after creation; the selector keeps the native topology alive independently. The topology is shared rather than cloned, so mutation through another native owner can affect later selections.
Selection calls read host-resident PSF metadata. The set-valued apo_atom_selector_select operation produces an independently owned apo_atom_selection containing zero or more atoms. The exact-one apo_atom_selector_select_atom operation requires exactly one selected atom and produces an independently owned apo_atom_reference that keeps the native PSF alive. No CUDA allocation, transfer, stream work, or synchronization is performed by the selector.
A non-NULL pointer must designate a live handle created by apoCHARMM. Passing a dangling, already-destroyed, or foreign pointer has undefined behavior. The implementation provides no internal locking. Do not overlap destruction with another call, and keep the shared PSF immutable during selection.
Status-returning functions clear the calling thread's previous diagnostic at entry. On failure, call apo_last_error immediately on the same thread; its borrowed pointer remains valid only until another diagnostic-changing C ABI call on that thread.
- See also
- atom_selection
Evaluates one atom-selection expression.
selection_string is parsed as a null-terminated byte string. Keywords and dotted operators use ASCII spellings and case-insensitive matching. The C interface cannot represent an embedded null byte; bytes after the first null are not part of the expression. See Atom Selection and Atom References for fields, wildcards, ranges, precedence, and expansion operators.
- Parameters
-
| [out] | out | Non-NULL address receiving a newly owned selection handle. The function stores NULL before validating other arguments and leaves *out == NULL on every failure path. Release a successful result with apo_atom_selection_destroy. |
| [in] | selector | Borrowed live selector handle. The pointer may not be NULL and is not retained. |
| [in] | selection_string | Borrowed nonempty, null-terminated expression. The bytes are copied during tokenization and are not retained. |
- Return values
-
| APO_STATUS_OK | A new owned selection was stored in *out. |
| APO_STATUS_INVALID_ARGUMENT | out is NULL, selector is NULL, the selector handle contains no native object, selection_string is NULL or empty, the expression has a lexical, syntax, operator, range, or parenthesis error, or a stored PSF bonded-neighbor index is out of range. |
| APO_STATUS_RUNTIME_ERROR | The shared PSF violates parser residue, group, or bonded-connectivity invariants; an internal parser invariant failed; allocation failed; or another unexpected standard or nonstandard C++ exception crossed the boundary. |
- Precondition
- Per-atom PSF metadata arrays remain consistent with the PSF atom count.
- Postcondition
- On success,
*out owns an immutable selection independent of the selector and PSF lifetimes.
-
On failure with a valid
out pointer, *out == NULL.
- Note
- The function clears the previous thread-local diagnostic at entry. Success leaves it empty; failure leaves text available through apo_last_error.
Evaluates one expression that must select exactly one atom.
The same native tokenizer, parser, fields, wildcards, ranges, precedence, and expansion operators used by apo_atom_selector_select are applied. Native AtomSelector code creates a temporary set-valued AtomSelection, validates that its cardinality is exactly one, and then returns the topology-aware atom identity. The temporary selection is destroyed before this function returns.
- Parameters
-
| [out] | out | Non-NULL address receiving a newly owned atom-reference handle. The function stores NULL before validating other arguments and leaves *out == NULL on every failure path. Release a successful result with apo_atom_reference_destroy. |
| [in] | selector | Borrowed live selector handle. The pointer may not be NULL and is not retained. |
| [in] | selection_string | Borrowed nonempty, null-terminated expression. The bytes are copied during tokenization and are not retained. |
- Return values
-
| APO_STATUS_OK | A new owned atom reference was stored in *out. |
| APO_STATUS_INVALID_ARGUMENT | out is NULL, selector is NULL, the selector handle contains no native object, selection_string is NULL or empty, the expression is invalid, a stored PSF bonded-neighbor index is out of range, or the result contains zero or more than one atom. |
| APO_STATUS_RUNTIME_ERROR | The shared PSF violates parser residue, group, or bonded-connectivity invariants; an internal parser invariant failed; allocation failed; or another unexpected standard or nonstandard C++ exception crossed the boundary. |
- Precondition
- Per-atom PSF metadata arrays remain consistent with the PSF atom count.
- Postcondition
- On success,
*out owns one immutable topology-aware atom reference that remains valid after the selector and public PSF handles are destroyed.
-
On failure with a valid
out pointer, *out == NULL.
- Note
- The function clears the previous thread-local diagnostic at entry. Success leaves it empty; failure leaves text available through apo_last_error.