17 #include <boost/bind.hpp>
20 using namespace kome::core;
25 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
26 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
47 m_ranges.back().first.intVal = start;
54 m_ranges.back().first.dblVal = start;
81 return m_ranges[ idx ].second.intVal;
96 return m_ranges[ idx ].second.dblVal;
103 return (
m_type == DEFAULT_ALL );
107 for(
unsigned int i = 0; i <
m_ranges.size(); i++ ) {
108 if( val >=
m_ranges[ i ].first.intVal
109 && val <=
m_ranges[ i ].second.intVal ) {
120 return (
m_type == DEFAULT_ALL );
124 for(
unsigned int i = 0; i <
m_ranges.size(); i++ ) {
125 if( val >=
m_ranges[ i ].first.dblVal
126 && val <=
m_ranges[ i ].second.dblVal ) {
139 std::vector< std::string > tokens;
143 for(
unsigned int i = 0; i < tokens.size(); i++ ) {
145 std::vector< std::string > range;
149 if( range.size() == 1 ) {
150 std::string val =
trimstring( range[ 0 ].c_str() );
152 if(
isint( val.c_str(), 10, &v ) ) {
158 else if( range.size() > 1 ) {
159 std::string val0 =
trimstring( range[ 0 ].c_str() );
160 std::string val1 =
trimstring( range[ 1 ].c_str() );
165 bool ret0 =
isint( val0.c_str(), 10, &v0 );
166 bool ret1 =
isint( val1.c_str(), 10, &v1 );
171 m_ranges.back().first.intVal = ( ret0 ? v0 : INT_MIN );
172 m_ranges.back().second.intVal = ( ret1 ? v1 : INT_MAX );
184 std::vector< std::string > tokens;
188 for(
unsigned int i = 0; i < tokens.size(); i++ ) {
190 std::vector< std::string > range;
194 if( range.size() == 1 ) {
195 std::string val =
trimstring( range[ 0 ].c_str() );
203 else if( range.size() > 1 ) {
204 std::string val0 =
trimstring( range[ 0 ].c_str() );
205 std::string val1 =
trimstring( range[ 1 ].c_str() );
207 double v0 = double();
208 double v1 = double();
210 bool ret0 =
isdouble( val0.c_str(), &v0 );
211 bool ret1 =
isdouble( val1.c_str(), &v1 );
216 m_ranges.back().first.dblVal = ( ret0 ? v0 : - FLT_MAX );
217 m_ranges.back().second.dblVal = ( ret1 ? v1 : FLT_MAX );
229 for(
unsigned int i = 0; i <
m_ranges.size(); i++ ) {
233 int v0 =
m_ranges[ i ].first.intVal;
234 int v1 =
m_ranges[ i ].second.intVal;
237 range = FMT(
"%d", v0 );
240 if( v0 != INT_MIN ) {
241 range = FMT(
"%d", v0 );
246 if( v1 != INT_MAX ) {
247 range = FMT(
"%d", v1 );
267 for(
unsigned int i = 0; i <
m_ranges.size(); i++ ) {
271 double v0 =
m_ranges[ i ].first.dblVal;
272 double v1 =
m_ranges[ i ].second.dblVal;
275 range = FMT(
"%f", v0 );
278 if( v0 != - FLT_MAX ) {
279 range = FMT(
"%f", v0 );
284 if( v1 != FLT_MAX ) {
285 range = FMT(
"%f", v1 );
double getEndDouble(const unsigned int idx)
gets range end value
DefaultType getType()
gets default type
RangeList(const DefaultType type=DEFAULT_NONE)
constructor
void addIntRange(const int start, const int end)
adds integer range
void clearRanges()
clears range
std::string exportIntRanges()
exports integer ranges to character string
bool isdouble(const char *s, double *val)
judge whether sutisfied character string shows real number.
unsigned int stringseparate(const char *s, const char *separator, std::vector< std::string > &tokens)
separates string
void importIntRanges(const char *str)
import integer ranges from character string
std::string trimstring(const char *s)
remove white spaces from both ends of specified string
bool checkIntValue(const int val)
checks integer vlaue
bool isint(const char *s, const int radix, int *val)
judge whether sutisfied character string shows integer number.
interfarces of RangeList class
int getEndInt(const unsigned int idx)
gets range end value
int getStartInt(const unsigned int idx)
gets range start value
void addDoubleRange(const double start, const double end)
adds double range
unsigned int getNumberOfRanges()
gets the number of ranges
void importDoubleRanges(const char *str)
import double ranges from character string
std::string exportDoubleRanges()
exports double ranges to character string
virtual ~RangeList()
destructor
std::vector< std::pair< NumberValue, NumberValue > > m_ranges
double getStartDouble(const unsigned int idx)
gets range start value
bool checkDoubleValue(const double val)
checks double value