regify utility  2.0.0-0
String Object

A String buffer implementation. This implementation allows for dynamically creating string and appending to them in a reasonably efficient matter. More...

Typedefs

typedef void * ruString
 An opaque data type representing a regify-util string object. More...
 

Functions

RUAPI ruString ruStringNew (const char *instr)
 Creates a new String object from a string. More...
 
RUAPI ruString ruStringNewn (const char *instr, rusize size)
 Creates a new String object of initial size from a string. More...
 
RUAPI ruString ruStringNewf (const char *format,...)
 Creates a new String object from a formatted string. More...
 
RUAPI int32_t ruStringReset (ruString rs)
 Empties the string for reuse without freeing the buffer. More...
 
RUAPI ruString ruStringFree (ruString rs, bool keepBuffer)
 Frees the given String Object object. More...
 
RUAPI int32_t ruStringAppend (ruString rs, const char *str)
 Append given string to String Object. More...
 
RUAPI int32_t ruStringAppendUriEncoded (ruString rs, const char *instr)
 Append given string URI encoded to String Object. More...
 
RUAPI int32_t ruStringAppendn (ruString rs, const char *instr, rusize len)
 Append given string to String Object. More...
 
RUAPI int32_t ruStringAppendf (ruString rs, const char *format,...)
 Appends formatted string to String Object. More...
 
RUAPI char * ruStringGetCString (ruString rs)
 Returns the underlying char* of the given String Object. More...
 
RUAPI rusize ruStringLen (ruString rs, int32_t *code)
 Returns the current length of the String Object. More...
 
RUAPI bool ruStringEndsWith (ruString rs, const char *suffix, int32_t *code)
 Whether String Object ends with given suffix. More...
 

Detailed Description

A String buffer implementation. This implementation allows for dynamically creating string and appending to them in a reasonably efficient matter.

Typedef Documentation

◆ ruString

typedef void* ruString

An opaque data type representing a regify-util string object.

Function Documentation

◆ ruStringAppend()

RUAPI int32_t ruStringAppend ( ruString  rs,
const char *  str 
)

Append given string to String Object.

Parameters
rsString buffer to append string to.
strString to append.
Returns
RUE_OK on success else a regify error code.

◆ ruStringAppendf()

RUAPI int32_t ruStringAppendf ( ruString  rs,
const char *  format,
  ... 
)

Appends formatted string to String Object.

Parameters
rsString buffer to append string to.
formatA general printf format string to format the remaining arguments.
...Any remaining arguments to add to the format string.
Returns
RUE_OK on success else a regify error code.

◆ ruStringAppendn()

RUAPI int32_t ruStringAppendn ( ruString  rs,
const char *  instr,
rusize  len 
)

Append given string to String Object.

Parameters
rsString buffer to append string to.
instrString to append.
lenNumber of bytes of string to append or RU_SIZE_AUTO to use strlen to determine the length
Returns
RUE_OK on success else a regify error code.

◆ ruStringAppendUriEncoded()

RUAPI int32_t ruStringAppendUriEncoded ( ruString  rs,
const char *  instr 
)

Append given string URI encoded to String Object.

Parameters
rsString buffer to append string to.
instrString to append.
Returns
RUE_OK on success else a regify error code.

◆ ruStringEndsWith()

RUAPI bool ruStringEndsWith ( ruString  rs,
const char *  suffix,
int32_t *  code 
)

Whether String Object ends with given suffix.

Parameters
rsString buffer to check.
suffixSuffix to test for.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Whether string ends with suffix.

◆ ruStringFree()

RUAPI ruString ruStringFree ( ruString  rs,
bool  keepBuffer 
)

Frees the given String Object object.

Parameters
rsString to free
keepBufferWhether to also free the underlying char* buffer.

◆ ruStringGetCString()

RUAPI char* ruStringGetCString ( ruString  rs)

Returns the underlying char* of the given String Object.

Parameters
rsString buffer to return buffer of.
Returns
Underlying char* or NULL in case rs was invalid.

◆ ruStringLen()

RUAPI rusize ruStringLen ( ruString  rs,
int32_t *  code 
)

Returns the current length of the String Object.

Parameters
rsString buffer to return the length of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
The length of the string or 0 in case of an error.

◆ ruStringNew()

RUAPI ruString ruStringNew ( const char *  instr)

Creates a new String object from a string.

Parameters
instrString to start object with.
Returns
The newly created String Object object to be freed with ruStringFree or NULL on error. Check ruLastError in case of NULL;

◆ ruStringNewf()

RUAPI ruString ruStringNewf ( const char *  format,
  ... 
)

Creates a new String object from a formatted string.

Parameters
formatA general printf format string to format the remaining arguments.
...Any remaining arguments to add to the format string.
Returns
The newly created String Object object to be freed with ruStringFree or NULL on error. Check ruLastError in case of NULL;

◆ ruStringNewn()

RUAPI ruString ruStringNewn ( const char *  instr,
rusize  size 
)

Creates a new String object of initial size from a string.

Parameters
instrString to start object with.
sizeInitial buffer to allocate. When size is less than the length of instr, only size bytes of instr will be copied.
Returns
The newly created String Object object to be freed with ruStringFree or NULL on error. Check ruLastError in case of NULL;

◆ ruStringReset()

RUAPI int32_t ruStringReset ( ruString  rs)

Empties the string for reuse without freeing the buffer.

Parameters
rsString to reset
Returns
RUE_OK on success else a regify error code.