#ifndef CFGPARAMETERVALUE_H
#define CFGPARAMETERVALUE_H

#include <string.h>
#include <stdlib.h>
#include <Arduino.h>
#include "DictionaryInterface.h"

class CFGParameterValue : public DictionaryInterface
{
public:
    CFGParameterValue();
    CFGParameterValue(const char *parameter, const char *value, boolean quotedParameter, boolean quotedValue);
    CFGParameterValue(const char *parameter, const char *value);
    CFGParameterValue(const CFGParameterValue &Object);
    ~CFGParameterValue();
    const char *stringValue() const{return _value == NULL ? "":_value;}
    long longValue() const {return _value == NULL ? 0 : strtol(_value, NULL, 10);}
    int intValue() const {return (int) (_value == NULL ? 0 : strtol(_value, NULL, 10));}
    unsigned long uintValue() const {return _value == NULL ? 0 : strtoul(_value, NULL, 10);}
    double doubleValue() const {return _value == NULL ? 0 : strtod(_value, NULL);}
    float floatValue() const {return _value == NULL ? 0 : strtof(_value, NULL);}
    boolean booleanValue() const
    {
        if(_value == NULL)
            return false;
        return strcmp(_value,"true") == 0 || strcmp(_value,"TRUE") == 0 ? true : false;
    }
    const char *getParameter() const{return _parameter == NULL ? "" : _parameter;}
    const bool isQuotedParameter()const{return _quotedParameter;}
    const bool isQuotedValue()const{return _quotedValue;}
	virtual const char *toString()
    {
        return _value;
    }
protected:
private:
    char *_parameter;
    char *_value;

    bool _quotedParameter;
    bool _quotedValue;

};


#endif //CFGPARAMETERVALUE_H
