![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
#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"
Go to the source code of this file.
Classes | |
class | ProgOpt |
Defines | |
#define | DECLARE_OPTION_TYPE(T) |
#define | DECLARE_VALUED_OPTION_TYPE(T) |
Enumerations | |
enum | OptType { FLAG = 0, INT, REAL, STRING, INT_VECT } |
Functions | |
template<typename T > | |
static OptType | get_opt_type () |
template<> | |
OptType | get_opt_type< void > () |
template<> | |
OptType | get_opt_type< int > () |
template<> | |
OptType | get_opt_type< double > () |
template<> | |
OptType | get_opt_type< std::string > () |
template<> | |
OptType | get_opt_type< std::vector< int > > () |
static bool | parse_int_list (const char *string, std::vector< int > &results) |
static std::string | do_rank_subst (const std::string &s) |
#define DECLARE_OPTION_TYPE | ( | T | ) |
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.
#define DECLARE_VALUED_OPTION_TYPE | ( | T | ) |
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.
enum OptType |
Definition at line 19 of file ProgOptions.cpp.
{
FLAG = 0,
INT,
REAL,
STRING,
INT_VECT
};
static std::string do_rank_subst | ( | const std::string & | s | ) | [static] |
Definition at line 459 of file ProgOptions.cpp.
References size.
Referenced by ProgOptions::evaluate().
{
#ifndef MOAB_HAVE_MPI
return s;
#else
int rank, size;
if( MPI_SUCCESS != MPI_Comm_rank( MPI_COMM_WORLD, &rank ) || MPI_SUCCESS != MPI_Comm_size( MPI_COMM_WORLD, &size ) )
return s;
int width = 1;
while( size > 10 )
{
size /= 10;
width++;
}
size_t j = s.find( '%' );
if( j == std::string::npos ) return s;
std::ostringstream st;
st << std::setfill( '0' );
st << s.substr( 0, j );
st << rank;
size_t i;
while( ( i = s.find( '%', j + 1 ) ) != std::string::npos )
{
st << s.substr( j, i - j );
st << std::setw( width ) << rank;
j = i;
}
st << s.substr( j + 1 );
return st.str();
#endif
}
static OptType get_opt_type | ( | ) | [inline, static] |
OptType get_opt_type< double > | ( | ) |
OptType get_opt_type< int > | ( | ) |
OptType get_opt_type< std::string > | ( | ) |
Definition at line 47 of file ProgOptions.cpp.
References get_opt_type< std::string >(), and STRING.
Referenced by get_opt_type< std::string >().
{
return STRING;
}
OptType get_opt_type< std::vector< int > > | ( | ) |
OptType get_opt_type< void > | ( | ) |
static bool parse_int_list | ( | const char * | string, |
std::vector< int > & | results | ||
) | [static] |
Definition at line 409 of file ProgOptions.cpp.
Referenced by ProgOptions::evaluate().
{
bool okay = true;
char* mystr = strdup( string );
for( const char* ptr = strtok( mystr, ", \t" ); ptr; ptr = strtok( 0, ", \t" ) )
{
char* endptr;
long val = strtol( ptr, &endptr, 0 );
if( endptr == ptr )
{
std::cerr << "Not an integer: \"" << ptr << '"' << std::endl;
okay = false;
break;
}
long val2 = val;
if( *endptr == '-' )
{
const char* sptr = endptr + 1;
val2 = strtol( sptr, &endptr, 0 );
if( endptr == sptr )
{
std::cerr << "Not an integer: \"" << sptr << '"' << std::endl;
okay = false;
break;
}
if( val2 < val )
{
std::cerr << "Invalid id range: \"" << ptr << '"' << std::endl;
okay = false;
break;
}
}
if( *endptr )
{
okay = false;
break;
}
for( ; val <= val2; ++val )
results.push_back( (int)val );
}
free( mystr );
return okay;
}