Merge pull request #7 from FusixGit/patch-4

Update IniFile.h
This commit is contained in:
Stas'M 2014-12-04 23:08:07 +03:00
commit 7873abd48c
1 changed files with 31 additions and 21 deletions

View File

@ -17,16 +17,18 @@
#include "stdafx.h" #include "stdafx.h"
#include <Windows.h> #include <Windows.h>
#define MAX_STRING_LEN 255
// Out values struсts // Out values struсts
typedef struct _INI_VAR_STRING typedef struct _INI_VAR_STRING
{ {
char Name[128]; char Name[MAX_STRING_LEN];
char Value[128]; char Value[MAX_STRING_LEN];
} INI_VAR_STRING, PINI_VAR_STRING; } INI_VAR_STRING, *PINI_VAR_STRING;
typedef struct _INI_VAR_DWORD typedef struct _INI_VAR_DWORD
{ {
char Name[128]; char Name[MAX_STRING_LEN];
#ifndef _WIN64 #ifndef _WIN64
DWORD ValueDec; DWORD ValueDec;
DWORD ValueHex; DWORD ValueHex;
@ -35,37 +37,43 @@ typedef struct _INI_VAR_DWORD
DWORD64 ValueHex; DWORD64 ValueHex;
#endif #endif
} INI_VAR_DWORD, PINI_VAR_DWORD; } INI_VAR_DWORD, *PINI_VAR_DWORD;
typedef struct _INI_VAR_BOOL
{
char Name[128];
bool Value;
} INI_VAR_BOOL, PINI_VAR_BOOL;
typedef struct _INI_VAR_BYTEARRAY typedef struct _INI_VAR_BYTEARRAY
{ {
char Name[128]; char Name[MAX_STRING_LEN];
byte ArraySize; byte ArraySize;
char Value[255]; char Value[MAX_STRING_LEN];
} INI_VAR_BYTEARRAY, PINI_VAR_BYTEARRAY; } INI_VAR_BYTEARRAY, *PINI_VAR_BYTEARRAY;
typedef struct _INI_SECTION_VARLIST_ENTRY
{
char String[MAX_STRING_LEN];
} INI_SECTION_VARLIST_ENTRY, *PINI_SECTION_VARLIST_ENTRY;
typedef struct _INI_SECTION_VARLIST
{
DWORD EntriesCount;
[length_is(EntriesCount)] INI_SECTION_VARLIST_ENTRY *NamesEntries;
[length_is(EntriesCount)] INI_SECTION_VARLIST_ENTRY *ValuesEntries;
} INI_SECTION_VARLIST, *PINI_SECTION_VARLIST;
// end // end
typedef struct _INI_SECTION_VARIABLE typedef struct _INI_SECTION_VARIABLE
{ {
char VariableName[128]; char VariableName[MAX_STRING_LEN];
char VariableValue[128]; char VariableValue[MAX_STRING_LEN];
} INI_SECTION_VARIABLE, PINI_SECTION_VARIABLE; } INI_SECTION_VARIABLE, *PINI_SECTION_VARIABLE;
typedef struct _INI_SECTION typedef struct _INI_SECTION
{ {
char SectionName[128]; char SectionName[MAX_STRING_LEN];
DWORD VariablesCount; DWORD VariablesCount;
[length_is(SectionCount)] INI_SECTION_VARIABLE *Variables; [length_is(SectionCount)] INI_SECTION_VARIABLE *Variables;
} INI_SECTION, PINI_SECTION; } INI_SECTION, *PINI_SECTION;
typedef struct _INI_DATA typedef struct _INI_DATA
{ {
@ -80,10 +88,12 @@ public:
~INI_FILE(); ~INI_FILE();
bool SectionExists(char *SectionName); bool SectionExists(char *SectionName);
bool VariableExists(char *SectionName, char *VariableName);
bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_STRING *Variable); bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_STRING *Variable);
bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_DWORD *Variable); bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_DWORD *Variable);
bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_BOOL *Variable); bool GetVariableInSection(char *SectionName, char *VariableName, bool *Variable);
bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_BYTEARRAY *Variable); bool GetVariableInSection(char *SectionName, char *VariableName, INI_VAR_BYTEARRAY *Variable);
bool GetSectionVariablesList(char *SectionName, INI_SECTION_VARLIST *VariablesList);
private: private:
DWORD FileSize; // Ini file size DWORD FileSize; // Ini file size
@ -101,6 +111,6 @@ private:
DWORD GetFileStringFromNum(DWORD StringNumber, char *RetString, DWORD Size); // Get string from string-map DWORD GetFileStringFromNum(DWORD StringNumber, char *RetString, DWORD Size); // Get string from string-map
bool IsVariable(char *Str, DWORD StrSize); bool IsVariable(char *Str, DWORD StrSize);
bool FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD StrSize); // Fill INI_SECTION_VARIABLE struct (for Parse) bool FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD StrSize); // Fill INI_SECTION_VARIABLE struct (for Parse)
PINI_SECTION GetSection(char *SectionName);
bool GetVariableInSectionPrivate(char *SectionName, char *VariableName, INI_SECTION_VARIABLE *RetVariable); bool GetVariableInSectionPrivate(char *SectionName, char *VariableName, INI_SECTION_VARIABLE *RetVariable);
}; };