ReactOS  0.4.14-dev-49-gfb4591c
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
340 }
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:655
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:668
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 380 of file misc.cpp.

381 {
383 
384  iResult = 0;
385 
386  // grab the text version of our entry
387  if (!GetString(KeyName, Buffer))
388  return FALSE;
389 
390  if (Buffer.IsEmpty())
391  return FALSE;
392 
393  // convert it to an actual integer
394  iResult = StrToIntW(Buffer.GetString());
395 
396  // we only care about values > 0
397  return (iResult > 0);
398 }
_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:342
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 342 of file misc.cpp.

343 {
344  DWORD dwResult;
345 
346  LPWSTR ResultStringBuffer = ResultString.GetBuffer(MAX_PATH);
347  // 1st - find localized strings (e.g. "Section.0c0a")
349  KeyName.GetString(),
350  NULL,
351  ResultStringBuffer,
352  MAX_PATH,
354 
355  if (!dwResult)
356  {
357  // 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a")
359  KeyName.GetString(),
360  NULL,
361  ResultStringBuffer,
362  MAX_PATH,
364  if (!dwResult)
365  {
366  // 3rd - if they weren't present fallback to standard english strings (just "Section")
367  dwResult = GetPrivateProfileStringW(L"Section",
368  KeyName.GetString(),
369  NULL,
370  ResultStringBuffer,
371  MAX_PATH,
373  }
374  }
375 
376  ResultString.ReleaseBuffer();
377  return (dwResult != 0 ? TRUE : FALSE);
378 }
_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: