EW_String

EW_String

ew

1998 12-05


CLASS

EW_String - general purpose character string


SYNOPSIS

Class EW_String is basically a character string with various editing operations. For this object, string refers to the functional object and buffer refers to the internal pointed-to dynamic array that contains character data.


PUBLIC MEMBER FUNCTIONS


void SetCharSize(long bits)

long GetCharSize(void)
Set/Get the number of bits per character (default: 8).



unsigned int Length(void)
Return the length of the current string.



void NewLength(unsigned int newsize)
Change the length of the string buffer to the specified newsize + 1, truncating if neccessary. The additional character is automatically allocated on the end to account for NULL termination.



long NewBuffer(const char *newbuffer)
Replace the entire buffer with newbuffer. Returns non-zero if successful.



void CopyFromString(EW_String *otherstring)
Copy the data from otherstring to this string.



void CopyToBuffer(char *outbuffer)
Copy the string buffer into outbuffer. The outbuffer must already be allocated large enough to hold the data, including the terminating NULL character.



char *Buffer(void)
Return the pointer to the actual string buffer. This is potentially dangerous, but useful for quick comparisons. The pointer can be invalid after any other member operations and the application should never alter the contents directly through the pointer. Whenever possible, Buffer(long) or Compare(char *) could be used instead.



long Buffer(long position)
Return the single character at the specified position in the string buffer.



long Compare(char *otherbuffer)
Equivalent to strcmp( Buffer(), otherbuffer ). Note that strcmp() returns zero if the two buffers are the same.



long InsertBuffer(long position,char *insertion)

long InsertChar(long position,long c)
Insert a buffer insertion or single character c at the specified position in the string buffer.



long DeleteRange(long position,long number)

long DeleteChar(long position)
Delete (a) character(s) starting at the specified position. DeleteRange() is a superset of the DeleteChar() functionality and allows a specified number of characters to be deleted.


FILES

ew/text.h Font/text header file


SEE ALSO

EW_intro(3), strcmp(3C)


NOTES

The interface conceptually handles any number of bits for a character size. However, the internal functionality restricts the value given in SetCharSize() to values it can handle, currently just 8.


If character sizes other than multiples of eight are permitted, the buffers may pad each character to fill the bytes. This is undecided.