ReactOS  0.4.13-dev-464-g6b95727
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 327 of file misc.cpp.

328 {
329  CacheINILocale();
330 }
ATL::CStringW GetINIFullPath(const ATL::CStringW &FileName)
Definition: misc.cpp:332
const ATL::CStringW szConfigPath
Definition: misc.h:36
VOID CacheINILocale()
Definition: misc.cpp:343

Member Function Documentation

◆ CacheINILocale()

VOID CConfigParser::CacheINILocale ( )
private

Definition at line 343 of file misc.cpp.

344 {
345  // TODO: Set default locale if call fails
346  // find out what is the current system lang code (e.g. "0a") and append it to SectionLocale
349 
352 
353  // turn "Section.0c0a" into "Section.0a", keeping just the neutral lang part
355 }
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 332 of file misc.cpp.

333 {
334  ATL::CStringW szDir;
335  ATL::CStringW szBuffer;
336 
337  GetStorageDirectory(szDir);
338  szBuffer.Format(L"%ls\\rapps\\%ls", szDir.GetString(), FileName.GetString());
339 
340  return szBuffer;
341 }
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:187

◆ GetInt()

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

Definition at line 395 of file misc.cpp.

396 {
398 
399  iResult = 0;
400 
401  // grab the text version of our entry
402  if (!GetString(KeyName, Buffer))
403  return FALSE;
404 
405  if (Buffer.IsEmpty())
406  return FALSE;
407 
408  // convert it to an actual integer
409  iResult = StrToIntW(Buffer.GetString());
410 
411  // we only care about values > 0
412  return (iResult > 0);
413 }
_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:357
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 357 of file misc.cpp.

358 {
359  DWORD dwResult;
360 
361  LPWSTR ResultStringBuffer = ResultString.GetBuffer(MAX_PATH);
362  // 1st - find localized strings (e.g. "Section.0c0a")
364  KeyName.GetString(),
365  NULL,
366  ResultStringBuffer,
367  MAX_PATH,
369 
370  if (!dwResult)
371  {
372  // 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a")
374  KeyName.GetString(),
375  NULL,
376  ResultStringBuffer,
377  MAX_PATH,
379  if (!dwResult)
380  {
381  // 3rd - if they weren't present fallback to standard english strings (just "Section")
382  dwResult = GetPrivateProfileStringW(L"Section",
383  KeyName.GetString(),
384  NULL,
385  ResultStringBuffer,
386  MAX_PATH,
388  }
389  }
390 
391  ResultString.ReleaseBuffer();
392  return (dwResult != 0 ? TRUE : FALSE);
393 }
_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: