~canonical-dx-team/nux/nux.fix-702538

« back to all changes in this revision

Viewing changes to Nux/IntegerValidator.cpp

  • Committer: Jay Taoko
  • Date: 2011-01-04 03:57:29 UTC
  • mfrom: (157.1.13 nux-holidays)
  • Revision ID: jay.taoko@canonical.com-20110104035729-0xh3iabo7e7dk371
* Added support to copy a texture from the current render target
* Blur, Color matrix, Exponent shaders
* Gaussian blur
* Bug fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    :   m_Minimum (Minimum)
31
31
    ,   m_Maximum (Maximum)
32
32
  {
33
 
    m_reg_exp = g_regex_new ("[-+]?[0-9]+", G_REGEX_CASELESS, G_REGEX_MATCH_ANCHORED, NULL);
 
33
    _regexp_str = "^[-+]?[0-9]+$";
 
34
 
 
35
    InitRegExp ();
34
36
 
35
37
    if (m_Minimum > m_Maximum)
36
38
    {
44
46
  {
45
47
    m_Minimum   = copy.m_Minimum;
46
48
    m_Minimum   = copy.m_Maximum;
47
 
    m_reg_exp    = copy.m_reg_exp;
48
 
    g_regex_ref (m_reg_exp);
 
49
    _regexp_str    = copy._regexp_str;
 
50
    InitRegExp ();
49
51
  }
50
52
 
51
53
  IntegerValidator &IntegerValidator::operator= (const IntegerValidator &rhs)
54
56
    {
55
57
      m_Minimum   = rhs.m_Minimum;
56
58
      m_Minimum   = rhs.m_Maximum;
57
 
      m_reg_exp    = rhs.m_reg_exp;
58
 
      g_regex_ref (m_reg_exp);
 
59
      _regexp_str    = rhs._regexp_str;
 
60
      InitRegExp ();
59
61
    }
60
62
 
61
63
    return *this;
63
65
 
64
66
  IntegerValidator::~IntegerValidator()
65
67
  {
66
 
    g_regex_unref (m_reg_exp);
 
68
 
67
69
  }
68
70
 
69
71
  Validator *IntegerValidator::Clone()  const
105
107
    return m_Maximum;
106
108
  }
107
109
 
108
 
  int IntegerValidator::Validate (int i) const
 
110
  int IntegerValidator::GetClampedValue (int i) const
109
111
  {
110
112
    if (i < m_Minimum)
111
113
      return m_Minimum;
116
118
    return i;
117
119
  }
118
120
 
119
 
  Validator::State IntegerValidator::Validate (const TCHAR *str) const
120
 
  {
121
 
    GMatchInfo *match_info;
122
 
 
123
 
    if (!g_regex_match (m_reg_exp, str, G_REGEX_MATCH_ANCHORED, &match_info) )
124
 
    {
125
 
      return Validator::Invalid;
126
 
    }
127
 
 
128
 
    return Validator::Acceptable;
129
 
  }
130
 
 
131
121
  void IntegerValidator::Alternative (const TCHAR *str)
132
122
  {
133
123
    str = TEXT ("0");
146
136
    else
147
137
      return 0;
148
138
  }
149
 
 
150
 
 
151
 
 
152
139
}
 
140