UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
The UpnpString Class

Implements string operations in the UPnP library. More...

Classes

struct  s_UpnpString
 Internal implementation of the class UpnpString. More...
 

Typedefs

typedef struct s_UpnpString UpnpString
 Type of the string objects inside libupnp.
 

Functions

PUPNP_Api UpnpStringUpnpString_new (void)
 Constructor.
 
PUPNP_Api void UpnpString_delete (UpnpString *p)
 Destructor.
 
PUPNP_Api UpnpStringUpnpString_dup (const UpnpString *p)
 Copy Constructor.
 
PUPNP_Api void UpnpString_assign (UpnpString *p, const UpnpString *q)
 Assignment operator.
 
PUPNP_Api size_t UpnpString_get_Length (const UpnpString *p)
 Returns the length of the string.
 
PUPNP_Api void UpnpString_set_Length (UpnpString *p, size_t n)
 Truncates the string to the specified lenght, or does nothing if the current lenght is less than or equal to the requested length.
 
PUPNP_Api const char * UpnpString_get_String (const UpnpString *p)
 Returns the pointer to char.
 
PUPNP_Api int UpnpString_set_String (UpnpString *p, const char *s)
 Sets the string from a pointer to char.
 
PUPNP_Api int UpnpString_set_StringN (UpnpString *p, const char *s, size_t n)
 Sets the string from a pointer to char using a maximum of N chars.
 
PUPNP_Api void UpnpString_clear (UpnpString *p)
 Clears the string, sets its size to zero.
 
PUPNP_Api int UpnpString_cmp (UpnpString *p, UpnpString *q)
 Compares two strings for equality. Case matters.
 
PUPNP_Api int UpnpString_casecmp (UpnpString *p, UpnpString *q)
 Compares two strings for equality. Case does not matter.
 
static size_t strnlen (const char *s, size_t n)
 strnlen() is a GNU extension and here provided for portability.
 

Detailed Description

Implements string operations in the UPnP library.

Authors
Marcelo Roberto Jimenez, Ingo Höft
Version
1.0

Due to its heavy use, this class is coded for efficiency, not for beauty. Do not use this as example to other classes. Please take a look at any other one.

Todo:
Always alloc a minimum size like 64 bytes or so and when shrinking do not perform a new memory allocation.

Class Documentation

◆ s_UpnpString

struct s_UpnpString

Internal implementation of the class UpnpString.

Definition at line 74 of file UpnpString.cpp.

Class Members
size_t m_length Length of the string excluding terminating null byte ('\0').
char * m_string Pointer to a dynamically allocated area that holds the NULL terminated string.

Typedef Documentation

◆ UpnpString

typedef struct s_UpnpString UpnpString

Type of the string objects inside libupnp.

Definition at line 37 of file UpnpString.hpp.

Function Documentation

◆ UpnpString_new()

UpnpString * UpnpString_new ( void  )

Constructor.

Returns
A pointer to a new allocated object.

Definition at line 82 of file UpnpString.cpp.

+ Here is the caller graph for this function:

◆ UpnpString_delete()

void UpnpString_delete ( UpnpString p)

Destructor.

Parameters
[in]pThe this pointer.

Definition at line 108 of file UpnpString.cpp.

+ Here is the caller graph for this function:

◆ UpnpString_dup()

UpnpString * UpnpString_dup ( const UpnpString p)

Copy Constructor.

Returns
A pointer to a new allocated copy of the original object.
Parameters
[in]pThe this pointer.

Definition at line 122 of file UpnpString.cpp.

◆ UpnpString_assign()

void UpnpString_assign ( UpnpString p,
const UpnpString q 
)

Assignment operator.

Parameters
[in]pThe this pointer.
[in]qThe that pointer.

Definition at line 143 of file UpnpString.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpnpString_get_Length()

size_t UpnpString_get_Length ( const UpnpString p)

Returns the length of the string.

Returns
The length of the string.
Parameters
[in]pThe this pointer.

Definition at line 149 of file UpnpString.cpp.

+ Here is the caller graph for this function:

◆ UpnpString_set_Length()

void UpnpString_set_Length ( UpnpString p,
size_t  n 
)

Truncates the string to the specified lenght, or does nothing if the current lenght is less than or equal to the requested length.

Parameters
[in]pThe this pointer.
[in]nThe requested length.

Definition at line 155 of file UpnpString.cpp.

◆ UpnpString_get_String()

const char * UpnpString_get_String ( const UpnpString p)

Returns the pointer to char.

Returns
The pointer to char.
Parameters
[in]pThe this pointer.

Definition at line 164 of file UpnpString.cpp.

◆ UpnpString_set_String()

int UpnpString_set_String ( UpnpString p,
const char *  s 
)

Sets the string from a pointer to char.

Parameters
[in]pThe this pointer.
[in]s(char *) to copy from.

Definition at line 171 of file UpnpString.cpp.

◆ UpnpString_set_StringN()

int UpnpString_set_StringN ( UpnpString p,
const char *  s,
size_t  n 
)

Sets the string from a pointer to char using a maximum of N chars.

Parameters
[in]pThe this pointer.
[in]s(char *) to copy from.
nMaximum number of chars to copy.

Definition at line 185 of file UpnpString.cpp.

+ Here is the caller graph for this function:

◆ UpnpString_clear()

void UpnpString_clear ( UpnpString p)

Clears the string, sets its size to zero.

Parameters
[in]pThe this pointer.

Definition at line 199 of file UpnpString.cpp.

+ Here is the caller graph for this function:

◆ UpnpString_cmp()

int UpnpString_cmp ( UpnpString p,
UpnpString q 
)

Compares two strings for equality. Case matters.

Returns
The result of strcmp().
Parameters
[in]pThe the first string.
[in]qThe the second string.

Definition at line 207 of file UpnpString.cpp.

+ Here is the call graph for this function:

◆ UpnpString_casecmp()

int UpnpString_casecmp ( UpnpString p,
UpnpString q 
)

Compares two strings for equality. Case does not matter.

Returns
The result of strcasecmp().
Parameters
[in]pThe the first string.
[in]qThe the second string.

Definition at line 214 of file UpnpString.cpp.

+ Here is the call graph for this function:

◆ strnlen()

static size_t strnlen ( const char *  s,
size_t  n 
)
static

strnlen() is a GNU extension and here provided for portability.

Definition at line 40 of file UpnpString.cpp.