/******************************************************************************* | |
* Copyright (c) 2010 Nokia and others. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Nokia - Initial API and implementation. Feb 26, 2010 | |
*******************************************************************************/ | |
#ifndef PROPERTYVALUE_H_ | |
#define PROPERTYVALUE_H_ | |
#include <map> | |
#include <string> | |
#include "TCFOutputStream.h" | |
enum PropertyType { | |
PVT_UNKNOWN, | |
PVT_INT, | |
PVT_ULONG_INT, | |
PVT_BOOL, | |
PVT_STRING | |
}; | |
class PropertyValue { | |
public: | |
PropertyValue(); | |
PropertyValue(const PropertyValue &src); | |
PropertyValue(int x); | |
PropertyValue(unsigned long int x); | |
PropertyValue(bool x); | |
PropertyValue(const char *x); | |
PropertyValue(const std::string& x); | |
PropertyType getType(); | |
int getIntValue(); | |
unsigned long int getUnsignedLongIntValue(); | |
bool getBoolValue(); | |
const std::string& getStringValue(); | |
void writeToTCFChannel(TCFOutputStream& tcf_stream) const; | |
void log() const; | |
private: | |
PropertyType type; | |
union { | |
int v_int; | |
unsigned long int v_ulong_int; | |
bool v_bool; | |
} v; | |
// "std::string" is not allowed to be in a union. | |
// But I still prefer std::string to char* for easier memory management. | |
std::string v_string; | |
}; | |
typedef std::map<std::string, PropertyValue> Properties; | |
void logProperties(Properties& properties); | |
#endif /* PROPERTYVALUE_H_ */ |