当前位置: 首页>>代码示例>>C++>>正文


C++ CConfigParser::ReadString方法代码示例

本文整理汇总了C++中CConfigParser::ReadString方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigParser::ReadString方法的具体用法?C++ CConfigParser::ReadString怎么用?C++ CConfigParser::ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConfigParser的用法示例。


在下文中一共展示了CConfigParser::ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
	}
}
开发者ID:VladimirKhomenko,项目名称:rainmeter,代码行数:34,代码来源:MeterImage.cpp

示例2: 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;
        }
    }
}
开发者ID:jieah,项目名称:rainmeter,代码行数:63,代码来源:MeterBar.cpp

示例3: 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();
	}
}
开发者ID:JamesAC,项目名称:rainmeter,代码行数:59,代码来源:MeasureTime.cpp

示例4: 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);
}
开发者ID:testaccountx,项目名称:testrepo,代码行数:56,代码来源:MeasureRegistry.cpp

示例5: 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;
	}
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:54,代码来源:MeterImage.cpp

示例6: 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);
	}
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:34,代码来源:Meter.cpp

示例7: 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();
		}
	}
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:39,代码来源:MeasureCalc.cpp

示例8: 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);
}
开发者ID:JamesAC,项目名称:rainmeter,代码行数:51,代码来源:MeasureRegistry.cpp

示例9: 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);
		}
	}
}
开发者ID:dpvreony-forks,项目名称:rainmeter,代码行数:22,代码来源:MeterHistogram.cpp

示例10: ReadOptions

/*
** Read the options specified in the ini file. Base implementation for In/Out/Total.
**
*/
void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section, NET net)
{
	double value;
	const WCHAR* netName = NULL;

	if (net == NET_IN)
	{
		netName = L"NetInSpeed";
		value = Rainmeter->GetGlobalOptions().netInSpeed;
	}
	else if (net == NET_OUT)
	{
		netName = L"NetOutSpeed";
		value = Rainmeter->GetGlobalOptions().netOutSpeed;
	}
	else
	{
		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();
	}

	m_TrafficValue = parser.ReadFloat(section, L"TrafficValue", 0.0);
	m_TrafficAction = parser.ReadString(section, L"TrafficAction", L"", false);

	if (maxValue == 0)
	{
		m_MaxValue = 1;
		m_LogMaxValue = true;
	}
	else
	{
		m_MaxValue = maxValue / 8;
	}
}
开发者ID:JamesAC,项目名称:rainmeter,代码行数:56,代码来源:MeasureNet.cpp

示例11: ReadStats

/*
** Reads statistics.
**
*/
void CMeasureNet::ReadStats(const std::wstring& iniFile, std::wstring& statsDate)
{
	WCHAR buffer[48];

	CConfigParser parser;
	parser.Initialize(iniFile, NULL, L"Statistics");

	const std::wstring& date = parser.ReadString(L"Statistics", L"Since", L"", false);
	if (!date.empty())
	{
		statsDate = date;
	}

	uint32_t count = parser.ReadUInt(L"Statistics", L"Count", 0);
	if (parser.GetLastDefaultUsed())
	{
		count = parser.ReadUInt(L"Statistics", L"NetStatsCount", 0);
	}

	c_StatValues.clear();
	c_StatValues.reserve(count * 2);

	for (uint32_t i = 1; i <= count; ++i)
	{
		ULARGE_INTEGER value;

		_snwprintf_s(buffer, _TRUNCATE, L"In%u", i);
		value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
		if (parser.GetLastDefaultUsed())
		{
			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInHigh%u", i);
			value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);

			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInLow%u", i);
			value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
		}
		c_StatValues.push_back(value.QuadPart);

		_snwprintf_s(buffer, _TRUNCATE, L"Out%u", i);
		value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
		if (parser.GetLastDefaultUsed())
		{
			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutHigh%u", i);
			value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);

			_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutLow%u", i);
			value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
		}
		c_StatValues.push_back(value.QuadPart);
	}
}
开发者ID:JamesAC,项目名称:rainmeter,代码行数:55,代码来源:MeasureNet.cpp

示例12: 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;
}
开发者ID:VladimirKhomenko,项目名称:SunMeter,代码行数:15,代码来源:Export.cpp

示例13: 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;
	}
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:19,代码来源:MeasureUptime.cpp

示例14: 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;
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:24,代码来源:Meter.cpp

示例15: ReadOptions

/*
** Read the options specified in the ini file.
**
*/
void CMeterRotator::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;

	CMeter::ReadOptions(parser, section);

	m_ImageName = parser.ReadString(section, L"ImageName", L"");
	if (!m_ImageName.empty())
	{
		m_MeterWindow->MakePathAbsolute(m_ImageName);

		// Read tinting options
		m_Image.ReadOptions(parser, section);
	}
	else
	{
		m_Image.ClearOptionFlags();
	}

	m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0);
	m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0);
	m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
	m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);

	m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0);		// Typo
	m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder);

	if (m_Initialized)
	{
		m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0);

		if (m_NeedsReload ||
			m_Image.IsOptionsChanged())
		{
			Initialize();  // Reload the image
		}
	}
}
开发者ID:RichVRed,项目名称:rainmeter,代码行数:43,代码来源:MeterRotator.cpp


注:本文中的CConfigParser::ReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。