#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <list>
#include <limits>
#include <set>
#include <algorithm>
#include <cassert>
#include <cstring>
#include "moab/MOABConfig.h"
#include "moab/ProgOptions.hpp"
#include "moab_mpi.h"
Go to the source code of this file.
◆ DECLARE_OPTION_TYPE
#define DECLARE_OPTION_TYPE |
( |
|
T | ) |
|
Value: template void ProgOptions::addOpt< T >( const std::string&, const std::string&, T*, int ); \
template bool ProgOptions::getOpt< T >( const std::string&, T* );
Definition at line 1029 of file ProgOptions.cpp.
◆ DECLARE_VALUED_OPTION_TYPE
#define DECLARE_VALUED_OPTION_TYPE |
( |
|
T | ) |
|
Value: DECLARE_OPTION_TYPE( T ) \
template void ProgOptions::getOptAllArgs< T >( const std::string&, std::vector< T >& ); \
template void ProgOptions::addRequiredArg< T >( const std::string&, const std::string&, T*, int ); \
template void ProgOptions::addOptionalArgs< T >( unsigned, const std::string&, const std::string&, int ); \
template T ProgOptions::getReqArg< T >( const std::string& ); \
template void ProgOptions::getArgs< T >( const std::string&, std::vector< T >& );
Definition at line 1033 of file ProgOptions.cpp.
◆ OptType
Enumerator |
---|
FLAG | |
INT | |
REAL | |
STRING | |
INT_VECT | |
Definition at line 19 of file ProgOptions.cpp.
20 {
21 FLAG = 0,
22 INT,
23 REAL,
24 STRING,
25 INT_VECT
26 };
◆ do_rank_subst()
static std::string do_rank_subst |
( |
const std::string & |
s | ) |
|
|
static |
Definition at line 459 of file ProgOptions.cpp.
460 {
461 #ifndef MOAB_HAVE_MPI
462 return s;
463 #else
464 int rank, size;
465 if( MPI_SUCCESS != MPI_Comm_rank( MPI_COMM_WORLD, &rank ) || MPI_SUCCESS != MPI_Comm_size( MPI_COMM_WORLD, &size ) )
466 return s;
467 int width = 1;
468 while( size > 10 )
469 {
470 size /= 10;
471 width++;
472 }
473
474 size_t j = s.find( '%' );
475 if( j == std::string::npos ) return s;
476
477 std::ostringstream st;
478 st << std::setfill( '0' );
479 st << s.substr( 0, j );
480 st << rank;
481
482 size_t i;
483 while( ( i = s.find( '%', j + 1 ) ) != std::string::npos )
484 {
485 st << s.substr( j, i - j );
486 st << std::setw( width ) << rank;
487 j = i;
488 }
489 st << s.substr( j + 1 );
490 return st.str();
491 #endif
492 }
References size.
Referenced by ProgOptions::evaluate().
◆ get_opt_type()
◆ get_opt_type< double >()
◆ get_opt_type< int >()
◆ get_opt_type< std::string >()
◆ get_opt_type< std::vector< int > >()
◆ get_opt_type< void >()
◆ parse_int_list()
static bool parse_int_list |
( |
const char * |
string, |
|
|
std::vector< int > & |
results |
|
) |
| |
|
static |
Definition at line 409 of file ProgOptions.cpp.
410 {
411 bool okay = true;
412 char* mystr = strdup( string );
413 for( const char* ptr = strtok( mystr, ", \t" ); ptr; ptr = strtok( 0, ", \t" ) )
414 {
415 char* endptr;
416 long val = strtol( ptr, &endptr, 0 );
417 if( endptr == ptr )
418 {
419 std::cerr << "Not an integer: \"" << ptr << '"' << std::endl;
420 okay = false;
421 break;
422 }
423
424 long val2 = val;
425 if( *endptr == '-' )
426 {
427 const char* sptr = endptr + 1;
428 val2 = strtol( sptr, &endptr, 0 );
429 if( endptr == sptr )
430 {
431 std::cerr << "Not an integer: \"" << sptr << '"' << std::endl;
432 okay = false;
433 break;
434 }
435 if( val2 < val )
436 {
437 std::cerr << "Invalid id range: \"" << ptr << '"' << std::endl;
438 okay = false;
439 break;
440 }
441 }
442
443 if( *endptr )
444 {
445 okay = false;
446 break;
447 }
448
449 for( ; val <= val2; ++val )
450 results.push_back( (int)val );
451 }
452
453 free( mystr );
454 return okay;
455 }
Referenced by ProgOptions::evaluate().