#ifndef _kbini_H
#define _kbini_H

class KbIniKeyValue
{//Key=Value
private:
    char *m_pszKey;  //キー名
    char *m_pszValue;//値
    KbIniKeyValue(void);
public:
    const char* __fastcall GetKeyName(void)const{return m_pszKey;}
    const char* __fastcall GetValue(void)const{return m_pszValue;}
    void __fastcall SetValue(const char *cszValue);
    KbIniKeyValue(const char *cszKeyName, const char *cszValue);
    ~KbIniKeyValue(void);
};

class KbIniSection
{//[Section]
private:
    char           *m_pszSection; //セクション名
    KbIniKeyValue **m_ppKeyValues;//
    int             m_nCapacity;
    int             m_nCount;
    KbIniSection(void);
public:
    const char* __fastcall GetSectionName(void)const{return m_pszSection;}
    KbIniKeyValue* __fastcall FindKeyValue(const char *cszKey);
    KbIniKeyValue* __fastcall GetKeyValue(int nIndex);
    void __fastcall AddKeyValue(const char *cszKey, const char *cszValue);
    KbIniSection(const char *cszSectionName);
    ~KbIniSection(void);
};

class KbIniFile
{
private:
    char           m_szFileName[MAX_PATH*2];
    KbIniSection **m_ppSections;
    int            m_nCapacity;
    int            m_nCount;
    KbIniSection* __fastcall FindSection(const char *cszSection,
                                         BOOL bCreate);
public:
    KbIniSection* __fastcall GetIniSection(int nIndex);
    int   __fastcall ReadInt(const char *cszSection,
                             const char *cszKey,
                             int nDefault);
    char* __fastcall ReadStr(const char *cszSection,
                             const char *cszKey,
                             const char *cszDefault,
                             char *szString,
                             int  nSize);
    void  __fastcall WriteInt(const char *cszSection,
                              const char *cszKey,
                              int nValue);
    void  __fastcall WriteStr(const char *cszSection,
                              const char *cszKey,
                              const char *cszValue);
    void __fastcall Flush(void);
    BOOL __fastcall Open(const char *cszFileName);
    BOOL __fastcall OpenFromBuffer(BYTE *pBuffer, DWORD dwSize);
    void __fastcall Close(void);
    KbIniFile(void);
    ~KbIniFile(void);
};

#endif
