ReactOS  0.4.15-dev-3203-gacde1e0
CConfigParser Class Reference

#include <configparser.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 ()
 
BOOL GetStringWorker (const ATL::CStringW &KeyName, PCWSTR Suffix, ATL::CStringW &ResultString)
 

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 6 of file configparser.h.

Constructor & Destructor Documentation

◆ CConfigParser()

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

Definition at line 11 of file configparser.cpp.

12 {
14 }
ATL::CStringW GetINIFullPath(const ATL::CStringW &FileName)
const ATL::CStringW szConfigPath
Definition: configparser.h:15
VOID CacheINILocale()

Member Function Documentation

◆ CacheINILocale()

VOID CConfigParser::CacheINILocale ( )
private

Definition at line 27 of file configparser.cpp.

28 {
29  // TODO: Set default locale if call fails
30  // find out what is the current system lang code (e.g. "0a") and append it to SectionLocale
33 
36 
37  // turn "Section.0c0a" into "Section.0a", keeping just the neutral lang part
38  if (m_szLocaleID.GetLength() >= 2)
40  else
42 }
int GetLength() const
Definition: atlsimpstr.h:356
ATL::CStringW m_szLocaleID
Definition: configparser.h:11
static const INT m_cchLocaleSize
Definition: configparser.h:9
CStringT Right(int nCount) const
Definition: cstringt.h:740
ATL::CStringW m_szCachedINISectionLocaleNeutral
Definition: configparser.h:13
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
ATL::CStringW m_szCachedINISectionLocale
Definition: configparser.h:12
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 16 of file configparser.cpp.

17 {
18  ATL::CStringW szDir;
19  ATL::CStringW szBuffer;
20 
21  GetStorageDirectory(szDir);
22  szBuffer.Format(L"%ls\\rapps\\%ls", szDir.GetString(), FileName.GetString());
23 
24  return szBuffer;
25 }
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:753
PCXSTR GetString() const
Definition: atlsimpstr.h:361
BOOL GetStorageDirectory(ATL::CStringW &lpDirectory)
Definition: misc.cpp:180
static const WCHAR L[]
Definition: oid.c:1250

◆ GetInt()

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

Definition at line 102 of file configparser.cpp.

103 {
105 
106  iResult = 0;
107 
108  // grab the text version of our entry
109  if (!GetString(KeyName, Buffer))
110  return FALSE;
111 
112  if (Buffer.IsEmpty())
113  return FALSE;
114 
115  // convert it to an actual integer
116  iResult = StrToIntW(Buffer.GetString());
117 
118  // we only care about values > 0
119  return (iResult > 0);
120 }
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)
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 82 of file configparser.cpp.

83 {
84  /* First try */
85  if (GetStringWorker(KeyName, L"." CurrentArchitecture, ResultString))
86  {
87  return TRUE;
88  }
89 
90 #ifndef _M_IX86
91  /* On non-x86 architecture we need the architecture specific URL */
92  if (KeyName == L"URLDownload")
93  {
94  return FALSE;
95  }
96 #endif
97 
98  /* Fall back to default */
99  return GetStringWorker(KeyName, L"", ResultString);
100 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
static const WCHAR L[]
Definition: oid.c:1250
BOOL GetStringWorker(const ATL::CStringW &KeyName, PCWSTR Suffix, ATL::CStringW &ResultString)

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

◆ GetStringWorker()

BOOL CConfigParser::GetStringWorker ( const ATL::CStringW KeyName,
PCWSTR  Suffix,
ATL::CStringW ResultString 
)
private

Definition at line 44 of file configparser.cpp.

45 {
46  DWORD dwResult;
47 
48  LPWSTR ResultStringBuffer = ResultString.GetBuffer(MAX_PATH);
49  // 1st - find localized strings (e.g. "Section.0c0a")
51  KeyName.GetString(),
52  NULL,
53  ResultStringBuffer,
54  MAX_PATH,
56 
57  if (!dwResult)
58  {
59  // 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a")
61  KeyName.GetString(),
62  NULL,
63  ResultStringBuffer,
64  MAX_PATH,
66  if (!dwResult)
67  {
68  // 3rd - if they weren't present fallback to standard english strings (just "Section")
69  dwResult = GetPrivateProfileStringW((ATL::CStringW(L"Section") + Suffix).GetString(),
70  KeyName.GetString(),
71  NULL,
72  ResultStringBuffer,
73  MAX_PATH,
75  }
76  }
77 
78  ResultString.ReleaseBuffer();
79  return (dwResult != 0 ? TRUE : FALSE);
80 }
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: configparser.h:13
ATL::CStringW m_szCachedINISectionLocale
Definition: configparser.h:12
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
const ATL::CStringW szConfigPath
Definition: configparser.h:15
_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
BOOL GetString(const ATL::CStringW &KeyName, ATL::CStringW &ResultString)
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GetString().

Member Data Documentation

◆ m_cchLocaleSize

const INT CConfigParser::m_cchLocaleSize = 5
staticprivate

Definition at line 9 of file configparser.h.

Referenced by CacheINILocale().

◆ m_szCachedINISectionLocale

ATL::CStringW CConfigParser::m_szCachedINISectionLocale
private

Definition at line 12 of file configparser.h.

Referenced by CacheINILocale(), and GetStringWorker().

◆ m_szCachedINISectionLocaleNeutral

ATL::CStringW CConfigParser::m_szCachedINISectionLocaleNeutral
private

Definition at line 13 of file configparser.h.

Referenced by CacheINILocale(), and GetStringWorker().

◆ m_szLocaleID

ATL::CStringW CConfigParser::m_szLocaleID
private

Definition at line 11 of file configparser.h.

Referenced by CacheINILocale().

◆ szConfigPath

const ATL::CStringW CConfigParser::szConfigPath
private

Definition at line 15 of file configparser.h.

Referenced by GetStringWorker().


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