Git Product home page Git Product logo

inicpp's Introduction

inicpp

Linux/MacOS Build Windows Build License Wiki Docs

C++ parser of INI files with schema validation.

About

This project started as semestral work for Recommended Programming Practices class at MFF UK, Prague, in 2016. After deadline the project was published at GitHub under MIT license.

Great emphasis was put on qualities of object oriented design and clean implementation with modern C++ features.

Originally written by:

Versions

Master branch contains source code using std::variant feature and it requires compiler with C++17 support. Older version with C++14 support is in cpp14 branch and is still supported by us.

Build instructions

Inicpp is build as shared and static library using cmake. There are two options to control which libraries are built, by default both are set to ON. Basic syntax is:

cmake [-G generator] [-DBUILD_STATIC=ON|OFF] [-DBUILD_SHARED=ON|OFF] source_dir

Also C++ compiler with at least C++17 support is required.

Linux

To build the library run following commands from root of source code directory:

$ mkdir -p build
$ cd build
$ cmake ..
$ make

To build and run unit tests using Google Test framework run additional commands:

$ make -f tests/Makefile
$ ./tests/run_tests

Note: For building tests you must have all the sources including git submodules. This could be done using git clone --recursive https://github.com/SemaiCZE/inicpp.git command when clonning or git submodule update --init when you already have the sources.

Windows

For Windows there are two ways of building inicpp. For both ways cmake has to be installed on machine.

Using MS Visual Studio:

  • As stated Visual Studio 2017 (or later) should be installed on the machine.
  • If dependencies are successfully fulfilled then run cmake in root directory of repository using:
> cmake -G "Visual Studio 15 2017"
  • This command will generate solution files
  • Open solution file inicpp.sln using Visual Studio
  • Build ALL_BUILD project which will hopefully successfully build whole library
  • Distribute static or shared binaries which can be found in target build directories to your program/library

Using MS Visual C++:

  • Besides Visual C++ 2017 (or later) nmake compilation tool is needed (both should be part of Windows SDK)
  • Run cmake in root directory of repository using:
> cmake -G "NMake Makefiles"
  • This will generate file Makefile which can be interpreted with nmake
  • Now enter following easy command:
> nmake
  • After this compiled library should appear in working directory
  • Depending on your needs use inicpp or inicpp_static in your library or program

Examples

Some examples are located in examples directory. Compiling them requires additional steps after standard library compilation, for example on Linux (note that you must be in build directory):

$ make -f examples/Makefile

Compiled examples can be run as follows:

$ ./examples/schema_validation/inicpp_schema
$ ./examples/basic/inicpp_basic

Expected outputs are also provided with examples sources.

Basic usage without schema

Slightly modified version of basic example.

std::cout << "Load and parse config from string" << std::endl;
config example_conf = parser::load(get_config());

std::cout << "Iterate through whole config and print it" << std::endl;
for(auto &sect : example_conf) {
	std::cout << "  Section: '" << sect.get_name() << "'" << std::endl;
	// Iterate through options in a section
	for(auto &opt : sect) {
		std::cout << "    Option: '" << opt.get_name() << "' with value(s): ";
		if (!opt.is_list()) {
			std::cout << "'" << opt.get<string_ini_t>() << "'";
		} else {
			for (auto &list_item : opt.get_list<string_ini_t>())
				std::cout << "'" << list_item << "' ";
		}
	}
}

std::cout << "Get number as signed_ini_t type" << std::endl;
try {
	signed_ini_t number = example_conf["Numbers"]["num"].get<signed_ini_t>();
	std::cout << "  " << number << std::endl;
} catch (bad_cast_exception) {
	std::cout << "  Item 'num' in 'Numbers' section cannot be casted to signed_ini_t type" << std::endl;
}

std::cout << "Change some values - could be properly typed" << std::endl;
// Make reference to the section
section &number_sect = example_conf["Numbers"];
// Change some values
number_sect["num"].set<signed_ini_t>(42222);
signed_ini_t new_num = number_sect["num"].get<signed_ini_t>();
std::cout << "  Option 'num' in 'Numbers' section is '" << new_num << "'" << std::endl;
// Following two lines are equivalent
number_sect["num_oct"].set<string_ini_t>("0756");
number_sect["num_oct"] = "0756"s;
std::cout << "  set method and assingment operator on option are equivalent" << std::endl;

std::cout << "Change single value to list and vice versa" << std::endl;
option &num_opt = number_sect["num"];
num_opt.add_to_list<signed_ini_t>(99);
if (num_opt.is_list()) {
	std::cout << "  'num' option in 'Numbers' section is list" << std::endl;
} else {
	std::cout << "  'num' option in 'Numbers' section is single value" << std::endl;
}
// Remove item from the list (specifying position)
num_opt.remove_from_list_pos(0); // remove first item
std::cout << "  first item from 'num' option list removed" << std::endl;
if (num_opt.is_list()) {
	std::cout << "  'num' option in 'Numbers' section is list" << std::endl;
} else {
	std::cout << "  'num' option in 'Numbers' section is single value" << std::endl;
}
std::cout << "  'num' option value is '" << num_opt.get<signed_ini_t>() << "'" << std::endl;

std::cout << "Save changes to ostream and print the result" << std::endl;
std::ostringstream ofs;
ofs << example_conf;
std::cout << ofs.str();

Without schema all items are treated as string type, but runtime conversion could be done to one of supported types if possible.

Schema validation support

Schema validation can bring you ability to make sure, that a config file contain what you expect with type safety. In addition, this implies better performance on heavy reading of validated configuration. Slightly modified version of schema validation example.

std::cout << "Create config schema" << std::endl;
schema schm;

// add section 'Section 1'
section_schema_params section_1_params;
section_1_params.name = "Section 1";
section_1_params.comment = "comment";
section_1_params.requirement = item_requirement::optional;
schm.add_section(section_1_params);

// add options to 'Section 1'
option_schema_params<signed_ini_t> option_1_params;
option_1_params.name = "Option 1";
option_1_params.type = option_item::single;
option_1_params.requirement = item_requirement::mandatory;
option_1_params.validator = [](signed_ini_t i){ return i < 0; }; // valid values are only negative ones
option_1_params.comment = "Important option\nshould be negative";
option_1_params.default_value = "-1";
schm.add_option("Section 1", option_1_params);

option_schema_params<float_ini_t> option_4_params;
option_4_params.name = "float1";
option_4_params.type = option_item::single;
option_4_params.requirement = item_requirement::mandatory;
schm.add_option("Section 1", option_4_params);


std::cout << "Load and validate config in relaxed mode" << std::endl;
config conf = parser::load(get_config(), schm, schema_mode::relaxed);

std::cout << "Check, if options are properly typed" << std::endl;
std::cout << "  'Option 1' is signed_ini_t type with value '" <<
	conf["Section 1"]["Option 1"].get<signed_ini_t>() << "'" << std::endl;
std::cout << "  'float1' option has value '" << conf["Section 1"]["float1"].get<float_ini_t>() <<
	std::endl;
std::cout << "  'unknown_option' was left as string with value '" <<
	conf["Section 1"]["unknown_option"].get<string_ini_t>() << std::endl;

std::cout << "Validation with strict mode fails due to 'unknown_option'" << std::endl;
try {
	parser::load(get_config(), schm, schema_mode::strict);
} catch (validation_exception) {
	std::cout << "  Strict mode validation failed" << std::endl;
}

std::cout << "Write default configuration from schema to stream" << std::endl;
std::ostringstream str;
str << schm;
std::cout << str.str();

std::cout << "Write current configuration with comments from schema to stream" << std::endl;
str.str("");
parser::save(conf, schm, str);
std::cout << str.str();

Contribution

This project is open for all contributions, but please respect some rules:

  • write clean code
  • use modern C++ features when possible
  • write tests - no need to have 100% coverage, but some tests should be present
  • format code using our style in provided .clang-format file - cmake target format on unix handle this

inicpp's People

Contributors

alexey-pelykh avatar benkay86 avatar malacath-92 avatar muttleyxd avatar neloop avatar niclasr avatar petr-stefan-szn avatar semaicze avatar slaufmann avatar yuzukitsuru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

inicpp's Issues

CMake INSTALL step not working

Operating system - Windows 10.

Steps to reproduce:

  1. git clone --recursive -j8 https://github.com/SemaiCZE/inicpp.git
  2. mkdir build
  3. cd build
  4. cmake.exe -G "Microsoft Visual Studio 14 2015" ..\
  5. Open generated project in VS2015 as administrator
  6. Run All_BUILD
  7. Run INSTALL

But nothing were installed in "Program Files" folder

Expexted behavior:
headers and dlls should be placed in "C:\Program Files (x86)\inicpp.

cmake -DBUILD_STATIC=OFF fails on Unix (fix inside)

I suppose a change in CMake results in the current CMakeLists.txt to fail on cmake -DBUILD_STATIC=OFF . when using unix.

The culprit is line 81 that does not check if ${PROJECT_NAME}_static is even build or not.

The following patch fixes that:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a23c93..2510a39 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,7 +78,9 @@ include(InstallRequiredSystemLibraries)
 if(UNIX)
 	install(DIRECTORY ${INCLUDE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 	install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
-	install(TARGETS ${PROJECT_NAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
+	if(BUILD_STATIC)
+		install(TARGETS ${PROJECT_NAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
+	endif()
 elseif(MSVC)
 	install(DIRECTORY ${INCLUDE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 	install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)

usage of std::equal causing assertion fail

I came across this problem when trying to parse a uint64_t with a value of "0".

L126/7 of string_utils.cpp.

			std::string binary_prefix = "0b";
			if (std::equal(binary_prefix.begin(), binary_prefix.end(), value.begin()))

According to cppreference this uses the following:

1,3) Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)), and false otherwise

This calculates the distance (in terms of iterations, or in this case, chars) between first2 and last2 as the length of 1. If len(1) > len(2), then the second range can fall outside of the .end() iterator for 2. Or in other words, they compare the same range, but you need to make sure 2 is at least as long as 1.

len("0") < len("0b") so it gets to the assertion failing.

std::equal supports 4 args, perhaps this would fix it?

std::equal(binary_prefix.begin(), binary_prefix.end(), value.begin(), value.end())

Fails to build on linux

Hi,

When building on linux, the process fails with an error message that does not appear to have many hits on a search.

[berocs@bns-kharselim git]$ git clone https://github.com/SemaiCZE/inicpp
Cloning into 'inicpp'...
remote: Enumerating objects: 1940, done.
remote: Counting objects: 100% (194/194), done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 1940 (delta 91), reused 160 (delta 88), pack-reused 1746
Receiving objects: 100% (1940/1940), 773.53 KiB | 5.90 MiB/s, done.
Resolving deltas: 100% (1362/1362), done.
[berocs@bns-kharselim git]$ cd inicpp/
[berocs@bns-kharselim inicpp]$ ls
CMakeLists.txt  examples  inicpp.pc.in  README.md  src    vendor
Doxyfile        include   LICENSE       rpm        tests
[berocs@bns-kharselim inicpp]$ mkdir build
[berocs@bns-kharselim inicpp]$ cd build/
[berocs@bns-kharselim build]$ cmake ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/berocs/git/inicpp/build
[berocs@bns-kharselim build]$ make
[ 11%] Building CXX object CMakeFiles/inicpp.dir/src/config.cpp.o
[ 22%] Building CXX object CMakeFiles/inicpp.dir/src/option.cpp.o
[ 33%] Building CXX object CMakeFiles/inicpp.dir/src/option_schema.cpp.o
[ 44%] Building CXX object CMakeFiles/inicpp.dir/src/parser.cpp.o
[ 55%] Building CXX object CMakeFiles/inicpp.dir/src/schema.cpp.o
[ 66%] Building CXX object CMakeFiles/inicpp.dir/src/section.cpp.o
[ 77%] Building CXX object CMakeFiles/inicpp.dir/src/section_schema.cpp.o
[ 88%] Building CXX object CMakeFiles/inicpp.dir/src/string_utils.cpp.o
In file included from /home/berocs/git/inicpp/include/inicpp/string_utils.h:6,
                 from /home/berocs/git/inicpp/src/string_utils.cpp:1:
/home/berocs/git/inicpp/include/inicpp/types.h:46:57: warning: unnecessary parentheses in declaration of ‘uint64_t’ [-Wparentheses]
   46 |                 [[noreturn]] explicit internal_enum_type(uint64_t) : data_()
      |                                                         ^~~~~~~~~~
/home/berocs/git/inicpp/include/inicpp/types.h:46:57: note: remove parentheses
   46 |                 [[noreturn]] explicit internal_enum_type(uint64_t) : data_()
      |                                                         ^~~~~~~~~~
      |                                                         -        -
/home/berocs/git/inicpp/include/inicpp/types.h:46:30: error: only declarations of constructors and conversion operators can be ‘explicit’
   46 |                 [[noreturn]] explicit internal_enum_type(uint64_t) : data_()
      |                              ^~~~~~~~
/home/berocs/git/inicpp/include/inicpp/types.h:46:58: error: field ‘uint64_t’ has incomplete type ‘inicpp::internal_enum_type’
   46 |                 [[noreturn]] explicit internal_enum_type(uint64_t) : data_()
      |                                                          ^~~~~~~~
/home/berocs/git/inicpp/include/inicpp/types.h:15:15: note: definition of ‘class inicpp::internal_enum_type’ is not complete until the closing brace
   15 |         class internal_enum_type
      |               ^~~~~~~~~~~~~~~~~~
/home/berocs/git/inicpp/include/inicpp/types.h:101:32: error: ‘uint64_t’ does not name a type
  101 |         using unsigned_ini_t = uint64_t;
      |                                ^~~~~~~~
/home/berocs/git/inicpp/include/inicpp/types.h:8:1: note: ‘uint64_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    7 | #include <variant>
  +++ |+#include <cstdint>
    8 | 
/home/berocs/git/inicpp/include/inicpp/types.h:107:59: error: ‘unsigned_ini_t’ was not declared in this scope; did you mean ‘signed_ini_t’?
  107 |                 std::variant<boolean_ini_t, signed_ini_t, unsigned_ini_t, float_ini_t, enum_ini_t, string_ini_t>;
      |                                                           ^~~~~~~~~~~~~~
      |                                                           signed_ini_t
/home/berocs/git/inicpp/include/inicpp/types.h:107:112: error: template argument 3 is invalid
  107 | n_ini_t, signed_ini_t, unsigned_ini_t, float_ini_t, enum_ini_t, string_ini_t>;
      |                                                                             ^

/home/berocs/git/inicpp/include/inicpp/string_utils.h:125:40: error: ‘unsigned_ini_t’ does not name a type; did you mean ‘signed_ini_t’?
  125 |                 template <> INICPP_API unsigned_ini_t parse_string<unsigned_ini_t>(const std::string &value, const std::string &option_name);
      |                                        ^~~~~~~~~~~~~~
      |                                        signed_ini_t
/home/berocs/git/inicpp/src/string_utils.cpp:124:17: error: ‘unsigned_ini_t’ does not name a type; did you mean ‘signed_ini_t’?
  124 |                 unsigned_ini_t parse_string<unsigned_ini_t>(const std::string &value, const std::string &option_name)
      |                 ^~~~~~~~~~~~~~
      |                 signed_ini_t
make[2]: *** [CMakeFiles/inicpp.dir/build.make:174: CMakeFiles/inicpp.dir/src/string_utils.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/inicpp.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

After `make install` library files (*.so) are not found at runtime (fix included)

After make install is performed the header files are located at /usr/local/include/inicpp which is fine. But the library (*.so) files are located at /usr/local/include which is rather unusual.

The pull request #4 I opened fixes this by setting a more common LIB_INSTALL_DIR in CMakeLists.txt.

Thanks for the work on this easy-to-use library. I would appreciate it if you accept the pull request.

Build with Clang-CL on Windows cause warning STL4015

In file included from inicpp\src\config.cpp:1:
inicpp\include\inicpp/config.h(236,66): warning: 'iterator<std::random_access_iterator_tag, inicpp::section>' is deprecated: warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The <iterator> header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning. [-Wdeprecated-declarations]
        template <typename Element> class config_iterator : public std::iterator<std::random_access_iterator_tag, Element>
                                                                        ^
inicpp\src\config.cpp(176,27): note: in instantiation of template class 'inicpp::config_iterator<inicpp::section>' requested here
        config::iterator config::begin()
                                 ^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(6048,8): note: 'iterator<std::random_access_iterator_tag, inicpp::section>' has been explicitly marked deprecated here
struct _CXX17_DEPRECATE_ITERATOR_BASE_CLASS iterator { // base type for iterator classes
       ^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\yvals_core.h(859,7): note: expanded from macro '_CXX17_DEPRECATE_ITERATOR_BASE_CLASS'
    [[deprecated(                                                                                                     \
      ^

warning STL4015:
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
(The header is NOT deprecated.) The C++ Standard has never required user-defined iterators to
derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing
publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference.
Note that value_type is required to be non-const, even for constant iterators.
You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

Store Windows path with drive letter followed by colon?

Hi -
Nice library you have here. I'm trying to store a windows path like "E:\foo\bar". When I set() the value, it looks good in the ini file that I write.
However when I read it back, it gets split into two parts. "E" and "\foo\bar". Is there a way to suppress this behavior?

Thanks!

does not compile on MacOS with current MacOSX11.3.sdk

djabi@x:~/github/inicpp/build$ cmake -GNinja ..
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/djabi/github/inicpp/build

djabi@x:~/github/inicpp/build$ ninja
[2/9] Building CXX object CMakeFiles/inicpp.dir/src/config.cpp.o
In file included from ../src/config.cpp:1:
In file included from ../include/inicpp/config.h:10:
../include/inicpp/option.h:52:28: warning: function 'convert_single_value' is not needed and will not be emitted [-Wunneeded-internal-declaration]
template <> string_ini_t convert_single_value(const option_value &value, const std::string &)
^
1 warning generated.
[3/9] Building CXX object CMakeFiles/inicpp.dir/src/section.cpp.o
In file included from ../src/section.cpp:1:
In file included from ../include/inicpp/section.h:12:
../include/inicpp/option.h:52:28: warning: function 'convert_single_value' is not needed and will not be emitted [-Wunneeded-internal-declaration]
template <> string_ini_t convert_single_value(const option_value &value, const std::string &)
^
1 warning generated.
[4/9] Building CXX object CMakeFiles/inicpp.dir/src/schema.cpp.o
In file included from ../src/schema.cpp:1:
In file included from ../include/inicpp/schema.h:7:
In file included from ../include/inicpp/config.h:10:
../include/inicpp/option.h:52:28: warning: function 'convert_single_value' is not needed and will not be emitted [-Wunneeded-internal-declaration]
template <> string_ini_t convert_single_value(const option_value &value, const std::string &)
^
1 warning generated.
[5/9] Building CXX object CMakeFiles/inicpp.dir/src/section_schema.cpp.o
In file included from ../src/section_schema.cpp:1:
In file included from ../include/inicpp/section_schema.h:9:
In file included from ../include/inicpp/option_schema.h:11:
../include/inicpp/option.h:52:28: warning: function 'convert_single_value' is not needed and will not be emitted [-Wunneeded-internal-declaration]
template <> string_ini_t convert_single_value(const option_value &value, const std::string &)
^
1 warning generated.
[6/9] Building CXX object CMakeFiles/inicpp.dir/src/option_schema.cpp.o
FAILED: CMakeFiles/inicpp.dir/src/option_schema.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -I../include/inicpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -Wall -Wextra -Wdeprecated -Wconversion -Wold-style-cast -Wformat -std=gnu++17 -MD -MT CMakeFiles/inicpp.dir/src/option_schema.cpp.o -MF CMakeFiles/inicpp.dir/src/option_schema.cpp.o.d -o CMakeFiles/inicpp.dir/src/option_schema.cpp.o -c ../src/option_schema.cpp
In file included from ../src/option_schema.cpp:1:
In file included from ../include/inicpp/option_schema.h:11:
../include/inicpp/option.h:256:17: error: no viable conversion from 'std::__1::__bit_const_reference<std::__1::vector>' to 'inicpp::option_value' (aka 'variant<bool, long long, unsigned long long, double, inicpp::internal_enum_type, basic_string>')
option_value new_option_value = value;
^ ~~~~~
../include/inicpp/option.h:225:31: note: in instantiation of function template specialization 'inicpp::option::add_to_list<std::__1::__bit_const_reference<std::__1::vector>>' requested here
for (auto &&item : list) { add_to_list(item); }
^
../src/option_schema.cpp:67:10: note: in instantiation of function template specialization 'inicpp::option::set_list' requested here
opt.set_list(parse_typed_option_items(
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1204:3: note: candidate constructor not viable: no known conversion from 'std::__1::__bit_const_reference<std::__1::vector>' to 'const std::__1::variant<bool, long long, unsigned long long, double, inicpp::internal_enum_type, std::__1::basic_string> &' for 1st argument
variant(const variant&) = default;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1205:3: note: candidate constructor not viable: no known conversion from 'std::__1::__bit_const_reference<std::__1::vector>' to 'std::__1::variant<bool, long long, unsigned long long, double, inicpp::internal_enum_type, std::__1::basic_string> &&' for 1st argument
variant(variant&&) = default;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1217:13: note: candidate template ignored: substitution failure [with _Arg = std::__1::__bit_const_reference<std::__1::vector> &, $1 = 0, $2 = 0, $3 = 0]: no type named 'type' in 'std::__1::invoke_result<std::__1::__variant_detail::__all_overloads<std::__1::__variant_detail::__overload<bool, 0>, std::__1::__variant_detail::__overload<long long, 1>, std::__1::__variant_detail::__overload<unsigned long long, 2>, std::__1::__variant_detail::__overload<double, 3>, std::__1::__variant_detail::__overload<inicpp::internal_enum_type, 4>, std::__1::__variant_detail::__overload<std::__1::basic_string, 5>>, std::__1::__bit_const_reference<std::__1::vector> &, std::__1::__bit_const_reference<std::__1::vector> &>'
constexpr variant(_Arg&& __arg) noexcept(
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1226:22: note: explicit constructor is not a candidate
explicit constexpr variant(
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1254:22: note: explicit constructor is not a candidate
explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept(
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__bit_reference:145:49: note: candidate function
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
^
In file included from ../src/option_schema.cpp:1:
In file included from ../include/inicpp/option_schema.h:4:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:504:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:677:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/tuple:1067:5: error: static_assert failed due to requirement 'value != __not_found' "type not found in type list"
static_assert(value != __not_found, "type not found in type list" );
^ ~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/tuple:1080:14: note: in instantiation of template class 'std::__1::__find_detail::__find_exactly_one_checked<std::__1::__bit_const_reference<std::__1::vector>, bool, long long, unsigned long long, double, inicpp::internal_enum_type, std::__1::basic_string>' requested here
: public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/variant:1381:30: note: in instantiation of template class 'std::__1::__find_exactly_one_t<std::__1::__bit_const_reference<std::__1::vector>, bool, long long, unsigned long long, double, inicpp::internal_enum_type, std::__1::basic_string>' requested here
return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
^
../include/inicpp/option.h:138:16: note: in instantiation of function template specialization 'std::__1::holds_alternative<std::__1::__bit_const_reference<std::__1::vector>, bool, long long, unsigned long long, double, inicpp::internal_enum_type, std::_1::basic_string>' requested here
return std::holds_alternative(values
[0]);
^
../include/inicpp/option.h:255:9: note: in instantiation of function template specialization 'inicpp::option::holds_type<std::__1::__bit_const_reference<std::__1::vector>>' requested here
if (!holds_type()) { throw bad_cast_exception("Cannot cast to requested type"); }
^
../include/inicpp/option.h:225:31: note: in instantiation of function template specialization 'inicpp::option::add_to_list<std::__1::__bit_const_reference<std::__1::vector>>' requested here
for (auto &&item : list) { add_to_list(item); }
^
../src/option_schema.cpp:67:10: note: in instantiation of function template specialization 'inicpp::option::set_list' requested here
opt.set_list(parse_typed_option_items(
^
2 errors generated.
[8/9] Building CXX object CMakeFiles/inicpp.dir/src/parser.cpp.o
ninja: build stopped: subcommand failed.

Really old CMake version

Is it really necessary to support a 10 year old CMake version? This severely inhibits the ability to make this library more usable as a submodule because the current CMake version used does not even have target_compile_options, thus inicpp is polluting CMAKE_CXX_FLAGS which no library should ever do. Not to mention the deprecation warnings that users get on newer versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.