ReactOS  0.4.15-dev-499-g1f31905
CConfigParser Class Reference

#include <misc.h>

Collaboration diagram for CConfigParser:

Public Member Functions

 CConfigParser (const ATL::CStringW &FileName="")
 
BOOL GetString (const ATL::CStringW &KeyName, ATL::CStringW &ResultString)
 
BOOL GetInt (const ATL::CStringW &KeyName, INT &iResult)
 

Private Member Functions

ATL::CStringW GetINIFullPath (const ATL::CStringW &FileName)
 
VOID CacheINILocale ()
 

Private Attributes

ATL::CStringW m_szLocaleID
 
ATL::CStringW m_szCachedINISectionLocale
 
ATL::CStringW m_szCachedINISectionLocaleNeutral
 
const ATL::CStringW szConfigPath
 

Static Private Attributes

static const INT m_cchLocaleSize = 5
 

Detailed Description

Definition at line 27 of file misc.h.

Constructor & Destructor Documentation

◆ CConfigParser()

CConfigParser::CConfigParser ( const ATL::CStringW FileName = "")

Definition at line 312 of file misc.cpp.

313 {
314  CacheINILocale();
315 }
ATL::CStringW GetINIFullPath(const ATL::CStringW &FileName)
Definition: misc.cpp:317
const ATL::CStringW szConfigPath
Definition: misc.h:36
VOID CacheINILocale()
Definition: misc.cpp:328

Member Function Documentation

◆ CacheINILocale()

VOID CConfigParser::CacheINILocale ( )
private

Definition at line 328 of file misc.cpp.

329 {
330  // TODO: Set default locale if call fails
331  // find out what is the current system lang code (e.g. "0a") and append it to SectionLocale
334 
337 
338  // turn "Section.0c0a" into "Section.0a", keeping just the neutral lang part
339  if (m_szLocaleID.GetLength() >= 2)
341  else
343 }
int GetLength() const
Definition: atlsimpstr.h:356
ATL::CStringW m_szLocaleID
Definition: misc.h:32
static const INT m_cchLocaleSize
Definition: misc.h:30
CStringT Right(int nCount) const
Definition: cstringt.h:675
ATL::CStringW m_szCachedINISectionLocaleNeutral
Definition: misc.h:34
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
ATL::CStringW m_szCachedINISectionLocale
Definition: misc.h:33
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
static const WCHAR L[]
Definition: oid.c:1250

Referenced by CConfigParser().

◆ GetINIFullPath()

ATL::CStringW CConfigParser::GetINIFullPath ( const ATL::CStringW FileName)
private

Definition at line 317 of file misc.cpp.

318 {
319  ATL::CStringW szDir;
320  ATL::CStringW szBuffer;
321 
322  GetStorageDirectory(szDir);
323  szBuffer.Format(L"%ls\\rapps\\%ls", szDir.GetString(), FileName.GetString());
324 
325  return szBuffer;
326 }
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:688
PCXSTR GetString() const
Definition: atlsimpstr.h:361
static const WCHAR L[]
Definition: oid.c:1250
BOOL GetStorageDirectory(ATL::CStringW &Directory)
Definition: misc.cpp:172

◆ GetInt()

BOOL CConfigParser::GetInt ( const ATL::CStringW KeyName,
INT iResult 
)

Definition at line 383 of file misc.cpp.

384 {
386 
387  iResult = 0;
388 
389  // grab the text version of our entry
390  if (!GetString(KeyName, Buffer))
391  return FALSE;
392 
393  if (Buffer.IsEmpty())
394  return FALSE;
395 
396  // convert it to an actual integer
397  iResult = StrToIntW(Buffer.GetString());
398 
399  // we only care about values > 0
400  return (iResult > 0);
401 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
Definition: bufpool.h:45
BOOL GetString(const ATL::CStringW &KeyName, ATL::CStringW &ResultString)
Definition: misc.cpp:345
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by CAvailableApplicationInfo::RetrieveGeneralInfo(), CAvailableApplicationInfo::RetrieveLicenseType(), and CAvailableApplicationInfo::RetrieveSize().

◆ GetString()

BOOL CConfigParser::GetString ( const ATL::CStringW KeyName,
ATL::CStringW ResultString 
)

Definition at line 345 of file misc.cpp.

346 {
347  DWORD dwResult;
348 
349  LPWSTR ResultStringBuffer = ResultString.GetBuffer(MAX_PATH);
350  // 1st - find localized strings (e.g. "Section.0c0a")
352  KeyName.GetString(),
353  NULL,
354  ResultStringBuffer,
355  MAX_PATH,
357 
358  if (!dwResult)
359  {
360  // 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a")
362  KeyName.GetString(),
363  NULL,
364  ResultStringBuffer,
365  MAX_PATH,
367  if (!dwResult)
368  {
369  // 3rd - if they weren't present fallback to standard english strings (just "Section")
370  dwResult = GetPrivateProfileStringW(L"Section",
371  KeyName.GetString(),
372  NULL,
373  ResultStringBuffer,
374  MAX_PATH,
376  }
377  }
378 
379  ResultString.ReleaseBuffer();
380  return (dwResult != 0 ? TRUE : FALSE);
381 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define TRUE
Definition: types.h:120
ATL::CStringW m_szCachedINISectionLocaleNeutral
Definition: misc.h:34
ATL::CStringW m_szCachedINISectionLocale
Definition: misc.h:33
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
const ATL::CStringW szConfigPath
Definition: misc.h:36
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GetInt(), CAvailableApplicationInfo::GetString(), and CAvailableApplicationInfo::RetrieveLanguages().

Member Data Documentation

◆ m_cchLocaleSize

const INT CConfigParser::m_cchLocaleSize = 5
staticprivate

Definition at line 30 of file misc.h.

Referenced by CacheINILocale().

◆ m_szCachedINISectionLocale

ATL::CStringW CConfigParser::m_szCachedINISectionLocale
private

Definition at line 33 of file misc.h.

Referenced by CacheINILocale(), and GetString().

◆ m_szCachedINISectionLocaleNeutral

ATL::CStringW CConfigParser::m_szCachedINISectionLocaleNeutral
private

Definition at line 34 of file misc.h.

Referenced by CacheINILocale(), and GetString().

◆ m_szLocaleID

ATL::CStringW CConfigParser::m_szLocaleID
private

Definition at line 32 of file misc.h.

Referenced by CacheINILocale().

◆ szConfigPath

const ATL::CStringW CConfigParser::szConfigPath
private

Definition at line 36 of file misc.h.

Referenced by GetString().


The documentation for this class was generated from the following files: