qix- / tortellini Goto Github PK
View Code? Open in Web Editor NEWA really stupid INI file format for C++11
A really stupid INI file format for C++11
Using a file containing:
v = 25500
and extracting that using
const char a = init[""]["v"] | 'a';
I would expect that '25500' is out of range, so the fall back is used, but it isn't and the value 0x639c is used instead. This can be seen in #5 on line 292 and 291.
Assertion in debug mode on Visual Studio 2019 if ini files contains BOM like EF BB BF at the beginning (function ltrim). Works if BOM is removed manually.
Calling code:
std::ifstream file{ "hello.ini" };
tortellini::ini dict;
file >> dict;
This allows users to quickly determine the latest, stable release and makes the library easier to use with a package manager
Line 118 in 2cac900
As i understand, this function is used for == comparison, but you use std::lexicographical_compare
than will return true if l
is lexicographic smaller than r
. Even if you use operator==
this can still happen for non-equals strings, example : https://godbolt.org/z/KLoRL9 .
A good practice when writing a library with CMake is to export any public targets. This enables code reuse and the usage of find_package()
.
Currently the tortelini
target isn't being exported nor installed.
We should check whenever the project is a root project (ie. "${CMAKE_SOURCE_DIR} == ${CMAKE_CURRENT_SOURCE_DIR}"
), provide an install target and export it.
should not this!
inline double operator |(long double fallback) const {
return strparse<long double, std::stold>(_value, fallback);
}
should this?
inline long double operator |(long double fallback) const {
return strparse<long double, std::stold>(_value, fallback);
}
With a file containing:
v = hello
and extracting a bool from that using
const auto b = ini[""]["v"] | true;
I would expect the fallback to be the result, but there returned value is false
. In tortellini.hh
inline bool operator |(bool fallback) const {
return _value.empty()
? fallback
: (
case_insensitive::compare(_value, "1")
|| case_insensitive::compare(_value, "true")
|| case_insensitive::compare(_value, "yes")
);
}
This function only uses the fallback if the _value
is empty, and not if the string isn't one of the valid [1|true|yes] options. This can be seen in #5 test.cc
line 248.
The readme states you can run tests by running make
but this is no longer the case; the library was switched to CMake in order to create a target and to honor the testing flags provided by CMake.
The readme should be updated to reflect this.
mkdir build && cd build
cmake .. -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build .
ctest
The above should be tested and, if correct, updated in the readme.
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.