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