SRS String Functions

SRS 5.1 strings handling as examples of how to pass string pointers around.

Basic rules:

  1. strings must be created before use. Null strings are an error condition in all cases.
  2. strings are returned only if they are being created (== ajStrNew)
  3. strings passed by reference can be changed (new strings, new location)
  4. strings passed by value are constant
  5. pos is the position in the string (0 .. len-1)
  6. len is the length from pos
  7. The string is stored at the end of the STRv data structure, so a single free clears all but it is not possible to change size merely by moving the string pointer so avoid this
  8. The user must delete strings when they are going out of scope.
  9. Temporary strings - similar model to SRS ?
  10. Log everything with counters for use in reporting
  11. Add a status report to the ajExit command
  12. Automatic deletion and allowing null entries for some modifiers?

Function classes

Destructor

decrements count (destroys string if not referenced) and also destroys the string pointer to prevent accidental reuse.

All Functions

Returns		Function	Destroys	Modifies	Given

STRv		StrNew

STRv		StrCpy						STRv

.		StrDel		STRv

.		StrGrow				STRv

.		StrShrink			STRv

.		StrClear			STRv

STRv		StrSub						STRv

STRv		StrLeft						STRv

STRv		StrRight					STRv

.		StrSet				STRv		STRv

.		StrIns				STRv		STRv

.		StrApp				STRv		STRv

.		StrAdd				STRv		STRv

.		StrCut				STRv		STRv

.		StrSubst			STRv		STRv

.		StrDebug					STRv

.		StrUpper			STRv

.		StrLower			STRv

Bool		StrEmpty					STRv

int		StrLen						STRv

Bool		StrEqual					STRv, STRv

int		StrCmp						STRv, STRv

int		StrHash						STRv

char*		StrConst (*)					STRv

char*		StrVal (*)					STRv

char*		StrGet						STRv

int		StrShared					STRv

STRv		StrTemp (*)					char*

STRv		StrCpyS						char*

.		StrSetS				STRv		char*

.		StrInsS				STRv		char*

.		StrAppS				STRv		char*

.		StrAppN				STRv		char*

.		StrAddS				STRv		char*

Bool		StrEqualS					STRv, char*

int		StrCmpS						STRv, char*

int		StrHashS					char*

STRv		StrNCpyS					char*

.		StrNSetS			STRv		char*

STRv		StrBufNew

.		StrBufChange			STRv

STRv		StrFromInt

int		StrToInt					STRv

.		StrCutLF			STRv

STRv		StrPrintf			STRv		char*,...

STRv		StrEncode			STRv

.		StrDecode			STRv

.		StrTranslate			STRv		char*,char*

.		StrFill				STRv

.		StrTrim				STRv

STRv		StrFormat					STRv

STRv		StrReplace (*)			STRv