xref: /haiku/headers/private/debugger/value/value_formatters/IntegerValueFormatter.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1*fce4895dSRene Gollent /*
2*fce4895dSRene Gollent  * Copyright 2015, Rene Gollent, rene@gollent.com.
3*fce4895dSRene Gollent  * Distributed under the terms of the MIT License.
4*fce4895dSRene Gollent  */
5*fce4895dSRene Gollent #ifndef INTEGER_VALUE_FORMATTER_H
6*fce4895dSRene Gollent #define INTEGER_VALUE_FORMATTER_H
7*fce4895dSRene Gollent 
8*fce4895dSRene Gollent 
9*fce4895dSRene Gollent #include "util/IntegerFormatter.h"
10*fce4895dSRene Gollent #include "ValueFormatter.h"
11*fce4895dSRene Gollent 
12*fce4895dSRene Gollent 
13*fce4895dSRene Gollent class Settings;
14*fce4895dSRene Gollent class Value;
15*fce4895dSRene Gollent 
16*fce4895dSRene Gollent 
17*fce4895dSRene Gollent class IntegerValueFormatter : public ValueFormatter {
18*fce4895dSRene Gollent public:
19*fce4895dSRene Gollent 	class Config;
20*fce4895dSRene Gollent 
21*fce4895dSRene Gollent public:
22*fce4895dSRene Gollent 								IntegerValueFormatter(Config* config);
23*fce4895dSRene Gollent 	virtual						~IntegerValueFormatter();
24*fce4895dSRene Gollent 
GetConfig()25*fce4895dSRene Gollent 			Config*				GetConfig() const
26*fce4895dSRene Gollent 									{ return fConfig; }
27*fce4895dSRene Gollent 
28*fce4895dSRene Gollent 	virtual	Settings*			GetSettings() const;
29*fce4895dSRene Gollent 
30*fce4895dSRene Gollent 	virtual	status_t			FormatValue(Value* value, BString& _output);
31*fce4895dSRene Gollent 
32*fce4895dSRene Gollent 	virtual	bool				SupportsValidation() const;
33*fce4895dSRene Gollent 
34*fce4895dSRene Gollent 	virtual	bool				ValidateFormattedValue(
35*fce4895dSRene Gollent 									const BString& input,
36*fce4895dSRene Gollent 									type_code type) const;
37*fce4895dSRene Gollent 
38*fce4895dSRene Gollent 	virtual	status_t			GetValueFromFormattedInput(
39*fce4895dSRene Gollent 									const BString& input, type_code type,
40*fce4895dSRene Gollent 									Value*& _output) const;
41*fce4895dSRene Gollent private:
42*fce4895dSRene Gollent 
43*fce4895dSRene Gollent 			status_t			_PerformValidation(const BString& input,
44*fce4895dSRene Gollent 									type_code type,
45*fce4895dSRene Gollent 									::Value*& _output,
46*fce4895dSRene Gollent 									bool wantsValue) const;
47*fce4895dSRene Gollent 			status_t			_ValidateSigned(const BString& input,
48*fce4895dSRene Gollent 									type_code type,
49*fce4895dSRene Gollent 									::Value*& _output,
50*fce4895dSRene Gollent 									bool wantsValue = false) const;
51*fce4895dSRene Gollent 			status_t			_ValidateUnsigned(const BString& input,
52*fce4895dSRene Gollent 									type_code type,
53*fce4895dSRene Gollent 									::Value*& _output,
54*fce4895dSRene Gollent 									integer_format format,
55*fce4895dSRene Gollent 									bool wantsValue = false) const;
56*fce4895dSRene Gollent 
57*fce4895dSRene Gollent 			Config*				fConfig;
58*fce4895dSRene Gollent };
59*fce4895dSRene Gollent 
60*fce4895dSRene Gollent 
61*fce4895dSRene Gollent class IntegerValueFormatter::Config : public BReferenceable {
62*fce4895dSRene Gollent public:
63*fce4895dSRene Gollent 	virtual						~Config();
64*fce4895dSRene Gollent 
65*fce4895dSRene Gollent 	virtual	Settings*			GetSettings() const = 0;
66*fce4895dSRene Gollent 	virtual	integer_format		IntegerFormat() const = 0;
67*fce4895dSRene Gollent };
68*fce4895dSRene Gollent 
69*fce4895dSRene Gollent 
70*fce4895dSRene Gollent #endif	// INTEGER_VALUE_FORMATTER_H
71