XCLE



Strg Object structure and methods

Instructions manual


XCLE: eXtensible Concatenative Language Engine
Copyright (C) 2000-2006 Yann LANDRIN-SCHWEITZER a.k.a. Varkhan


This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Author: Yann LANDRIN-SCHWEITZER
Contact: varkhan@varkhan.net
Homepage: http://www.varkhan.net/


XCLE_Strg object type


Function XCLE_StrgAlloc

XCLE_Strg XCLE_StrgAlloc(unsigned long size) ;
Allocates a new Strg object.

Args:
size: length of allocated Strg


Returns:
NULL: if no memory was available
else a new Strg object, with length 'size', and filled with '\0' chars.


Errors:
EINVAL: if a NULL was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgCopy

XCLE_Strg XCLE_StrgCopy(XCLE_Strg str) ;
Copies a Strg object.

Args:
str: Strg object to copy


Returns:
NULL: if no memory was available
else a complete copy of 'str'.


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available

Note:
XCLE_StrgCopy and XCLE_StrgClone do exactly the same thing.




Function XCLE_StrgClone

XCLE_Strg XCLE_StrgClone(XCLE_Strg str) ;
Clones a Strg object.

Args:
str: Strg object to clone


Returns:
NULL: if no memory was available
else a complete copy of 'str'.


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available

Note:
XCLE_StrgCopy and XCLE_StrgClone do exactly the same thing.




Function XCLE_StrgFree

void XCLE_StrgFree(XCLE_Strg str) ;
Frees a Strg object.

Args:
str: Strg object to free




Function XCLE_StrgNew

XCLE_Strg XCLE_StrgNew(char * chs) ;
Creates a Strg object from a character string (C convention, '\0'-terminated).

Args:
chs: character string to initialize the object from


Returns:
NULL: if no memory was available or 'chs' was NULL.
else a Strg object with the same characters as 'chs'.


Errors:
EINVAL: if a NULL string was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgLen

unsigned long XCLE_StrgLen(XCLE_Strg str) ;
Returns the length of a Strg object.

Args:
str: Strg object to query


Returns:
-1 : if 'str' was NULL
else the Strg length.


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgCat

XCLE_Strg XCLE_StrgCat(XCLE_Strg str1, XCLE_Strg str2) ;
Concatenes two Strg objects, in the arguments' order.

Args:
str1: first part of the concatenated string
str2: last part of the concatenated string


Returns:
NULL: if no memory was available
else the concatenation.


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgCut

XCLE_Strg XCLE_StrgCut(XCLE_Strg str, unsigned long beg, unsigned long end) ;
Extracts a portion of a Strg object.

Args:
str: Strg object to cut from
beg: index of first character of extracted part (beginning at 0)
end: index of first character after extracted part


Returns:
NULL: if no memory was available, or 'beg' > 'end'
a new Strg made form the extracted section.


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgEqual

unsigned char XCLE_StrgEqual(XCLE_Strg str, XCLE_Strg strw) ;
Compares two Strg object.

Args:
str: Strg object to compare
strw: reference Strg object


Returns:
-1: if a NULL Strg was passed as argument
0: if the two Strg were different
+1: if the two Strg were equal


Errors:
EINVAL: if a NULL Strg was passed as argument
ENOMEM: if no memory was available



Function XCLE_StrgValue

unsigned long XCLE_StrgValue(XCLE_Strg str, char * out, unsigned long max) ;
Outputs a Strg characters into a character string.

Args:
str: Strg to copy
out: output character string
max: maximum number of characters to write


Returns:
-1: if no memory was available, a NULL Strg or character string was passed
else the number of character written.


Errors:
EINVAL: if a NULL Strg or character string was passed as argument
ENOMEM: if no memory was available

Note:
This method is distinct from XCLE_StrgOut in that it does not output a representation
of the Strg as an object (i.e. with quotes, and special characters escaped) but the
exact string buffer contents.





Generated by textdoc2html - 2006-02-22