// iniFile.h: interface for the CiniFile class. // ////////////////////////////////////////////////////////////////////// #include //#include #include "LocalizationStrings.h" #if !defined(AFX_INIFILE_H__1B07240F_894F_46ED_B23C_9BD247136FE7__INCLUDED_) #define AFX_INIFILE_H__1B07240F_894F_46ED_B23C_9BD247136FE7__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////// //definicia ini suboru ///////////////////////////////////////////////////////////////////// #define BACKUPPATH "windows\\start menu\\backup\\" #define SERVERCOUNT 1 #define MIP1 "10.0.0.20" #define MPORT1 "2451" #define D_Color1_R 225 #define D_Color1_G 225 #define D_Color1_B 255 #define D_Color2_R 200 #define D_Color2_G 225 #define D_Color2_B 200 #define D_Color3_R 235 #define D_Color3_G 220 #define D_Color3_B 235 #define D_Color4_R 255 #define D_Color4_G 250 #define D_Color4_B 157 #define D_Color5_R 30 #define D_Color5_G 30 #define D_Color5_B 60 #define D_Color6_R 30 #define D_Color6_G 80 #define D_Color6_B 30 #define D_Color7_R 65 #define D_Color7_G 35 #define D_Color7_B 65 #define D_Color8_R 133 #define D_Color8_G 121 #define D_Color8_B 0 #define D_Color9_R 150 #define D_Color9_G 150 #define D_Color9_B 150 #define D_Color10_R 240 #define D_Color10_G 240 #define D_Color10_B 240 #define D_Color11_R 255 #define D_Color11_G 240 #define D_Color11_B 240 #define D_Color12_R 30 #define D_Color12_G 30 #define D_Color12_B 30 #define D_Color13_R 0 #define D_Color13_G 180 #define D_Color13_B 0 #define D_Color14_R 0 #define D_Color14_G 0 #define D_Color14_B 164 #define D_Color15_R 164 #define D_Color15_G 0 #define D_Color15_B 0 #define D_Color16_R 0 #define D_Color16_G 0 #define D_Color16_B 0 #define D_Color17_R 255 #define D_Color17_G 0 #define D_Color17_B 255 #define D_Color18_R 255 #define D_Color18_G 255 #define D_Color18_B 255 #define D_Color19_R 55 #define D_Color19_G 92 #define D_Color19_B 180 #define D_Color20_R 0 #define D_Color20_G 0 #define D_Color20_B 190 #define D_Color21_R 220 #define D_Color21_G 0 #define D_Color21_B 0 #define D_Color22_R 255 #define D_Color22_G 255 #define D_Color22_B 150 #define D_Color23_R 155 #define D_Color23_G 255 #define D_Color23_B 150 #define D_Color24_R 50 #define D_Color24_G 65 #define D_Color24_B 180 #define D_Color25_R 240 #define D_Color25_G 240 #define D_Color25_B 255 #define D_Color26_R 30 #define D_Color26_G 30 #define D_Color26_B 50 #define D_Color27_R 255 #define D_Color27_G 0 #define D_Color27_B 0 #define D_Color28_R 155 #define D_Color28_G 155 #define D_Color28_B 155 #define D_Color29_R 185 #define D_Color29_G 185 #define D_Color29_B 255 #define D_Color30_R 220 #define D_Color30_G 0 #define D_Color30_B 0 #define D_Color31_R 155 #define D_Color31_G 255 #define D_Color31_B 158 //kalendar nedela #define D_Color32_R 255 #define D_Color32_G 0 #define D_Color32_B 0 // sobota #define D_Color33_R 255 #define D_Color33_G 155 #define D_Color33_B 0 ////////////////////////////////////////////////////////////////////// //Section ////////////////////////////////////////////////////////////////////// class stKey { public: stKey (); stKey(stKey &s); stKey(stKey *s); wchar_t *csKey; wchar_t *csValue; // kopirovaci operator stKey& operator=( stKey &s ) // assignment operator { csKey = new wchar_t[wcslen(s.csKey)+2]; wcscpy(csKey,s.csKey); csValue = new wchar_t[wcslen(s.csValue)+2]; wcscpy(csValue,s.csValue); return *this; } stKey* operator=( stKey *s ) // assignment operator { csKey = s->csKey; csValue = s->csValue; return this; } ~stKey(); }; class Section { private: public: int bIsEmpty; Section(); ~Section(){delete CstKey;}; void SetEmty(); Section( Section &s ); Section( Section *s ); // kopirovaci operator Section* operator=( Section *s ) // assignment operator { m_csSectionName = s->m_csSectionName; CstKey= s->CstKey; bIsEmpty = s->bIsEmpty; return this; } // operator == BOOL operator==( Section s ) { if(m_csSectionName.Compare(s.m_csSectionName) == 0) { return TRUE; } else { return FALSE; } } CString m_csSectionName; ClocalizationStrings * CstKey; int IsEmpty () {return bIsEmpty;}; }; ////////////////////////////////////////////////////////////////////// //CiniFile ////////////////////////////////////////////////////////////////////// //#define class CiniFile { private: FILE *m_pfdIni; char *pcFileName; Section *sAktSection; BOOL bDalsia; POSITION m_Position; bool m_bWriteSection; bool m_bReadSection; int m_maxCount; BOOL RemoveSection(int * iIndex); bool RemoveIfExist(Section *scSection, wchar_t *csKey,wchar_t *pcValue); void SaveColors(); void GetIndexKey(Section scSection,wchar_t *csKey,int *iIndex,stKey **pKey); void GetString(Section *sSection,wchar_t *pcKey,wchar_t *Dest,int maxLen); void AddSection(Section *psSection); void AddSection(Section psSection); void ReadIniFile(FILE *fd); void ParseLine(char *pLine); void WriteSection(FILE *stream,Section *sSection); void WriteIniFile(FILE *stream); Section * NewSection(CString csName); Section *GetSection(wchar_t *pcSectionName,int *pIndex); CList m_clsSection; public: void StopReadSetcion(); void SartReadSetcion(wchar_t *pwSectionName); void StopWriteSetcion(); void SartWriteSetcion(wchar_t *pwSectionName); void SaveColorsDefault(); void LoadColors(); void CompColuNamePosition(wchar_t *sName, int iIndex,wchar_t *Dest, int maxLen); void CompColuNameWidth(wchar_t *sName,int iIndex,wchar_t *Dest, int maxLen); void CompColuNameCount(wchar_t *sName,wchar_t *Dest, int maxLen); void CompBox(int iIndex1, int iIndex2,wchar_t *Dest, int maxLen); void CompBox(int iIndex1,wchar_t *Dest, int maxLen); void CompPortIp(int iIndex,wchar_t *Dest, int maxLen); void CompPortId(int iIndex,wchar_t *Dest, int maxLen); void GetProfileString(wchar_t *pcSectionName,wchar_t *pcKey,wchar_t *Dest,int maxLen); void ConvertCsToWc(CString csSource, wchar_t *Dest,int maxLen); void SaveDefaults(char *pcFilename); void SaveFile(char *pcFileName); void WriteProfileInt(wchar_t *pcSectionName, wchar_t *pcKey, int iValue); void WriteProfileString(wchar_t *pcSectionName, wchar_t *pcKey, wchar_t *pcValue); void WriteProfileSection(wchar_t *pcSectionName); int GetProfileInt(wchar_t *pcSectionName, wchar_t *pcKey,wchar_t *Dest,int maxLen, bool *found = NULL); bool InitializeFile(char * pcFileName); CiniFile(); virtual ~CiniFile(); }; #endif // !defined(AFX_INIFILE_H__1B07240F_894F_46ED_B23C_9BD247136FE7__INCLUDED_)