Added the setString method to the string entity object
This commit is contained in:
parent
78231e9228
commit
e74cf22c71
@ -34,7 +34,22 @@ namespace DictionaryHelper
|
||||
strcpy(_string, Object._string);
|
||||
}
|
||||
~StringEntity(){free(_string);}
|
||||
char *getString(){return _string;}
|
||||
const char *getString(){return _string;}
|
||||
void setString(const char *string = NULL)
|
||||
{
|
||||
free(_string);_string = NULL;
|
||||
|
||||
if(string == NULL)
|
||||
{
|
||||
_string = (char *) malloc((sizeof(char)));
|
||||
_string[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_string = (char *) malloc((strlen(string) * sizeof(char)) + 1); //+1 for the string terminating character
|
||||
strcpy(_string, string);
|
||||
}
|
||||
}
|
||||
Dictionary<StringEntity> *split(char character);
|
||||
private:
|
||||
char *_string;
|
||||
|
Loading…
Reference in New Issue
Block a user