本文整理汇总了C++中ConfigParser类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigParser类的具体用法?C++ ConfigParser怎么用?C++ ConfigParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_parse_line_with_negative
void test_parse_line_with_negative() {
ConfigParser cfg;
ConfigParser::Entry* e = cfg.parse_line("rbx.blah = -3");
TS_ASSERT_EQUALS(std::string("rbx.blah"), e->variable);
TS_ASSERT_EQUALS(std::string("-3"), e->value);
}
示例2: BindSecondaryMeasures
/*
** Reads and binds secondary measures (MeasureName2 - MeasureNameN).
**
*/
void Meter::BindSecondaryMeasures(ConfigParser& parser, const WCHAR* section)
{
if (!m_Measures.empty())
{
WCHAR tmpName[64];
int i = 2;
do
{
_snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i);
const std::wstring& measureName = parser.ReadString(section, tmpName, L"");
Measure* measure = parser.GetMeasure(measureName);
if (measure)
{
m_Measures.push_back(measure);
}
else
{
if (!measureName.empty())
{
LogErrorF(this, L"MeasureName%i=%s is not valid", i, measureName.c_str());
}
break;
}
++i;
}
while (true);
}
}
示例3: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void MeasureCalc::ReadOptions(ConfigParser& parser, const WCHAR* section)
{
Measure::ReadOptions(parser, section);
// Store the current values so we know if the value needs to be updated
int oldLowBound = m_LowBound;
int oldHighBound = m_HighBound;
bool oldUpdateRandom = m_UpdateRandom;
std::wstring oldFormula = m_Formula;
m_Formula = parser.ReadString(section, L"Formula", L"");
m_LowBound = parser.ReadInt(section, L"LowBound", 0);
m_HighBound = parser.ReadInt(section, L"HighBound", 100);
m_UpdateRandom = 0!=parser.ReadInt(section, L"UpdateRandom", 0);
if (!m_Initialized ||
wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 ||
oldLowBound != m_LowBound ||
oldHighBound != m_HighBound ||
oldUpdateRandom != m_UpdateRandom)
{
if (!m_UpdateRandom)
{
FormulaReplace();
}
const WCHAR* errMsg = MathParser::Check(m_Formula.c_str());
if (errMsg != nullptr)
{
LogErrorF(this, L"Calc: %s", errMsg);
m_Formula.clear();
}
}
}
示例4: test_parse_line_with_dot
void test_parse_line_with_dot() {
ConfigParser cfg;
ConfigParser::Entry* e = cfg.parse_line("rbx.blah = ./foo.bar");
TS_ASSERT_EQUALS(std::string("rbx.blah"), e->variable);
TS_ASSERT_EQUALS(std::string("./foo.bar"), e->value);
}
示例5: ReadContainerOptions
void Meter::ReadContainerOptions(ConfigParser& parser, const WCHAR* section)
{
const std::wstring& style = parser.ReadString(section, L"MeterStyle", L"");
if (!style.empty())
{
parser.SetStyleTemplate(style);
}
const std::wstring& container = parser.ReadString(section, L"Container", L"");
if (_wcsicmp(section, container.c_str()) == 0)
{
LogErrorF(this, L"Container cannot self-reference: %s", container.c_str());
return;
}
if (!m_ContainerMeter || _wcsicmp(m_ContainerMeter->GetName(), container.c_str()) != 0)
{
if (m_ContainerMeter)
{
m_ContainerMeter->RemoveContainerItem(this);
m_ContainerMeter = nullptr;
}
auto meter = m_Skin->GetMeter(container);
if (meter)
{
meter->AddContainerItem(this);
m_ContainerMeter = meter;
}
else if (!container.empty())
{
LogErrorF(this, L"Invalid container: %s", container.c_str());
}
}
}
示例6: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void MeasureCalc::ReadOptions(ConfigParser& parser, const WCHAR* section)
{
Measure::ReadOptions(parser, section);
// Store the current values so we know if the value needs to be updated
int oldLowBound = m_LowBound;
int oldHighBound = m_HighBound;
bool oldUpdateRandom = m_UpdateRandom;
bool oldUniqueRandom = m_UniqueRandom;
std::wstring oldFormula = m_Formula;
m_Formula = parser.ReadString(section, L"Formula", L"");
m_LowBound = parser.ReadInt(section, L"LowBound", DEFAULT_LOWER_BOUND);
m_HighBound = parser.ReadInt(section, L"HighBound", DEFAULT_UPPER_BOUND);
m_UpdateRandom = parser.ReadBool(section, L"UpdateRandom", false);
m_UniqueRandom = parser.ReadBool(section, L"UniqueRandom", false);
if (!m_UniqueRandom)
{
m_UniqueNumbers.clear();
}
if (!m_Initialized ||
wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 ||
oldLowBound != m_LowBound ||
oldHighBound != m_HighBound ||
oldUpdateRandom != m_UpdateRandom ||
oldUniqueRandom != m_UniqueRandom)
{
// Reset bounds if |m_LowBound| is greater than |m_HighBound|
if (m_LowBound > m_HighBound)
{
LogErrorF(this, L"\"LowBound\" (%i) must be less then or equal to \"HighBound\" (%i)", m_LowBound, m_HighBound);
m_HighBound = m_LowBound;
}
// Reset the list if the bounds are changed
if (m_UniqueRandom && (
oldLowBound != m_LowBound ||
oldHighBound != m_HighBound))
{
UpdateUniqueNumberList();
}
if (!m_UpdateRandom)
{
FormulaReplace();
}
const WCHAR* errMsg = MathParser::Check(m_Formula.c_str());
if (errMsg != nullptr)
{
LogErrorF(this, L"Calc: %s", errMsg);
m_Formula.clear();
}
}
}
示例7: ReadPluginData
void ConfigData::ReadPluginData(ConfigParser &parser)
{
//Get if the outer log section exists
const ConfigToken * pluginDataToken = parser.GetToken("PluginData");
if(!pluginDataToken)
{
return;
}
const ConfigToken *pluginTestToken;
//Get the plugin base directory
pluginTestToken = pluginDataToken->GetChildToken("BaseDir");
if(pluginTestToken)
{
pluginTestToken->Get(pluginBasePath);
//Add a directory seperator
pluginBasePath = pluginBasePath + FileUtils::dirSeparator;
}
//Get the plugin token
pluginTestToken = pluginDataToken->GetChildToken("Plugins");
if(pluginTestToken)
{
//Loop for all children
for(uint i=0;i<pluginTestToken->GetNumChildren();i++)
{
//Get the token and check that it has a value
const ConfigToken *pToken = pluginTestToken->GetChildToken(i);
if(pToken->GetNumValues() != 1)
{
LOGERR(("ConfigData::ReadPluginData - Error in PluginData:Plugins:%s -Expected one dll name value",pToken->GetName().c_str()));
return;
}
//Fill out the plugin data
PluginData newData;
newData.pluginName = pToken->GetName();
pToken->Get(newData.pluginDLLName,0);
//Compile all child config data for the token
for(uint childNum =0;childNum < pToken->GetNumChildren(); childNum++)
{
//Convert each child back to raw config string data
string retString;
if(parser.GenerateConfigString(pToken->GetChildToken(childNum),retString))
{
newData.pluginConfigData += retString;
}
}
//Add the plugin data to the array
pluginDataArray.push_back(newData);
}
}
}
示例8: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void MeasureNet::ReadOptions(ConfigParser& parser, const WCHAR* section)
{
Measure::ReadOptions(parser, section);
double value;
const WCHAR* netName = nullptr;
if (m_Net == NET_IN)
{
netName = L"NetInSpeed";
value = GetRainmeter().GetGlobalOptions().netInSpeed;
}
else if (m_Net == NET_OUT)
{
netName = L"NetOutSpeed";
value = GetRainmeter().GetGlobalOptions().netOutSpeed;
}
else // if (m_Net == NET_TOTAL)
{
netName = L"NetTotalSpeed";
value = GetRainmeter().GetGlobalOptions().netInSpeed + GetRainmeter().GetGlobalOptions().netOutSpeed;
}
double maxValue = parser.ReadFloat(section, L"MaxValue", -1);
if (maxValue == -1)
{
maxValue = parser.ReadFloat(section, netName, -1);
if (maxValue == -1)
{
maxValue = value;
}
}
m_Interface = parser.ReadInt(section, L"Interface", 0);
m_Cumulative = parser.ReadBool(section, L"Cumulative", false);
if (m_Cumulative)
{
GetRainmeter().SetNetworkStatisticsTimer();
}
if (maxValue == 0.0)
{
if (!m_LogMaxValue)
{
m_MaxValue = 1.0;
m_LogMaxValue = true;
m_MedianValues.clear();
}
}
else
{
m_MaxValue = maxValue / 8;
m_LogMaxValue = false;
}
}
示例9: main
int main()
{
list<string>::iterator itor;
ConfigParser* cp = ConfigParser::instance();
cp->loader(CONF_PATH);
cout<<"log_level:"<<cp->getLogLevel()<<endl;
cout<<"depth:"<<cp->getDepth()<<endl;
cout<<"job_num:"<<cp->getJobNum()<<endl;
cout<<"seed:"<<cp->getUrlSeed()<<endl;
cout<<"module_path:"<<cp->getModulePath()<<endl;
list<string> module_name = cp->getModuleNames();
itor = module_name.begin();
while(itor!=module_name.end())
{
cout<< "module_name:"<<*itor<<endl;
itor++;
}
list<string> file_type = cp->getFileTypes();
itor = file_type.begin();
while(itor!=file_type.end())
{
cout<< "file_type:"<<*itor<<endl;
itor++;
}
ConfigParser::release();
return 0;
}
示例10:
// read in the HOG settings
bool cv::base::HOGSettings::configure(ConfigParser& cfg) {
bool success = true;
cells_per_block_w = cfg.get("cells_per_block_w", 2, "HOG");
cells_per_block_h = cfg.get("cells_per_block_h", 2, "HOG");
cells_per_image_w = cfg.get("cells_per_image_w", 8, "HOG");
cells_per_image_h = cfg.get("cells_per_image_h", 8, "HOG");
num_orientations = cfg.get("num_orientations", 9, "HOG");
min_scale = cfg.get("min_scale", 16);
max_scale = cfg.get("max_scale", 64);
return success;
}
示例11: qDebug
void ProjectCreatedGenerator::run()
{
qDebug() << "EmailGenerator: Generating Project Created Email";
ProjectCreatedEmail email_message;
email_message.ParseFromString(this->protoBody.toStdString());
ConfigParser settings;
QString error = "";
QSharedPointer<MySQLHandler> db = MySQLHandler::getInstance();
QSharedPointer<Email> email = QSharedPointer<Email>(new Email());
QSharedPointer<Project> project = ProjectDao::getProject(db, email_message.project_id());
QSharedPointer<Organisation> org = QSharedPointer<Organisation>();
if (project.isNull()) {
error = "Project created generation failed. Unable to find project with id " +
QString::number(email_message.project_id());
} else {
qDebug() << "EmailGenerator: Project Created Email Debugging: " << QString::number(email_message.project_id());
org = OrganisationDao::getOrg(db, project->organisationid());
if (org.isNull()) {
error = "Project created generation failed. Unable to find org with id " +
QString::number(project->organisationid());
}
}
if (error.compare("") == 0) {
QString siteLocation = settings.get("site.url");
QString siteName = settings.get("site.name");
ctemplate::TemplateDictionary dict("projectCreated");
dict.SetValue("SITE_NAME", siteName.toStdString());
QString projectView = siteLocation + "project/" + QString::number(project->id()) + "/view/";
dict.SetValue("PROJECT_VIEW", projectView.toStdString());
dict.SetValue("PROJECT_TITLE", project->title());
QString orgView = siteLocation + "org/" + QString::number(org->id()) + "/profile/";
dict.SetValue("ORG_VIEW", orgView.toStdString());
dict.SetValue("ORG_NAME", org->name());
std::string email_body;
QString template_location = QString(TEMPLATE_DIRECTORY) + "emails/project-created.tpl";
ctemplate::ExpandTemplate(template_location.toStdString(), ctemplate::DO_NOT_STRIP, &dict, &email_body);
email->setSender(settings.get("site.system_email_address"));
email->addRecipient(QString::fromStdString(email_message.recipient_email()));
email->setSubject(siteName + ": Project Created");
email->setBody(QString::fromUtf8(email_body.c_str()));
} else {
email = this->generateErrorEmail(error);
}
this->emailQueue->insert(email, currentMessage);
}
示例12: test_parse_line
void test_parse_line() {
ConfigParser cfg;
ConfigParser::Entry* e = cfg.parse_line("rbx.blah = 8");
TS_ASSERT_EQUALS(std::string("rbx.blah"), e->variable);
TS_ASSERT_EQUALS(std::string("8"), e->value);
// try again with trailing whitespace
e = cfg.parse_line("rbx.blah = 8 \t \t");
TS_ASSERT_EQUALS(std::string("rbx.blah"), e->variable);
TS_ASSERT_EQUALS(std::string("8"), e->value);
}
示例13: main
int main(int argc, char **argv) {
boost::mpi::environment env(argc, argv);
std::shared_ptr<boost::mpi::communicator> world(new
boost::mpi::communicator());
string config_file;
if (IsMaster(world)) {
ros::init(argc, argv, "real_test");
ros::NodeHandle nh("~");
nh.param("config_file", config_file, std::string(""));
}
ObjectRecognizer object_recognizer(world);
// All processes should wait until master has loaded params.
world->barrier();
broadcast(*world, config_file, kMasterRank);
ConfigParser parser;
parser.Parse(config_file);
RecognitionInput input;
input.x_min = parser.min_x;
input.x_max = parser.max_x;
input.y_min = parser.min_y;
input.y_max = parser.max_y;
input.table_height = parser.table_height;
input.camera_pose = parser.camera_pose;
input.model_names = parser.ConvertModelNamesInFileToIDs(
object_recognizer.GetModelBank());
boost::filesystem::path config_file_path(config_file);
input.heuristics_dir = ros::package::getPath("sbpl_perception") +
"/heuristics/" + config_file_path.stem().string();
// Objects for storing the point clouds.
pcl::PointCloud<PointT>::Ptr cloud_in(new PointCloud);
// Read the input PCD file from disk.
if (pcl::io::loadPCDFile<PointT>(parser.pcd_file_path.c_str(),
*cloud_in) != 0) {
cerr << "Could not find input PCD file!" << endl;
return -1;
}
input.cloud = cloud_in;
vector<ContPose> detected_poses;
object_recognizer.LocalizeObjects(input, &detected_poses);
return 0;
}
示例14: qDebug
void TaskScoreEmailGenerator::run()
{
qDebug() << "EmailGenerator - Generating TaskScoreEmail";
TaskScoreEmail email_message;
email_message.ParseFromString(this->protoBody.toStdString());
QSharedPointer<Email> email = QSharedPointer<Email>(new Email());
ConfigParser settings;
QStringList admins = settings.get("mail.admin_emails").split(",");
foreach(QString admin, admins) {
email->addRecipient(admin.trimmed());
}
示例15:
MessagingClient::MessagingClient()
{
ConfigParser mParser;
this->hostname = mParser.get("messaging.host");
this->port = mParser.get("messaging.port").toInt();
this->user = mParser.get("messaging.mess_user");
this->pass = mParser.get("messaging.mess_pass");
this->vhost = mParser.get("messaging.virtualhost");
this->finished = false;
this->conn = NULL;
this->mQueue = NULL;
this->mExchange = NULL;
}