1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Added cString::operator=(const char *String)

This commit is contained in:
Klaus Schmidinger 2010-10-24 13:08:55 +02:00
parent fbbcb8e9c8
commit 1c5ece6100
4 changed files with 14 additions and 2 deletions

View File

@ -2626,3 +2626,6 @@ Cristiano A. Silva <arquithek@gmail.com>
Osama Alrawab <alrawab@hotmail.com> Osama Alrawab <alrawab@hotmail.com>
for adding support for languages that are written right-to-left for adding support for languages that are written right-to-left
for translating OSD texts to the Arabian language for translating OSD texts to the Arabian language
Antti Seppälä <a.seppala@gmail.com>
for suggesting to add cString::operator=(const char *String)

View File

@ -6489,3 +6489,4 @@ Video Disk Recorder Revision History
- Changed the description of cDevice::GetSTC() to make it mandatory for devices - Changed the description of cDevice::GetSTC() to make it mandatory for devices
that can replay. that can replay.
- Removed the check for positive STC values from cDvbSubtitleConverter::Action(). - Removed the check for positive STC values from cDvbSubtitleConverter::Action().
- Added cString::operator=(const char *String) (suggested by Antti Seppälä).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.c 2.9 2010/10/24 11:32:27 kls Exp $ * $Id: tools.c 2.10 2010/10/24 13:07:30 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -885,6 +885,13 @@ cString &cString::operator=(const cString &String)
return *this; return *this;
} }
cString &cString::operator=(const char *String)
{
free(s);
s = String ? strdup(String) : NULL;
return *this;
}
cString &cString::Truncate(int Index) cString &cString::Truncate(int Index)
{ {
int l = strlen(s); int l = strlen(s);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.h 2.4 2009/12/23 15:14:39 kls Exp $ * $Id: tools.h 2.5 2010/10/24 13:06:27 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -171,6 +171,7 @@ public:
operator const char * () const { return s; } // for use in (const char *) context operator const char * () const { return s; } // for use in (const char *) context
const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.) const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.)
cString &operator=(const cString &String); cString &operator=(const cString &String);
cString &operator=(const char *String);
cString &Truncate(int Index); ///< Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string). cString &Truncate(int Index); ///< Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string).
static cString sprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); static cString sprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
static cString sprintf(const char *fmt, va_list &ap); static cString sprintf(const char *fmt, va_list &ap);