#include "CFGParameterValue.h" CFGParameterValue::CFGParameterValue() : DictionaryInterface() { } CFGParameterValue::CFGParameterValue(const char *parameter, const char *value, boolean quotedParameter, boolean quotedValue) : DictionaryInterface(), _quotedParameter(quotedParameter), _quotedValue(quotedValue) { _parameter = (char *) malloc((strlen(parameter) * sizeof(char)) + 1); //+1 for the string terminating character _value = (char *) malloc((strlen(value) * sizeof(char)) + 1); //+1 for the string terminating character strcpy(_parameter, parameter); strcpy(_value, value); } CFGParameterValue::CFGParameterValue(const char *parameter, const char *value) : CFGParameterValue() { _parameter = (char *) malloc((strlen(parameter) * sizeof(char)) + 1); //+1 for the string terminating character _value = (char *) malloc((strlen(value) * sizeof(char)) + 1); //+1 for the string terminating character strcpy(_parameter, parameter); strcpy(_value, value); } CFGParameterValue::CFGParameterValue(const CFGParameterValue &Object) : DictionaryInterface() { _parameter = (char *) malloc((strlen(Object._parameter) * sizeof(char)) + 1); //+1 for the string terminating character _value = (char *) malloc((strlen(Object._value) * sizeof(char)) + 1); //+1 for the string terminating character strcpy(_parameter, Object._parameter); strcpy(_value, Object._value); _quotedParameter = Object._quotedParameter; _quotedValue = Object._quotedValue; } CFGParameterValue::~CFGParameterValue() { free(_parameter); _parameter = NULL; free(_value); _value = NULL; } void CFGParameterValue::setValue(const char *value, bool isQuoted) { _quotedValue = isQuoted; free(_value);_value = NULL; _value = (char *) malloc((strlen(value) * sizeof(char)) + 1); //+1 for the string terminating character strcpy(_value, value); }