本文整理汇总了C++中CConfigParser类的典型用法代码示例。如果您正苦于以下问题:C++ CConfigParser类的具体用法?C++ CConfigParser怎么用?C++ CConfigParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CConfigParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureCalc::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::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 != NULL)
{
LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str());
m_Formula.clear();
}
}
}
示例2: BindSecondaryMeasures
/*
** Reads and binds secondary measures (MeasureName2 - MeasureNameN).
**
*/
void CMeter::BindSecondaryMeasures(CConfigParser& 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"");
CMeasure* measure = parser.GetMeasure(measureName);
if (measure)
{
m_Measures.push_back(measure);
}
else
{
if (!measureName.empty())
{
LogWithArgs(LOG_ERROR, L"MeasureName%i=%s is not valid in [%s]", i, measureName.c_str(), section);
}
break;
}
++i;
}
while (true);
}
}
示例3: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeterImage::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeter::ReadOptions(parser, section);
m_Path = parser.ReadString(section, L"Path", L"");
if (!m_Path.empty())
{
if (!CSystem::IsPathSeparator(m_Path[m_Path.length() - 1]))
{
m_Path += L'\\';
}
}
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0);
m_Tile = 0!=parser.ReadInt(section, L"Tile", 0);
static const RECT defMargins = {0};
m_ScaleMargins = parser.ReadRECT(section, L"ScaleMargins", defMargins);
// Read tinting options
m_Image.ReadOptions(parser, section);
if (m_Initialized && m_Measures.empty() && !m_DynamicVariables)
{
Initialize();
m_NeedsRedraw = true;
}
}
示例4: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeterBar::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
int oldW = m_W;
int oldH = m_H;
CMeter::ReadOptions(parser, section);
m_Color = parser.ReadColor(section, L"BarColor", Color::Green);
m_ImageName = parser.ReadString(section, L"BarImage", L"");
if (!m_ImageName.empty())
{
m_MeterWindow->MakePathAbsolute(m_ImageName);
// Read tinting options
m_Image.ReadOptions(parser, section);
}
else
{
m_Image.ClearOptionFlags();
}
m_Border = parser.ReadInt(section, L"BarBorder", 0);
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);
const WCHAR* orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL").c_str();
if (_wcsicmp(L"VERTICAL", orientation) == 0)
{
m_Orientation = VERTICAL;
}
else if (_wcsicmp(L"HORIZONTAL", orientation) == 0)
{
m_Orientation = HORIZONTAL;
}
else
{
LogWithArgs(LOG_ERROR, L"BarOrientation=%s is not valid in [%s]", orientation, m_Name.c_str());
}
if (m_Initialized)
{
m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0);
if (m_NeedsReload ||
m_Image.IsOptionsChanged())
{
Initialize(); // Reload the image
}
else if (!m_ImageName.empty())
{
// Reset to old dimensions
m_W = oldW;
m_H = oldH;
}
}
}
示例5: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
double value;
const WCHAR* netName = NULL;
if (m_Net == NET_IN)
{
netName = L"NetInSpeed";
value = Rainmeter->GetGlobalOptions().netInSpeed;
}
else if (m_Net == NET_OUT)
{
netName = L"NetOutSpeed";
value = Rainmeter->GetGlobalOptions().netOutSpeed;
}
else // if (m_Net == NET_TOTAL)
{
netName = L"NetTotalSpeed";
value = Rainmeter->GetGlobalOptions().netInSpeed + Rainmeter->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 = 0!=parser.ReadInt(section, L"Cumulative", 0);
if (m_Cumulative)
{
Rainmeter->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;
}
}
示例6: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureTime::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
m_Format = parser.ReadString(section, L"Format", L"");
const WCHAR* timezone = parser.ReadString(section, L"TimeZone", L"local").c_str();
if (_wcsicmp(L"local", timezone) == 0)
{
SYSTEMTIME sysLocalTime, sysUTCTime;
GetLocalTime(&sysLocalTime);
GetSystemTime(&sysUTCTime);
FILETIME ftLocalTime, ftUTCTime;
SystemTimeToFileTime(&sysLocalTime, &ftLocalTime);
SystemTimeToFileTime(&sysUTCTime, &ftUTCTime);
LARGE_INTEGER largeInt1, largeInt2;
largeInt1.HighPart = ftLocalTime.dwHighDateTime;
largeInt1.LowPart = ftLocalTime.dwLowDateTime;
largeInt2.HighPart = ftUTCTime.dwHighDateTime;
largeInt2.LowPart = ftUTCTime.dwLowDateTime;
m_DeltaTime.QuadPart = largeInt1.QuadPart - largeInt2.QuadPart;
}
else
{
double zone = wcstod(timezone, NULL);
bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1);
struct tm* today;
time_t now;
time(&now);
today = localtime(&now);
if (dst && today->tm_isdst)
{
// Add DST
TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);
m_DeltaTime.QuadPart = (LONGLONG)((zone * 3600) - tzi.DaylightBias * 60) * 10000000;
}
else
{
m_DeltaTime.QuadPart = (LONGLONG)(zone * 3600) * 10000000;
}
}
if (!m_Initialized)
{
// Initialize m_Time to avoid causing EINVAL in TimeToString() until calling UpdateValue()
FillCurrentTime();
}
}
示例7: ReadConfig
/*
** Reads the measure specific configs.
**
*/
void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadConfig(parser, section);
const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str();
if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 0)
{
m_HKey = HKEY_CURRENT_USER;
}
else if (_wcsicmp(keyname, L"HKEY_LOCAL_MACHINE") == 0)
{
m_HKey = HKEY_LOCAL_MACHINE;
}
else if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0)
{
m_HKey = HKEY_CLASSES_ROOT;
}
else if (_wcsicmp(keyname, L"HKEY_CURRENT_CONFIG") == 0)
{
m_HKey = HKEY_CURRENT_CONFIG;
}
else if (_wcsicmp(keyname, L"HKEY_PERFORMANCE_DATA") == 0)
{
m_HKey = HKEY_PERFORMANCE_DATA;
}
else if (_wcsicmp(keyname, L"HKEY_DYN_DATA") == 0)
{
m_HKey = HKEY_DYN_DATA;
}
else
{
std::wstring error = L"RegHKey=";
error += keyname;
error += L" is not valid in [";
error += m_Name;
error += L']';
throw CError(error);
}
m_RegKeyName = parser.ReadString(section, L"RegKey", L"");
m_RegValueName = parser.ReadString(section, L"RegValue", L"");
if (m_MaxValue == 0.0)
{
m_MaxValue = 1.0;
m_LogMaxValue = true;
}
// Try to open the key
if (m_RegKey) RegCloseKey(m_RegKey);
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
示例8: ReadConfigString
// Deprecated!
LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue)
{
NULLCHECK(section);
NULLCHECK(option);
NULLCHECK(defValue);
CConfigParser* parser = Rainmeter->GetCurrentParser();
if (parser)
{
return parser->ReadString(section, option, defValue, false).c_str();
}
return defValue;
}
示例9: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeterImage::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeter::ReadOptions(parser, section);
m_Path = parser.ReadString(section, L"Path", L"");
if (!m_Path.empty())
{
if (!CSystem::IsPathSeparator(m_Path[m_Path.length() - 1]))
{
m_Path += L'\\';
}
}
m_ImageName = parser.ReadString(section, L"ImageName", L"");
int mode = parser.ReadInt(section, L"Tile", 0);
if (mode != 0)
{
m_DrawMode = DRAWMODE_TILE;
}
else
{
mode = parser.ReadInt(section, L"PreserveAspectRatio", 0);
switch (mode)
{
case 0:
m_DrawMode = DRAWMODE_NONE;
break;
case 1:
default:
m_DrawMode = DRAWMODE_KEEPRATIO;
break;
case 2:
m_DrawMode = DRAWMODE_KEEPRATIOANDCROP;
break;
}
}
static const RECT defMargins = {0};
m_ScaleMargins = parser.ReadRECT(section, L"ScaleMargins", defMargins);
// Read tinting options
m_Image.ReadOptions(parser, section);
if (m_Initialized && m_Measures.empty() && !m_DynamicVariables)
{
Initialize();
m_NeedsRedraw = true;
}
}
示例10: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureUptime::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
m_Format = parser.ReadString(section, L"Format", L"%4!i!d %3!i!:%2!02i!");
if (m_Format.find(L"%4") == std::wstring::npos)
{
m_AddDaysToHours = 0!=parser.ReadInt(section, L"AddDaysToHours", 1);
}
else
{
m_AddDaysToHours = false;
}
}
示例11: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureRegistry::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str();
if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 0)
{
m_HKey = HKEY_CURRENT_USER;
}
else if (_wcsicmp(keyname, L"HKEY_LOCAL_MACHINE") == 0)
{
m_HKey = HKEY_LOCAL_MACHINE;
}
else if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0)
{
m_HKey = HKEY_CLASSES_ROOT;
}
else if (_wcsicmp(keyname, L"HKEY_CURRENT_CONFIG") == 0)
{
m_HKey = HKEY_CURRENT_CONFIG;
}
else if (_wcsicmp(keyname, L"HKEY_PERFORMANCE_DATA") == 0)
{
m_HKey = HKEY_PERFORMANCE_DATA;
}
else if (_wcsicmp(keyname, L"HKEY_DYN_DATA") == 0)
{
m_HKey = HKEY_DYN_DATA;
}
else
{
LogWithArgs(LOG_ERROR, L"RegHKey=%s is not valid in [%s]", keyname, m_Name.c_str());
}
m_RegKeyName = parser.ReadString(section, L"RegKey", L"");
m_RegValueName = parser.ReadString(section, L"RegValue", L"");
if (m_MaxValue == 0.0)
{
m_MaxValue = 1.0;
m_LogMaxValue = true;
}
// Try to open the key
if (m_RegKey) RegCloseKey(m_RegKey);
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
示例12: BindMeasures
/*
** Overwritten method to handle the secondary measure binding.
**
*/
void CMeterHistogram::BindMeasures(CConfigParser& parser, const WCHAR* section)
{
if (BindPrimaryMeasure(parser, section, false))
{
const std::wstring* secondaryMeasure = &parser.ReadString(section, L"MeasureName2", L"");
if (secondaryMeasure->empty())
{
// For backwards compatibility.
secondaryMeasure = &parser.ReadString(section, L"SecondaryMeasureName", L"");
}
CMeasure* measure = parser.GetMeasure(*secondaryMeasure);
if (measure)
{
m_Measures.push_back(measure);
}
}
}
示例13: BindPrimaryMeasure
/*
** Reads and binds the primary MeasureName. This must always be called in overridden
** BindMeasures() implementations.
**
*/
bool CMeter::BindPrimaryMeasure(CConfigParser& parser, const WCHAR* section, bool optional)
{
m_Measures.clear();
const std::wstring& measureName = parser.ReadString(section, L"MeasureName", L"");
CMeasure* measure = parser.GetMeasure(measureName);
if (measure)
{
m_Measures.push_back(measure);
return true;
}
else if (!optional)
{
LogWithArgs(LOG_ERROR, L"MeasureName=%s is not valid in [%s]", measureName.c_str(), section);
}
return false;
}
示例14: ReadOptions
/*
** Read the options specified in the ini file.
**
*/
void CMeasureVirtualMemory::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat);
m_MaxValue = (double)(__int64)stat.ullTotalPageFile;
}
示例15: cfgLecture
QString cfgLecture(QString section, QString option, QString cfgfile)
{
QString strRetour;
CConfigParser cfg;
bool bOK = cfg.open(cfgfile, QIODevice::ReadOnly);
if (cfgfile.isNull()) cfgfile = "SuperVision.cfg";
// Sauvegarder le poste sélectionné dans le fichier init.
if (!bOK) return QString::null;
cfg.read();
if (!cfg.has_section(section) || (!cfg.has_option(section, option))) strRetour = QString::null;
else strRetour = cfg.get(section, option);
cfg.close();
return strRetour;
}