1*fce4895dSRene Gollent /* 2*fce4895dSRene Gollent * Copyright 2015, Rene Gollent, rene@gollent.com. 3*fce4895dSRene Gollent * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 4*fce4895dSRene Gollent * Distributed under the terms of the MIT License. 5*fce4895dSRene Gollent */ 6*fce4895dSRene Gollent #include "EnumerationValueFormatter.h" 7*fce4895dSRene Gollent 8*fce4895dSRene Gollent #include "EnumerationValue.h" 9*fce4895dSRene Gollent #include "Type.h" 10*fce4895dSRene Gollent 11*fce4895dSRene Gollent EnumerationValueFormatter(Config * config)12*fce4895dSRene GollentEnumerationValueFormatter::EnumerationValueFormatter(Config* config) 13*fce4895dSRene Gollent : 14*fce4895dSRene Gollent IntegerValueFormatter(config) 15*fce4895dSRene Gollent { 16*fce4895dSRene Gollent } 17*fce4895dSRene Gollent 18*fce4895dSRene Gollent ~EnumerationValueFormatter()19*fce4895dSRene GollentEnumerationValueFormatter::~EnumerationValueFormatter() 20*fce4895dSRene Gollent { 21*fce4895dSRene Gollent } 22*fce4895dSRene Gollent 23*fce4895dSRene Gollent 24*fce4895dSRene Gollent status_t FormatValue(Value * _value,BString & _output)25*fce4895dSRene GollentEnumerationValueFormatter::FormatValue(Value* _value, BString& _output) 26*fce4895dSRene Gollent { 27*fce4895dSRene Gollent Config* config = GetConfig(); 28*fce4895dSRene Gollent if (config != NULL && config->IntegerFormat() == INTEGER_FORMAT_DEFAULT) { 29*fce4895dSRene Gollent EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value); 30*fce4895dSRene Gollent if (value == NULL) 31*fce4895dSRene Gollent return B_BAD_VALUE; 32*fce4895dSRene Gollent 33*fce4895dSRene Gollent if (EnumeratorValue* enumValue 34*fce4895dSRene Gollent = value->GetType()->ValueFor(value->GetValue())) { 35*fce4895dSRene Gollent _output.SetTo(enumValue->Name()); 36*fce4895dSRene Gollent return B_OK; 37*fce4895dSRene Gollent } 38*fce4895dSRene Gollent } 39*fce4895dSRene Gollent 40*fce4895dSRene Gollent return IntegerValueFormatter::FormatValue(_value, _output); 41*fce4895dSRene Gollent } 42