Previous: Reading and writing QLA arrays, Up: I/O utilities


4.7.4 String Handling

The file and record metadata is passed to QDP in QDP_string objects. These can be created, destroyed and converted to/from C strings with the following routines.

Creating an empty QDP string

Syntax QDP_String *QDP_string_create(void);


Meaning Creates an empty string.


Example fileinfo = QDP_string_create();

Destroying a QDP string

Syntax void QDP_string_destroy(QDP_String *xml);


Meaning Frees the QDP_string object and its contents.


Example QDP_string_destroy(xml);

Set a QDP string from a C string

Syntax void QDP_string_set(QDP_String *qstring, char *cstring);


Meaning Sets the QDP string to contain a copy of the null-terminated character array cstring.


Example QDP_string *fileinfo = QDP_string_create();
QDP_string_set(fileinfo, string);

Copying a QDP string

Syntax void QDP_string_copy(QDP_String *dest, QDP_String *src);


Meaning Copies the string.


Example QDP_string_copy(newxml, oldxml);

Accessing the string length

Syntax size_t QDP_string_length(QDP_String *qs);


Meaning Returns the length of the string.


Example length = QDP_string_length(xml);

Accessing the character string

Syntax char *QDP_string_ptr(QDP_String *qs);


Meaning Returns a pointer to the null-terminated character array in the string.


Example printf("%sn", QDP_string_ptr(xml));