本文整理汇总了C++中GetPot::next方法的典型用法代码示例。如果您正苦于以下问题:C++ GetPot::next方法的具体用法?C++ GetPot::next怎么用?C++ GetPot::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GetPot
的用法示例。
在下文中一共展示了GetPot::next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_and_get_inputfile
std::string Runner::check_and_get_inputfile(int argc, char* argv[], GetPot & command_line)
{
if( argc < 2 )
{
std::stringstream error_msg;
error_msg << "ERROR: Found only 1 command line argument, but was expecting an inputfile name!"
<< std::endl
<< " Please specify the name of the input file on the command line as the first" << std::endl
<< " command line argument or using the '--input <filename>' option." << std::endl;
libmesh_error_msg(error_msg.str());
}
std::string inputfile_name;
if( command_line.search("--input") )
inputfile_name = command_line.next(std::string("DIE!"));
else
inputfile_name = argv[1];
std::ifstream i(inputfile_name.c_str());
if (!i)
{
std::string error_msg = "Error: Could not read from input file "+inputfile_name+"!\n";
libmesh_error_msg(error_msg);
}
return inputfile_name;
}
示例2: assert_argument
T assert_argument (GetPot &cl,
const std::string &argname,
const char *progname,
const T& defaultarg)
{
if(!cl.search(argname))
{
libMesh::err << ("No " + argname + " argument found!") << std::endl;
usage_error(progname);
}
return cl.next(defaultarg);
}
示例3: get_input_params
void get_input_params(GetPot& field_parser,
libmesh_assemble_input_params& input_params) {
// Set mesh files
if (field_parser.search(1, "Mesh")) {
input_params.mesh_file = field_parser.next(
input_params.mesh_file);
} else {
homemade_error_msg("Missing the system mesh file!");
}
// Set constant parameters
if ( field_parser.search(1, "PhysicalParameters") )
{
input_params.physical_params_file = field_parser.next(input_params.physical_params_file);
}
else
{
homemade_error_msg("Missing the physical parameters file!");
}
// Set weight function
std::string sys_type;
if ( field_parser.search(1, "SystemType") )
{
sys_type = field_parser.next(sys_type);
if(sys_type == "Macro" || sys_type == "MACRO" || sys_type == "macro")
input_params.system_type = WeightFunctionSystemType::MACRO;
else if(sys_type == "Micro" || sys_type == "MICRO" || sys_type == "micro")
input_params.system_type = WeightFunctionSystemType::MICRO;
else if(sys_type == "NoWeight" || sys_type == "NOWEIGHT" || sys_type == "noweight")
{
input_params.system_type = WeightFunctionSystemType::NO_WEIGHT;
std::cout << " >> Warning: Will not use the weight parameters!" << std::endl;
}
else
homemade_error_msg("Invalid system type (must be either Macro, Micro or NoWeight)!");
}
else
{
homemade_error_msg("Missing the system type (must be either Macro, Micro or NoWeight)!");
}
if ( field_parser.search(1, "MeshWeight") )
{
input_params.mesh_weight_file = field_parser.next(input_params.mesh_weight_file);
}
else
{
homemade_error_msg("Missing the weight mesh file!");
}
if( field_parser.search(1, "WeightIndexes") )
{
input_params.weight_domain_idx_file = field_parser.next(input_params.weight_domain_idx_file);
}
else
{
homemade_error_msg("Missing the weight value file!");
}
// Output
if (field_parser.search(2, "--output", "OutputBase"))
{
input_params.output_base = field_parser.next(
input_params.output_base);
} else {
input_params.output_base = "test_system";
}
if (field_parser.search(1, "ExportRBVectors")) {
input_params.bCalculateRBVectors = true;
} else {
input_params.bCalculateRBVectors = false;
}
};
示例4: parseConfig
//.........这里部分代码省略.........
string filelistname=config.follow("list.txt",2,"-f","--filelist");
string result=retriever_.filelist(filelistname,partialLoadingString);
if(result=="filelist FAILURE")
{
ERR << "Error in filelist. Please correct it and start again." << endl;
exit(1);
}
DBG(10) << result << endl;
}
if(config.search(2,"-R","--relevancefile"))
{
relevanceFile_=config.follow("",2,"-R","--relevancefile");
}
retriever_.setScoring("linear");
log_=LogFile(config.follow("",2,"-l","--logfile"));
if(config.search(2,"-D","--defaultdists"))
{
for(uint i=0;i<retriever_.numberOfSuffices();++i)
{
retriever_.dist(i,distanceMaker_.getDefaultDistance(retriever_.featureType(i)));
retriever_.weight(i,1.0);
DBG(10) << "default dist[" << i << "]=" << retriever_.dist(i)->name() << endl;
}
}
config.init_multiple_occurrence(); // can have multiple distances
while(config.search(2,"-d","--dist"))
{
uint idx=config.follow(0,2,"-d","--dist");
string distname=config.next("basedist"); // default distance measure (dummy!)
retriever_.weight(idx,1.0); // set default weight for configured distances
retriever_.dist(idx,distanceMaker_.makeDistance(distname));
DBG(10) << "dist[" << idx << "]=" << retriever_.dist(idx)->name() << endl;
}
config.init_multiple_occurrence(); // can have multiple weights
while(config.search(2,"-w","--weight"))
{
uint idx=config.follow(0,2,"-w","--weight");
double w=config.next(1.0);
retriever_.weight(idx,w);
DBG(10) << "weight[" << idx << "]=" << w << endl;
}
retriever_.setScoring(config.follow("linear",2,"-C","--scoring"));
if(config.search(2,"-I","--interactor"))
{
retriever_.setInteractor(config.follow("",2,"-I","--interactor"));
}
config.enable_loop(); // enable returning to the beginning of command line (was disabled for multiplicity before)
if(config.search(2,"-S","--startAfterInit"))
{
startAfterInit_=config.follow("echo \"No program defined\"",2,"-S","--startAfterInit");
}
if(config.search(2,"-P","--proxy"))
{
proxyhost_=config.follow("localhost",2,"-P","--proxy");
proxyport_=config.next(12963);
DBG(10) << "Will notify proxy at " << proxyhost_ << ":"<<proxyport_ << " about my existence." << endl;