本文整理汇总了C++中ConfigReader类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigReader类的具体用法?C++ ConfigReader怎么用?C++ ConfigReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadPossibleModelPartition
bool GeneralGamlConfig::ReadPossibleModelPartition(ConfigReader &cr){
string origSection = cr.GetCurrentSection();
bool foundAnyModels = false;
for(int modelNum = 0; ;modelNum++){
char modName[10];
sprintf(modName, "model%d", modelNum);
int found = cr.SetSection(modName);
//models need to appear consecuatively, but can start at 0 (old) or 1 (new)
if(modelNum == 0 && found < 0){
continue;
}
else if(found < 0){
cr.SetSection(origSection.c_str());
return foundAnyModels;
}
else{
foundAnyModels = true;
ConfigModelSettings configModSet;
cr.GetStringOption("ratehetmodel", configModSet.rateHetModel, true);
cr.GetUnsignedOption("numratecats", configModSet.numRateCats, true);
cr.GetStringOption("statefrequencies", configModSet.stateFrequencies, true);
cr.GetStringOption("ratematrix", configModSet.rateMatrix, true);
cr.GetStringOption("invariantsites", configModSet.proportionInvariant, true);
cr.GetStringOption("datatype", configModSet.datatype, true);
cr.GetStringOption("geneticcode", configModSet.geneticCode, true);
configModelSets.push_back(configModSet);
}
}
//we shouldn't be getting to here
return false;
}
示例2: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
ConfigReader *Conf = new ConfigReader(ServerInstance);
for (int index = 0; index < Conf->Enumerate("vhost"); index++)
{
std::string mask = Conf->ReadValue("vhost","host",index);
std::string username = Conf->ReadValue("vhost","user",index);
std::string pass = Conf->ReadValue("vhost","pass",index);
std::string hash = Conf->ReadValue("vhost","hash",index);
if ((!strcmp(parameters[0].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()))
{
if (!mask.empty())
{
user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
user->ChangeDisplayedHost(mask.c_str());
delete Conf;
return CMD_LOCALONLY;
}
}
}
user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
delete Conf;
return CMD_FAILURE;
}
示例3: ModuleRandQuote
ModuleRandQuote(InspIRCd* Me)
: Module(Me)
{
conf = new ConfigReader(ServerInstance);
// Sort the Randomizer thingie..
srand(time(NULL));
q_file = conf->ReadValue("randquote","file",0);
prefix = conf->ReadValue("randquote","prefix",0);
suffix = conf->ReadValue("randquote","suffix",0);
mycommand = NULL;
if (q_file.empty())
{
RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
throw(e);
}
quotes = new FileReader(ServerInstance, q_file);
if(!quotes->Exists())
{
RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
throw(e);
}
else
{
/* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
mycommand = new cmd_randquote(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
}
示例4: ReadConfig
virtual void ReadConfig()
{
ConfigReader *MyConf = new ConfigReader(ServerInstance);
helpop_map.clear();
for (int i = 0; i < MyConf->Enumerate("helpop"); i++)
{
irc::string key = assign(MyConf->ReadValue("helpop", "key", i));
std::string value = MyConf->ReadValue("helpop", "value", i, true); /* Linefeeds allowed! */
if (key == "index")
{
throw ModuleException("m_helpop: The key 'index' is reserved for internal purposes. Please remove it.");
}
helpop_map[key] = value;
}
if (helpop_map.find("start") == helpop_map.end())
{
// error!
throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
}
else if (helpop_map.find("nohelp") == helpop_map.end())
{
// error!
throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
}
}
示例5: jets_RA5
bool jets_RA5(EasyChain* tree,vector<int>& goodJets){
static ConfigReader config;
// static since we read only once
static float jet_pt_min = config.getFloat("jet_pt_min", 30);
static float jet_eta_max = config.getDouble("jet_eta_max",2.4);
static bool quick = config.getBool("quick");
// static to get the cut flow for all events
static CutSet jetFlow("good jet selection");
// print at end of program and dump into histogram file
jetFlow.autoprint=true;
jetFlow.autodump=true;
vector<int>& JetID = tree->Get(&JetID,"ak5JetPFPFJetIDloosePat");
vector<LorentzM>& Jets = tree->Get(&Jets, "ak5JetPFCorrectedP4Pat");
int cntJets=0;
for(int k = 0; k<Jets.size(); k++){
if( !jetFlow.keepIf("pt>=jet_min", Jets[k].pt() >= jet_pt_min ) && quick) continue;
if( !jetFlow.keepIf("eta<=eta_max", fabs(Jets[k].eta()) <= jet_eta_max ) && quick) continue;
if( !jetFlow.keepIf("ak5JetPFPFJetIDloosePat", JetID[k]!=0 ) && quick) continue;
goodJets.push_back(k);
}
return goodJets.size() >= 2;
}
示例6: getLocaleValue
std::string getLocaleValue(const ConfigReader &config, const std::string &group, const std::string &key, const std::string &language)
{
lang wanted(language);
std::vector<std::string> localeKeys;
if (wanted.country.size() > 0 && wanted.modifier.size() > 0)
{
localeKeys.push_back(wanted.language + "_" + wanted.country + "@" + wanted.modifier);
}
if (wanted.country.size() > 0)
{
localeKeys.push_back(wanted.language + "_" + wanted.country);
}
if (wanted.modifier.size() > 0)
{
localeKeys.push_back(wanted.language + "@" + wanted.modifier);
}
localeKeys.push_back(wanted.language);
for (std::vector<std::string>::size_type i = 0; i < localeKeys.size(); ++i)
{
std::string localeKey = key + "[" + localeKeys[i] + "]";
if (config.hasKey(group, localeKey))
{
return config.value(group, localeKey);
}
}
return config.value(group, key);
}
示例7: BasePoseGrabber
PoseGrabber::PoseGrabber(const ConfigReader &reader, const std::string &output_dir) : BasePoseGrabber(output_dir) {
self_name_ = "pose-grabber";
checkSelfName(reader.get_element("name"));
try{
model_.LoadData(reader.get_element("model-file"));
}
catch (std::runtime_error){
//e.g. no model
}
ifs_.open(reader.get_element("pose-file"));
if (!ifs_.is_open()){
throw std::runtime_error("Error, could not open file: " + reader.get_element("pose-file"));
}
ifs_.exceptions(std::ifstream::eofbit);
save_dir_ = output_dir;
ofs_file_ = save_dir_ + "/" + reader.get_element("output-pose-file");
}
示例8: METconsistency
bool cleaningFilters::METconsistency( LorentzM& caloMET, LorentzM& pfMET){
ConfigReader config;
static float DPhi_Max = config.getFloat( "METconsistency_DPhiMax", 1.5);
return fabs( DeltaPhi( caloMET, pfMET)) < DPhi_Max;
};
示例9: readV4Config
bool readV4Config( const char *configFile,
EncfsConfig &config, ConfigInfo *)
{
bool ok = false;
// use Config to parse the file and query it..
ConfigReader cfgRdr;
if(cfgRdr.load( configFile ))
{
try
{
cfgRdr["cipher"] >> (*config.mutable_cipher());
int blockSize;
cfgRdr["blockSize"] >> blockSize;
config.set_block_size(blockSize);
EncryptedKey *key = config.mutable_key();
cfgRdr["keyData"] >> (*key->mutable_ciphertext());
// fill in default for V4
config.mutable_naming()->MergeFrom( makeInterface("nameio/stream", 1, 0, 0) );
config.set_creator( "EncFS 1.0.x" );
ok = true;
} catch( Error &err)
{
LOG(WARNING) << "Error parsing config file " << configFile
<< ": " << err.what();
ok = false;
}
}
return ok;
}
示例10: readV5Config
// Read a v5 archive, which is a proprietary binary format.
bool readV5Config( const char *configFile,
EncfsConfig &config, ConfigInfo *)
{
bool ok = false;
// use Config to parse the file and query it..
ConfigReader cfgRdr;
if(cfgRdr.load( configFile ))
{
try
{
config.set_revision(cfgRdr["subVersion"].readInt(0));
if(config.revision() > V5Latest)
{
/* config file specifies a version outside our supported
range.. */
LOG(ERROR) << "Config subversion " << config.revision()
<< " found, but this version of encfs only supports up to version "
<< V5Latest;
return false;
}
if( config.revision() < V5Latest )
{
LOG(ERROR) << "This version of EncFS doesn't support "
<< "filesystems created with EncFS releases before 2004-08-13";
return false;
}
cfgRdr["creator"] >> (*config.mutable_creator());
cfgRdr["cipher"] >> (*config.mutable_cipher());
cfgRdr["naming"] >> (*config.mutable_naming());
int blockSize;
cfgRdr["blockSize"] >> blockSize;
config.set_block_size(blockSize);
EncryptedKey *encryptedKey = config.mutable_key();
int keySize;
cfgRdr["keySize"] >> keySize;
encryptedKey->set_size(keySize / 8);
cfgRdr["keyData"] >> (*encryptedKey->mutable_ciphertext());
config.set_unique_iv( cfgRdr["uniqueIV"].readBool( false ) );
config.set_chained_iv( cfgRdr["chainedIV"].readBool( false ) );
config.set_external_iv( cfgRdr["externalIV"].readBool( false ) );
config.set_block_mac_bytes( cfgRdr["blockMACBytes"].readInt(0) );
config.set_block_mac_rand_bytes( cfgRdr["blockMACRandBytes"].readInt(0) );
ok = true;
} catch( Error &err)
{
LOG(WARNING) << "Error parsing data in config file " << configFile
<< "; " << err.what();
ok = false;
}
}
return ok;
}
示例11: anomalousRho
bool cleaningFilters::anomalousRho( EasyChain* tree){
ConfigReader config;
static float rho_Max = config.getFloat( "Rho_Max", 40.);
float rho = tree->Get( rho, "rho");
return rho <= rho_Max;
};
示例12: ReadSettings
void ReadSettings()
{
Conf = new ConfigReader(ServerInstance);
IdentTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
PortBind = Conf->ReadValue("ident", "bind", 0);
if (!IdentTimeout)
IdentTimeout = 1;
DELETE(Conf);
}
示例13: main
int main()
{
string configFileName("difex.dat");
ConfigReader *configReader = new ConfigReader(configFileName);
configReader->readConfig();
FTCSSchemeSolver *solver = new FTCSSchemeSolver(configReader);
solver->run();
return EXIT_SUCCESS;
}
示例14: OnRehash
virtual void OnRehash(userrec* user, const std::string ¶meter)
{
ConfigReader* conf = new ConfigReader(ServerInstance);
operChan = conf->ReadValue("operjoin", "channel", 0);
operChans.clear();
if (!operChan.empty())
tokenize(operChan,operChans);
DELETE(conf);
}
示例15: UpdateConfig
/**
* @brief Save all values and prepare xml configuration for writing
*/
void ParameterStructure::UpdateConfig() const
{
ConfigReader conf = m_configReader.Find("parameters");
for(const auto & elem : m_list)
{
if(m_writeAllParamsToConfig || (elem)->GetConfigurationSource() != PARAMCONF_DEF)
{
conf.FindRef("param[name=\"" +(elem)->GetName() + "\"]", true).SetValue((elem)->GetValueString());
}
}
}