00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
#ifndef UVALIDATOR_HPP
00029 
#define UVALIDATOR_HPP
00030 
00031 
#include "uobject.hpp"
00032 
00033 
namespace ufo {
00034 
00039 class UFO_EXPORT UValidator : 
public UObject {
00040     UFO_DECLARE_ABSTRACT_CLASS(UValidator)
00041 
public: 
00042     
enum State {
00043         Invalid = 0,
00044         Intermediate,
00045         Acceptable
00046     };
00047 
public:
00048     
virtual void fixup(std::string * text) 
const = 0;
00049     
virtual State validate(std::string * text, 
int * pos) 
const = 0;
00050 };
00051 
00056 class UFO_EXPORT UIntValidator : 
public UValidator {
00057     UFO_DECLARE_DYNAMIC_CLASS(UIntValidator)
00058 
public:
00060     UIntValidator();
00062     UIntValidator(
int min, 
int max);
00063 
public: 
00064     
virtual void fixup(std::string * text) 
const;
00065     
virtual State validate(std::string * text, 
int * pos) 
const;
00066 
public:
00067     
void setRange(
int min, 
int max);
00068     
int getMinimum() 
const;
00069     
int getMaximum() 
const;
00070 
private:
00071     
int m_min;
00072     
int m_max;
00073 };
00074 
00079 class UFO_EXPORT UDoubleValidator : 
public UValidator {
00080     UFO_DECLARE_DYNAMIC_CLASS(UDoubleValidator)
00081 
public:
00083     UDoubleValidator();
00085     UDoubleValidator(
double min, 
double max, 
int decimals);
00086 
public: 
00087     
virtual void fixup(std::string * text) 
const;
00088     
virtual State validate(std::string * text, 
int * pos) 
const;
00089 
public:
00090     
void setRange(
double min, 
double max);
00091     
double getMinimum() 
const;
00092     
double getMaximum() 
const;
00094     
void setDecimals(
int decimals);
00095     
int getDecimals() 
const;
00096 
private:
00097     
double m_min;
00098     
double m_max;
00099     
int m_decimals;
00100 };
00101 
00102 } 
00103 
00104 
#endif // UVALIDATOR_HPP