PROP_STRING(3)

NAME
prop_string, prop_string_create_copy, prop_string_create_format, prop_string_create_nocopy, prop_string_value, prop_string_copy_value, prop_string_copy, prop_string_size, prop_string_equals, prop_string_equals_string, prop_string_compare, prop_string_compare_string - string value property object

LIBRARY
libprop

SYNOPSIS
#include <prop/proplib.h>
prop_string_t
prop_string_create_copy(const char *cstring);
prop_string_t
prop_string_create_format(const char *fmt, ...);
prop_string_t
prop_string_create_nocopy(const char *cstring);
prop_string_t
prop_string_copy(prop_string_t string);
bool
prop_string_copy_value(prop_string_t string, char *buf, size_t buflen);
size_t
prop_string_size(prop_string_t string);
const char *
prop_string_value(prop_string_t string);
bool
prop_string_equals(prop_string_t str1, prop_string_t str2);
bool
prop_string_equals_string(prop_string_t string, const char *cstring);
int
prop_string_compare(prop_string_t str1, prop_string_t str2);
int
prop_string_compare_string(prop_string_t string, const char *cstring);

DESCRIPTION
The prop_string family of functions operate on a string value property object type.

prop_string_create_copy(const char *cstring)
    Create a string object that contains a copy of cstring. Returns NULL on failure.

prop_string_create_format(const char *fmt, ...)
    Similar to prop_string_create_copy(), but creates the string using the specified printf(3) format.

prop_string_create_nocopy(const char *cstring)
    Similar to prop_string_create_copy(), but is allowed to not create an internal copy of the string data, instead referencing the string data passed by the caller. Caution must be exercised because string objects can have an indefinite lifespan. The caller must therefore ensure that the provided string data reference will also be valid indefinitely. This is provided only as a memory optimization; it is not guaranteed that the returned string object will reference the provided string data, and thus callers should not rely on this behavior. Returns NULL on failure.

prop_string_copy(prop_string_t string)
    Copy a string object. If the string object being copied has an external string buffer reference, then the copy also references the same external string buffer. Returns NULL on failure.

prop_string_size(prop_string_t string)
    Returns the size of the string, not including the terminating NUL; equivalent semantics to strlen(3). If the supplied object isn't a string, zero is returned.

prop_string_value(prop_string_t string)
    Returns a reference to the contents of the string as a C string. If the supplied object isn't a string, NULL is returned.

prop_string_copy_value(prop_string_t string, void *buf, size_t buflen)
    Copies the contents of the string object including the terminating NUL into the supplied buffer of the specified size. Returns true if the copy succeeds and false if the supplied buffer is not large enough or if the object is not a string object.

prop_string_equals(prop_string_t str1, prop_string_t str2)
    Returns true if the two string objects are equivalent.

prop_string_equals_string(prop_string_t string, const char *cstring)
    Returns true if the string's value is equivalent to cstring.

prop_string_compare(prop_string_t str1, prop_string_t str2)
    Compares two strings using strcmp(3) semantics. If either of the two objects are not string objects, an arbitrary non-matching value will be returned.

prop_string_compare_string(prop_string_t string, const char *cstring)
    Compares the a string object to the specified C string using strcmp(3) semantics. If either the object is not a string object, an arbitrary non-matching value will be returned.

SEE ALSO
prop_array(3), prop_bool(3), prop_data(3), prop_dictionary(3), prop_number(3), prop_object(3), proplib(3)

HISTORY
The proplib(3) property container object library first appeared in NetBSD 4.0. Support for mutable string objects was deprecated in NetBSD 10.0.