metayeti / mini Goto Github PK
View Code? Open in Web Editor NEWINI file reader and writer
License: MIT License
INI file reader and writer
License: MIT License
mini/ini.h(352,32): warning C4310: cast truncates constant value
mini/ini.h(352,59): warning C4310: cast truncates constant value
mini/ini.h(352,86): warning C4310: cast truncates constant value
mini/ini.h(711,38): warning C4310: cast truncates constant value
mini/ini.h(711,50): warning C4310: cast truncates constant value
mini/ini.h(711,62): warning C4310: cast truncates constant value
Trying to generate / rewrite the config only if there isn't one , how would I do this ? I tried using functions from the lib that return the bool but didn't help much.
now only support return std::string,
std::string value = ini.get("section").get("key");
but we want
int value = ini.get("section").get("key").get<int>();
There are several places in code you're using const std::string to define whitespace and end-of-line strings. There are a couple of issues with this.
First, these aren't inline, meaning that an instance is created for every translation unit.
Second, because you're using std::string, this performs an unnecessary allocation in debug mode (it disappears in release due to SSO). This is causing me problems with my leak detection, since the deallocation order isn't guaranteed, and is occurring after my leak check exit point.
It would be best to simply replace these several instances with inline const char*
This will avoid any allocations, and works exactly like before.
inline const char* whitespaceDelimiters = " \t\n\r\f\v";
...
#ifdef _WIN32
inline const char* endl = "\r\n";
#else
inline const char* endl = "\n";
#endif
Hi, I write ini files in arabic paths which makes the app crash when passing a wide char* or a wstring path
Like: C:/somefoler/مجلد/settings.ini
Is there a feature for wstring filenames and what not?
Hi,
what should be the location of the .ini file in linux?
I used to have the ini file along with my application in /usr/bin, but if I launch the application within a different directory it does not read the ini file.
Example (myapplication is the name of the application, it has a myapplication.ini file):
root@localhost:~# myapplication // The application does not find the ini file
root@localhost:~# cd /usr/bin
root@localhost:/usr/bin# myapplication // The application does find the ini file
Is there a way to tell the path where to look for the ini file?
Thanks!
I added this.
if (equalsAt != std::string::npos)
{
auto key = line.substr(0, equalsAt);
INIStringUtil::trim(key);
INIStringUtil::replace(key, "\=", "=");
auto value = line.substr(equalsAt + 1);
auto commentAt = value.find_first_of(';');
if (commentAt != std::string::npos)
value = value.erase(commentAt, value.length());
INIStringUtil::trim(value);
parseData.first = key;
parseData.second = value;
return PDataType::PDATA_KEYVALUE;
}
Is there a way to read a value without creating an empty entry in case it does not exist?
From the comments in the header it seems that this is not supported.
Thanks.
Hi !
I realised a problem in mIni as it doesn't parse strings properly, the string should be parsed as A MineServer !
but is instead parsed as A
.
Config :
[network]
port = 25565
[display]
motd = A MineServer !
[other]
max-players = 100
Using logging here is what I get :
[DEBUG] 10:34:32 - Parsed port as 25565
[DEBUG] 10:34:32 - Parsed motd as A
[DEBUG] 10:34:32 - Parsed max-players as 100
[INFO] 10:34:32 - Motd : A
Hello,
I am trying to write a simple program and cannot get past the first part of reading an ini files. I saw you library and downloaded and installed it. It is reading my ini file but the output is being prefix with some sort of gabage. For now I only have the ini portion of the code so here it is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include
#include
#include "mini/ini.h"
using namespace std;
int main()
{
mINI::INIFile file("clean-folders.ini");
mINI::INIStructure ini;
file.read(ini);
std::string dFolder = ini.get("folder").get("location");
std::string delay = ini.get("purge-minutes").get("min");
printf("%s" "%s" "%s", dFolder, delay, "\n");
return 0;
}
As this library is header-only, shouldn't all the functions be inline
to prevent multiple definition errors?
Would it be possible to add support for trailing comments on key/value lines? It would be nice to leave a comment here and there for the end users (or myself) of my program. Maybe a relatively crude method would suffice? Store everything after the value as a comment, no matter how much whitespace, etc.?
key = value ; This is the background color
While writing, simply append the stored string back to the value.
Pretty please.
Hi,
I'm trying to use the int from the ini file but I can't because when I run it I get the message:
terminate called after throwing an instance of 'std::invalid_argument'
what(): stands
Does anyone know how to fix this?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.