forked from rocket/rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added inifile support though filthy static class thingy.
- Loading branch information
1 parent
cd0e127
commit da96ca4
Showing
7 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #include "inifile.h" | ||
|
|
||
| std::string IniFile::filename; | ||
| std::string IniFile::section; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <windows.h> | ||
|
|
||
| class IniFile | ||
| { | ||
| protected: | ||
| static std::string filename; | ||
| static std::string section; | ||
| public: | ||
|
|
||
| static std::string getFullPath(std::string filename) | ||
| { | ||
| char fullpath[100]; | ||
| char* dummy; | ||
| GetFullPathName(filename.c_str(), 100, fullpath, &dummy); | ||
| return std::string(fullpath); | ||
| } | ||
| static void load(std::string filename) | ||
| { | ||
| IniFile::filename = getFullPath(filename); | ||
| } | ||
| static void load(std::string filename, std::string section) | ||
| { | ||
| load(filename); | ||
| setSection(section); | ||
| } | ||
| static void setSection(std::string section) | ||
| { | ||
| IniFile::section = section; | ||
| } | ||
| static bool check() | ||
| { | ||
| char buf[10]; | ||
| return (GetPrivateProfileSectionNames( buf, 10, filename.c_str() )) ? true : false; | ||
| } | ||
| static int get(std::string filename, std::string section, std::string key, int defaultValue=INT_MAX) | ||
| { | ||
| return GetPrivateProfileInt(section.c_str(), key.c_str(), defaultValue, filename.c_str()); | ||
| } | ||
| static int get(std::string section, std::string key, int defaultValue=INT_MAX) | ||
| { | ||
| return get(filename, section, key, defaultValue); | ||
| } | ||
| static int get(std::string key, int defaultValue=INT_MAX) | ||
| { | ||
| return get(filename, section, key, defaultValue); | ||
| } | ||
| static void read(int &var, std::string filename, std::string section, std::string key) | ||
| { | ||
| var = get(filename, section, key, var); | ||
| } | ||
| static void read(int &var, std::string section, std::string key) | ||
| { | ||
| var = get(filename, section, key, var); | ||
| } | ||
| static void read(int &var, std::string key) | ||
| { | ||
| var = get(filename, section, key, var); | ||
| } | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [GUI] | ||
| fontHeight = 14 | ||
| fontWidth = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters