ReactOS  0.4.15-dev-1384-g878186b
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 31 of file misc.h.

Constructor & Destructor Documentation

◆ CConfigParser()

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

Definition at line 321 of file misc.cpp.

322 {
323  CacheINILocale();
324 }
ATL::CStringW GetINIFullPath(const ATL::CStringW &FileName)
Definition: misc.cpp:326
const ATL::CStringW szConfigPath
Definition: misc.h:40
VOID CacheINILocale()
Definition: misc.cpp:337

Member Function Documentation

◆ CacheINILocale()

VOID CConfigParser::CacheINILocale ( )
private

Definition at line 337 of file misc.cpp.

338 {
339  // TODO: Set default locale if call fails
340  // find out what is the current system lang code (e.g. "0a") and append it to SectionLocale
343 
346 
347  // turn "Section.0c0a" into "Section.0a", keeping just the neutral lang part
348  if (m_szLocaleID.GetLength() >= 2)
350  else
352 }
int GetLength() const
Definition: atlsimpstr.h:356
ATL::CStringW m_szLocaleID
Definition: misc.h:36
static const INT m_cchLocaleSize
Definition: misc.h:34
CStringT Right(int nCount) const
Definition: cstringt.h:703
ATL::CStringW m_szCachedINISectionLocaleNeutral
Definition: misc.h:38
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
ATL::CStringW m_szCachedINISectionLocale
Definition: misc.h:37
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 326 of file misc.cpp.

327 {
328  ATL::CStringW szDir;
329  ATL::CStringW szBuffer;
330 
331  GetStorageDirectory(szDir);
332  szBuffer.Format(L"%ls\\rapps\\%ls", szDir.GetString(), FileName.GetString());
333 
334  return szBuffer;
335 }
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:716
PCXSTR GetString() const
Definition: atlsimpstr.h:361
static const WCHAR L[]
Definition: oid.c:1250
BOOL GetStorageDirectory(ATL::CStringW &Directory)
Definition: misc.cpp:180

◆ GetInt()

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

Definition at line 392 of file misc.cpp.

393 {
395 
396  iResult = 0;
397 
398  // grab the text version of our entry
399  if (!GetString(KeyName, Buffer))
400  return FALSE;
401 
402  if (Buffer.IsEmpty())
403  return FALSE;
404 
405  // convert it to an actual integer
406  iResult = StrToIntW(Buffer.GetString());
407 
408  // we only care about values > 0
409  return (iResult > 0);
410 }
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
BOOL GetString(const ATL::CStringW &KeyName, ATL::CStringW &ResultString)
Definition: misc.cpp:354
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411

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

◆ GetString()

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

Definition at line 354 of file misc.cpp.

355 {
356  DWORD dwResult;
357 
358  LPWSTR ResultStringBuffer = ResultString.GetBuffer(MAX_PATH);
359  // 1st - find localized strings (e.g. "Section.0c0a")
361  KeyName.GetString(),
362  NULL,
363  ResultStringBuffer,
364  MAX_PATH,
366 
367  if (!dwResult)
368  {
369  // 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a")
371  KeyName.GetString(),
372  NULL,
373  ResultStringBuffer,
374  MAX_PATH,
376  if (!dwResult)
377  {
378  // 3rd - if they weren't present fallback to standard english strings (just "Section")
379  dwResult = GetPrivateProfileStringW(L"Section",
380  KeyName.GetString(),
381  NULL,
382  ResultStringBuffer,
383  MAX_PATH,
385  }
386  }
387 
388  ResultString.ReleaseBuffer();
389  return (dwResult != 0 ? TRUE : FALSE);
390 }
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:38
ATL::CStringW m_szCachedINISectionLocale
Definition: misc.h:37
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
const ATL::CStringW szConfigPath
Definition: misc.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
#define MAX_PATH
Definition: compat.h:34
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
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 34 of file misc.h.

Referenced by CacheINILocale().

◆ m_szCachedINISectionLocale

ATL::CStringW CConfigParser::m_szCachedINISectionLocale
private

Definition at line 37 of file misc.h.

Referenced by CacheINILocale(), and GetString().

◆ m_szCachedINISectionLocaleNeutral

ATL::CStringW CConfigParser::m_szCachedINISectionLocaleNeutral
private

Definition at line 38 of file misc.h.

Referenced by CacheINILocale(), and GetString().

◆ m_szLocaleID

ATL::CStringW CConfigParser::m_szLocaleID
private

Definition at line 36 of file misc.h.

Referenced by CacheINILocale().

◆ szConfigPath

const ATL::CStringW CConfigParser::szConfigPath
private

Definition at line 40 of file misc.h.

Referenced by GetString().


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