Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cIniFile.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cIniFile_H
7 #define _INC_cIniFile_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cIniSection.h"
13 #include "cArrayRef.h"
14 #include "HResult.h"
15 #include "FileName.h"
16 #include "cUnitTestDecl.h"
17 
18 namespace Gray
19 {
21  : public IIniBaseEnumerator // enumerate the sections.
22  {
27  private:
28  cArrayRef<cIniSectionEntry> m_aSections;
29 
30  public:
31  cIniFile();
32  virtual ~cIniFile();
33 
34  bool isRead() const
35  {
37  return m_aSections.GetSize() > 0;
38  }
39 
40  HRESULT ReadIniStream(cStreamInput& s, bool bStripComments = false);
41  HRESULT ReadIniFile(const FILECHAR_t* pszFilePath, bool bStripComments = false);
42  HRESULT WriteIniFile(const FILECHAR_t* pszFilePath) const;
43 
45  {
46  return m_aSections.GetAtCheck(i);
47  }
48  virtual HRESULT PropEnum(IPROPIDX_t ePropIdx, OUT cStringI& rsValue, cStringI* psPropTag = nullptr) const override;
49  cIniSectionEntryPtr FindSection(const IniChar_t* pszSectionTitle = nullptr, bool bPrefix = false) const;
50 
51  const IniChar_t* FindKeyLinePtr(const IniChar_t* pszSectionTitle, const IniChar_t* pszKey) const;
52  virtual cIniSectionEntryPtr AddSection(const IniChar_t* pszSectionTitle = nullptr, bool bStripped = false, int iLine = 0);
53  HRESULT SetKeyLine(const IniChar_t* pszSectionTitle, const IniChar_t* pszKey, const IniChar_t* pszLine);
54  HRESULT SetKeyArg(const IniChar_t* pszSectionTitle, const IniChar_t* pszKey, const IniChar_t* pszArg);
55 
57  };
58 };
59 
60 #endif // _INC_cIniFile_H
#define GRAYCORE_LINK
Definition: GrayCore.h:47
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
ITERATE_t GetSize() const noexcept
Definition: cArray.h:137
REF_t GetAtCheck(ITERATE_t index) const
Definition: cArray.h:834
Definition: cArrayRef.h:21
Definition: cIniFile.h:22
bool isRead() const
Definition: cIniFile.h:34
cIniSectionEntryPtr EnumSection(ITERATE_t i=0) const
Definition: cIniFile.h:44
Definition: cRefPtr.h:225
Definition: cStream.h:306
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
int ITERATE_t
like size_t but signed
Definition: Index.h:28
char IniChar_t
char format even on UNICODE system! Screw M$, INI files should ALWAYS have UTF8 contents
Definition: cIniBase.h:17
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
int IPROPIDX_t
enumerate known properties for some interface/object/class. similar to SCRIPTPROPID_t
Definition: cIniBase.h:16
Definition: cIniBase.h:35