Statistics
| Branch: | Revision:

root / src / common / enumstr.h @ master

History | View | Annotate | Download (1.23 KB)

1
//==========================================================================
2
//  ENUMSTR.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//==========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17
#ifndef __ENUMSTR_H
18
#define __ENUMSTR_H
19

    
20
#include "commondefs.h"
21

    
22
NAMESPACE_BEGIN
23

    
24
/**
25
 * Loops through numbers in a string like "1,2,5..10", expanding ranges.
26
 * Both ".." and "-" are accepted for ranges.
27
 *
28
 * This is used for implementing the -r command-line option and
29
 * the cmdenv-runs-to-execute= configuration option.
30
 */
31
class COMMON_API EnumStringIterator
32
{
33
     const char *str;  // pointer to the original string (not a copy)
34
     int current, until;
35
     bool err;
36
   public:
37
     EnumStringIterator(const char *s);
38
     int operator++(int);
39
     int operator()() {return err ? -1 : current;}
40
     bool hasError() const {return err;}
41
};
42

    
43
NAMESPACE_END
44

    
45

    
46
#endif