Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
RangeListSelector.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "RangeListSelector.h"
14 
15 
16 using namespace kome::core;
17 
18 
19 #include <crtdbg.h>
20 #ifdef _DEBUG
21  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
22  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
23 #endif // _DEBUG
24 
25 
26 
27 // constructor
29  : m_type( type ), m_ranges( dflt ) {
30 }
31 
32 // destructor
34 }
35 
36 // get range list object
38  return m_ranges;
39 }
40 
41 // on select
43  const unsigned int num,
44  const char** items,
45  const char** values,
46  bool* selected
47 ) {
48  // each items
49  for( unsigned int i = 0; i < num; i++ ) {
50  // get selected
51  bool sel = false;
52 
53  if( m_type == RANGE_INDEX ) { // index
54  sel = m_ranges.checkIntValue( i );
55  }
56  else if( m_type == RANGE_INT_VALUE ) { // integer value
57  int v = int();
58  if( isint( values[ i ], 10, &v ) ) {
59  sel = m_ranges.checkIntValue( v );
60  }
61  }
62  else if( m_type == RANGE_DOUBLE_VALUE ) { // double value
63  double v = double();
64  if( isdouble( values[ i ], &v ) ) {
65  sel = m_ranges.checkDoubleValue( v );
66  }
67  }
68 
69  selected[ i ] = sel;
70  }
71 
72  return true;
73 }
range list mangement class
Definition: RangeList.h:27
RangeList & getRangeList()
gets ranges list object
DefaultType
default type
Definition: RangeList.h:33
bool isdouble(const char *s, double *val)
judge whether sutisfied character string shows real number.
bool checkIntValue(const int val)
checks integer vlaue
Definition: RangeList.cpp:100
bool isint(const char *s, const int radix, int *val)
judge whether sutisfied character string shows integer number.
interfaces of RangeListSelector class
virtual ~RangeListSelector()
destructor
RangeListSelector(const RangeList::DefaultType dflt=RangeList::DEFAULT_NONE, const RangeType type=RANGE_INDEX)
constructor
virtual bool onSelect(const unsigned int num, const char **items, const char **values, bool *selected)
This method is called by select method. (override method)
bool checkDoubleValue(const double val)
checks double value
Definition: RangeList.cpp:117