FLTK 1.4.0
Fl_String Class Reference

Fl_String is the basic string class for FLTK. More...

#include <Fl_String.H>

Public Member Functions

char * buffer ()
 
int capacity () const
 
void capacity (int num_bytes)
 Set the minumum capacity to num_bytes plus one for a terminating NUL. More...
 
void debug (const char *info=0) const
 Write some details about the string to stdout. More...
 
 Fl_String (const char *str)
 
 Fl_String (const char *str, int size)
 
 Fl_String (const Fl_String &in)
 
void hexdump (const char *info=0) const
 Write some details about the string to stdout, followed by a hex dump of the string. More...
 
Fl_Stringoperator= (const char *in)
 
Fl_Stringoperator= (const Fl_String &in)
 
int size () const
 
int slen () const
 
const char * value () const
 
void value (const char *str)
 
void value (const char *str, int slen)
 

Detailed Description

Fl_String is the basic string class for FLTK.

In this version Fl_String can be used to store strings, copy strings, and move strings. There are no string manipulation methods yet.

Fl_String can hold the value of an Fl_Input widget including nul bytes if the constructor Fl_String(const char *str, int size) is used.

Assignment and copy constructors copy the string value such that the source string can be freed immediately after the assignment.

The string value() can be an empty string "" or NULL.

If value() is not NULL it is guaranteed that the string is terminated by a trailing nul byte even if the string contains embedded nul bytes.

The method size() returns the full string size, whether the string contains embedded nul bytes or not. The special method slen() returns 0 if value() is NULL, otherwise the same as strlen() would do.

Examples:

Fl_String np(NULL);
printf(" np : value = %p, size = %d, slen = %d\n", np.value(), np.size(), np.slen());
Fl_String empty("");
printf(" empty : value = %p, size = %d\n", empty.value(), empty.size());
Fl_String fltk("FLTK");
Fl_Input i(0, 0, 0, 0);
i.value("abc\0def", 7);
Fl_String str(i.value(), i.size());
printf(" str : strlen = %lu, size = %d, capacity = %d\n",
strlen(str.value()), str.size(), str.capacity());
Output:
np : value = (nil), size = 0, slen = 0
empty : value = 0x562840befbf0, size = 0
str : strlen = 3, size = 7, capacity = 15
This is the FLTK text input widget.
Definition: Fl_Input.H:220
Fl_String is the basic string class for FLTK.
Definition: Fl_String.H:70
Since
1.4.0
Todo:
Complete documentation of class Fl_String

Member Function Documentation

◆ capacity()

void Fl_String::capacity ( int  num_bytes)

Set the minumum capacity to num_bytes plus one for a terminating NUL.

The cintents of the string buffer will be copied if needed.

Parameters
num_bytesminimum size of buffer

◆ debug()

void Fl_String::debug ( const char *  info = 0) const

Write some details about the string to stdout.

Nothing at all is written if info is NULL, otherwise the short info string and details are written to stdout.

The info string should not be longer than 20 characters to align the debug output of several strings.

Parameters
[in]infoshort info string or NULL

◆ hexdump()

void Fl_String::hexdump ( const char *  info = 0) const

Write some details about the string to stdout, followed by a hex dump of the string.

The first part is the same as written by Fl_String::debug(). The following part is a hexadecimal dump of all bytes of the string. Embedded nul bytes are possible and will be dumped as well.

Parameters
[in]infoshort info string or NULL
See also
Fl_String::debug(const char *info) const

The documentation for this class was generated from the following files: