From 6a6770aeed1200663021bf15b87328f4155e1d95 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 7 Apr 2012 13:54:36 +0300 Subject: [PATCH] Plugin API: Renamed (Rm)ReadFormula to (Rm)ReadDouble. Changed (Rm)ReadInt to accept formulas. --- Plugins/API/RainmeterAPI.cs | 12 ++---------- Plugins/API/RainmeterAPI.h | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Plugins/API/RainmeterAPI.cs b/Plugins/API/RainmeterAPI.cs index 6448dba4..6162a160 100644 --- a/Plugins/API/RainmeterAPI.cs +++ b/Plugins/API/RainmeterAPI.cs @@ -77,22 +77,14 @@ namespace Rainmeter return new string(value); } - public unsafe double ReadFormula(string option, double defValue) + public unsafe double ReadDouble(string option, double defValue) { return RmReadFormula((void*)m_Rm, ToUnsafe(option), defValue); } public unsafe int ReadInt(string option, int defValue) { - string value = ReadString(option, ""); - try - { - return Convert.ToInt32(value); - } - catch - { - return defValue; - } + return (int)RmReadFormula((void*)m_Rm, ToUnsafe(option), defValue); } public unsafe string GetMeasureName() diff --git a/Plugins/API/RainmeterAPI.h b/Plugins/API/RainmeterAPI.h index 06e1989b..8fbf2167 100644 --- a/Plugins/API/RainmeterAPI.h +++ b/Plugins/API/RainmeterAPI.h @@ -67,14 +67,12 @@ __inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue) __inline int RmReadInt(void* rm, LPCWSTR option, int defValue) { - LPCWSTR value = RmReadString(rm, option, L"", TRUE); - return (*value) ? _wtoi(value) : defValue; + return (int)RmReadFormula(rm, option, defValue); } __inline double RmReadDouble(void* rm, LPCWSTR option, double defValue) { - LPCWSTR value = RmReadString(rm, option, L"", TRUE); - return (*value) ? wcstod(value, NULL) : defValue; + return RmReadFormula(rm, option, defValue); } __inline LPCWSTR RmGetMeasureName(void* rm) @@ -106,4 +104,6 @@ enum LOGLEVEL }; #endif // LIBRARY_EXPORTS +#define RmReadFormula _ReadFormula + #endif