libUPnP 1.14.19
Files | Data Structures | Typedefs | Functions | Variables
The UpnpString Class

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

Files

file  UpnpString.h
 UpnpString object declaration.
 
file  UpnpString.c
 UpnpString object implementation.
 

Data Structures

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

Typedefs

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

Functions

UpnpStringUpnpString_new (void)
 Constructor.
 
void UpnpString_delete (UpnpString *p)
 Destructor.
 
UpnpStringUpnpString_dup (const UpnpString *p)
 Copy Constructor.
 
void UpnpString_assign (UpnpString *p, const UpnpString *q)
 Assignment operator.
 
size_t UpnpString_get_Length (const UpnpString *p)
 Returns the length of the string.
 
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.
 
const char * UpnpString_get_String (const UpnpString *p)
 Returns the pointer to char.
 
int UpnpString_set_String (UpnpString *p, const char *s)
 Sets the string from a pointer to char.
 
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.
 
void UpnpString_clear (UpnpString *p)
 Clears the string, sets its size to zero.
 
int UpnpString_cmp (UpnpString *p, UpnpString *q)
 Compares two strings for equality. Case matters.
 
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)
 
static char * strndup (const char *__string, size_t __n)
 

Variables

size_t SUpnpString::m_length
 Length of the string.
 
char * SUpnpString::m_string
 Pointer to a dynamically allocated area that holds the NULL terminated string.
 

Detailed Description

Implements string operations in the UPnP library.

Author
Marcelo Roberto Jimenez
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.

Typedef Documentation

◆ UpnpString

typedef struct s_UpnpString UpnpString

Type of the string objects inside libupnp.

Function Documentation

◆ UpnpString_assign()

void UpnpString_assign ( UpnpString p,
const UpnpString q 
)

Assignment operator.

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

References UpnpString_get_String(), and UpnpString_set_String().

Referenced by genaSubscribe().

◆ 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.

References UpnpString_get_String().

◆ UpnpString_clear()

void UpnpString_clear ( UpnpString p)

◆ 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.

References UpnpString_get_String().

◆ UpnpString_delete()

void UpnpString_delete ( UpnpString p)

◆ 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.

References SUpnpString::m_length, and SUpnpString::m_string.

◆ 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.

Referenced by gena_subscribe(), gena_unsubscribe(), GenlibClientSubscription_get_ActualSID_Length(), GenlibClientSubscription_get_EventURL_Length(), GenlibClientSubscription_get_SID_Length(), handle_query_variable(), ssdp_handle_ctrlpt_msg(), TestClass_get_TheString_Length(), UpnpActionComplete_get_CtrlUrl_Length(), UpnpActionRequest_get_ActionName_Length(), UpnpActionRequest_get_DevUDN_Length(), UpnpActionRequest_get_ErrStr_Length(), UpnpActionRequest_get_Os_Length(), UpnpActionRequest_get_ServiceID_Length(), UpnpDiscovery_get_Date_Length(), UpnpDiscovery_get_DeviceID_Length(), UpnpDiscovery_get_DeviceType_Length(), UpnpDiscovery_get_Ext_Length(), UpnpDiscovery_get_Location_Length(), UpnpDiscovery_get_Os_Length(), UpnpDiscovery_get_ServiceType_Length(), UpnpDiscovery_get_ServiceVer_Length(), UpnpEvent_get_SID_Length(), UpnpEventSubscribe_get_PublisherUrl_Length(), UpnpEventSubscribe_get_SID_Length(), UpnpExtraHeaders_get_name_Length(), UpnpExtraHeaders_get_value_Length(), UpnpFileInfo_get_Os_Length(), UpnpStateVarComplete_get_CtrlUrl_Length(), UpnpStateVarComplete_get_StateVarName_Length(), UpnpStateVarRequest_get_DevUDN_Length(), UpnpStateVarRequest_get_ErrStr_Length(), UpnpStateVarRequest_get_ServiceID_Length(), UpnpStateVarRequest_get_StateVarName_Length(), UpnpSubscriptionRequest_get_ServiceId_Length(), UpnpSubscriptionRequest_get_SID_Length(), and UpnpSubscriptionRequest_get_UDN_Length().

◆ 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.

Referenced by gena_subscribe(), gena_unsubscribe(), GenlibClientSubscription_get_ActualSID_cstr(), GenlibClientSubscription_get_EventURL_cstr(), GenlibClientSubscription_get_SID_cstr(), GenlibClientSubscription_set_ActualSID(), GenlibClientSubscription_set_EventURL(), GenlibClientSubscription_set_SID(), GetClientSubClientSID(), RemoveClientSubClientSID(), SampleUtil_PrintEvent(), TestClass_get_TheString_cstr(), TestClass_set_TheString(), TvDeviceHandleActionRequest(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), UpnpActionComplete_get_CtrlUrl_cstr(), UpnpActionComplete_set_CtrlUrl(), UpnpActionRequest_get_ActionName_cstr(), UpnpActionRequest_get_DevUDN_cstr(), UpnpActionRequest_get_ErrStr_cstr(), UpnpActionRequest_get_Os_cstr(), UpnpActionRequest_get_ServiceID_cstr(), UpnpActionRequest_set_ActionName(), UpnpActionRequest_set_DevUDN(), UpnpActionRequest_set_ErrStr(), UpnpActionRequest_set_Os(), UpnpActionRequest_set_ServiceID(), UpnpDiscovery_get_Date_cstr(), UpnpDiscovery_get_DeviceID_cstr(), UpnpDiscovery_get_DeviceType_cstr(), UpnpDiscovery_get_Ext_cstr(), UpnpDiscovery_get_Location_cstr(), UpnpDiscovery_get_Os_cstr(), UpnpDiscovery_get_ServiceType_cstr(), UpnpDiscovery_get_ServiceVer_cstr(), UpnpDiscovery_set_Date(), UpnpDiscovery_set_DeviceID(), UpnpDiscovery_set_DeviceType(), UpnpDiscovery_set_Ext(), UpnpDiscovery_set_Location(), UpnpDiscovery_set_Os(), UpnpDiscovery_set_ServiceType(), UpnpDiscovery_set_ServiceVer(), UpnpEvent_get_SID_cstr(), UpnpEvent_set_SID(), UpnpEventSubscribe_get_PublisherUrl_cstr(), UpnpEventSubscribe_get_SID_cstr(), UpnpEventSubscribe_set_PublisherUrl(), UpnpEventSubscribe_set_SID(), UpnpExtraHeaders_get_name_cstr(), UpnpExtraHeaders_get_value_cstr(), UpnpExtraHeaders_set_name(), UpnpExtraHeaders_set_value(), UpnpFileInfo_get_Os_cstr(), UpnpFileInfo_set_Os(), UpnpStateVarComplete_get_CtrlUrl_cstr(), UpnpStateVarComplete_get_StateVarName_cstr(), UpnpStateVarComplete_set_CtrlUrl(), UpnpStateVarComplete_set_StateVarName(), UpnpStateVarRequest_get_DevUDN_cstr(), UpnpStateVarRequest_get_ErrStr_cstr(), UpnpStateVarRequest_get_ServiceID_cstr(), UpnpStateVarRequest_get_StateVarName_cstr(), UpnpStateVarRequest_set_DevUDN(), UpnpStateVarRequest_set_ErrStr(), UpnpStateVarRequest_set_ServiceID(), UpnpStateVarRequest_set_StateVarName(), UpnpString_assign(), UpnpString_casecmp(), UpnpString_cmp(), UpnpSubscribe(), UpnpSubscriptionRequest_get_ServiceId_cstr(), UpnpSubscriptionRequest_get_SID_cstr(), UpnpSubscriptionRequest_get_UDN_cstr(), UpnpSubscriptionRequest_set_ServiceId(), UpnpSubscriptionRequest_set_SID(), and UpnpSubscriptionRequest_set_UDN().

◆ UpnpString_new()

UpnpString * UpnpString_new ( void  )

◆ 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.

References SUpnpString::m_length.

◆ 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.

References SUpnpString::m_string.

Referenced by genaSubscribe(), GenlibClientSubscription_set_ActualSID(), GenlibClientSubscription_set_EventURL(), GenlibClientSubscription_set_SID(), GenlibClientSubscription_strcpy_ActualSID(), GenlibClientSubscription_strcpy_EventURL(), GenlibClientSubscription_strcpy_SID(), TestClass_set_TheString(), TestClass_strcpy_TheString(), UpnpActionComplete_set_CtrlUrl(), UpnpActionComplete_strcpy_CtrlUrl(), UpnpActionRequest_set_ActionName(), UpnpActionRequest_set_DevUDN(), UpnpActionRequest_set_ErrStr(), UpnpActionRequest_set_Os(), UpnpActionRequest_set_ServiceID(), UpnpActionRequest_strcpy_ActionName(), UpnpActionRequest_strcpy_DevUDN(), UpnpActionRequest_strcpy_ErrStr(), UpnpActionRequest_strcpy_Os(), UpnpActionRequest_strcpy_ServiceID(), UpnpDiscovery_set_Date(), UpnpDiscovery_set_DeviceID(), UpnpDiscovery_set_DeviceType(), UpnpDiscovery_set_Ext(), UpnpDiscovery_set_Location(), UpnpDiscovery_set_Os(), UpnpDiscovery_set_ServiceType(), UpnpDiscovery_set_ServiceVer(), UpnpDiscovery_strcpy_Date(), UpnpDiscovery_strcpy_DeviceID(), UpnpDiscovery_strcpy_DeviceType(), UpnpDiscovery_strcpy_Ext(), UpnpDiscovery_strcpy_Location(), UpnpDiscovery_strcpy_Os(), UpnpDiscovery_strcpy_ServiceType(), UpnpDiscovery_strcpy_ServiceVer(), UpnpEvent_set_SID(), UpnpEvent_strcpy_SID(), UpnpEventSubscribe_set_PublisherUrl(), UpnpEventSubscribe_set_SID(), UpnpEventSubscribe_strcpy_PublisherUrl(), UpnpEventSubscribe_strcpy_SID(), UpnpExtraHeaders_set_name(), UpnpExtraHeaders_set_value(), UpnpExtraHeaders_strcpy_name(), UpnpExtraHeaders_strcpy_value(), UpnpFileInfo_set_Os(), UpnpFileInfo_strcpy_Os(), UpnpRenewSubscription(), UpnpStateVarComplete_set_CtrlUrl(), UpnpStateVarComplete_set_StateVarName(), UpnpStateVarComplete_strcpy_CtrlUrl(), UpnpStateVarComplete_strcpy_StateVarName(), UpnpStateVarRequest_set_DevUDN(), UpnpStateVarRequest_set_ErrStr(), UpnpStateVarRequest_set_ServiceID(), UpnpStateVarRequest_set_StateVarName(), UpnpStateVarRequest_strcpy_DevUDN(), UpnpStateVarRequest_strcpy_ErrStr(), UpnpStateVarRequest_strcpy_ServiceID(), UpnpStateVarRequest_strcpy_StateVarName(), UpnpString_assign(), UpnpSubscribe(), UpnpSubscriptionRequest_set_ServiceId(), UpnpSubscriptionRequest_set_SID(), UpnpSubscriptionRequest_set_UDN(), UpnpSubscriptionRequest_strcpy_ServiceId(), UpnpSubscriptionRequest_strcpy_SID(), UpnpSubscriptionRequest_strcpy_UDN(), and UpnpUnSubscribe().

◆ UpnpString_set_StringN()

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

Variable Documentation

◆ m_length

size_t SUpnpString::m_length

◆ m_string

char* SUpnpString::m_string

Pointer to a dynamically allocated area that holds the NULL terminated string.

Referenced by UpnpString_delete(), UpnpString_dup(), UpnpString_new(), UpnpString_set_String(), and UpnpString_set_StringN().