189077Sache/*
289077Sache * Copyright 2015, Rene Gollent, rene@gollent.com.
389077Sache * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
489077Sache * Distributed under the terms of the MIT License.
589077Sache */
689077Sache#include "EnumerationValueFormatter.h"
789077Sache
889077Sache#include "EnumerationValue.h"
989077Sache#include "Type.h"
1089077Sache
1189077Sache
1289077SacheEnumerationValueFormatter::EnumerationValueFormatter(Config* config)
1389077Sache	:
1489077Sache	IntegerValueFormatter(config)
1589077Sache{
1689077Sache}
1789077Sache
1889077Sache
1989077SacheEnumerationValueFormatter::~EnumerationValueFormatter()
2089077Sache{
2189077Sache}
2289077Sache
2389077Sache
2489077Sachestatus_t
2589077SacheEnumerationValueFormatter::FormatValue(Value* _value, BString& _output)
2689077Sache{
2789077Sache	Config* config = GetConfig();
2889077Sache	if (config != NULL && config->IntegerFormat() == INTEGER_FORMAT_DEFAULT) {
2989077Sache		EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value);
3089077Sache		if (value == NULL)
3189077Sache			return B_BAD_VALUE;
3289077Sache
3389077Sache		if (EnumeratorValue* enumValue
3489077Sache				= value->GetType()->ValueFor(value->GetValue())) {
3589077Sache			_output.SetTo(enumValue->Name());
3689077Sache			return B_OK;
37		}
38	}
39
40	return IntegerValueFormatter::FormatValue(_value, _output);
41}
42