Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

simpleini

> 编程语言
Open source

Cross-platform C++ library providing a simple API to read and write INI-style configuration files

1.3K stars0 likes2 views
WebsiteGitHub

About

Cross-platform C++ library providing a simple API to read and write INI-style configuration files

simpleini

A cross-platform library that provides a simple API to read and write INI-style configuration files. It supports data files in ASCII, MBCS and Unicode. It is designed explicitly to be portable to any platform and has been tested on Windows, WinCE and Linux. Released as open-source and free using the MIT licence.

Full documentation

Feature Summary

  • MIT Licence allows free use in all software (including GPL and commercial)
  • multi-platform: Windows (from 95 to 11, CE), Linux, MacOS
  • loading and saving of INI-style configuration files
  • configuration files can have any newline format on all platforms
  • liberal acceptance of file format
    • key/values with no section, keys with no value
    • removal of whitespace around sections, keys and values
  • support for multi-line values (values with embedded newline characters)
  • optional support for multiple keys with the same name
  • optional case-insensitive sections and keys (for ASCII characters only)
  • saves files with sections and keys in the same order as they were loaded
  • preserves comments on the file, section and keys where possible
  • supports both char or wchar_t programming interfaces
  • supports both MBCS (system locale) and UTF-8 file encodings
  • supports ICU as conversion library on all platforms
  • system locale does not need to be UTF-8 on Linux/Unix to load UTF-8 file
  • support for non-ASCII characters in section, keys, values and comments
  • support for non-standard character types or file encodings via user-written converter classes
  • support for adding/modifying values programmatically
  • should compile with no warnings in most compilers

Documentation

Full documentation of the interface is available in doxygen format. See latest documentation here.

Installation

SimpleIni is a header-only library. No building is required to use it in your project.

Simply include SimpleIni.h in your source files:

cpp
#include "SimpleIni.h"

That's it! The library is ready to use.

Build and Test

While the library itself doesn't require building, you can build and run the test suite using CMake. A top-level Makefile wraps the usual CMake workflow for local development:

bash
make help          # list targets
make check         # format-check, build, and test
make format        # apply clang-format
make format-check  # verify formatting
make test          # run ctest
make clean         # remove build/

Requires cmake, a C++17 compiler, and clang-format for format targets. Test builds use -Werror. CMake remains the build system.

CI (.github/workflows/build-and-test.yml) runs make format-check on Linux only; tests run on Linux (x64 and arm64), Windows, macOS, and FreeBSD (14.4 via a VM on ubuntu-latest, currently disabled).

Direct CMake usage:

bash
# Configure the project
cmake -S . -B build

# Build the tests (optional)
cmake --build build

# To build without tests
cmake -S . -B build -DBUILD_TESTING=OFF
cmake --build build

# Run all tests
cd build
ctest --verbose

CMake Integration

To use SimpleIni in your CMake project:

cmake
# Add SimpleIni as a subdirectory
add_subdirectory(simpleini)

# Link against your target
target_link_libraries(your_target PRIVATE SimpleIni::SimpleIni)

Or install it system-wide:

bash
cmake -S . -B build
cmake --build build
sudo cmake --install build

Then in your CMake project:

cmake
find_package(SimpleIni REQUIRED)
target_link_libraries(your_target PRIVATE SimpleIni::SimpleIni)

Note that SI_CONVERT_GENERIC is not the default conversion mode. When enabled, UTF-8 conversion is built into the header; no additional source files are required.

Migration from ConvertUTF

Earlier releases shipped ConvertUTF.c and ConvertUTF.h for SI_CONVERT_GENERIC and expected you to compile them into your project. UTF-8 conversion is now inline in SimpleIni.h. Remove any ConvertUTF.c / ConvertUTF.h from your build and drop links to ConvertUTF.c; no replacement source files are required.

Examples

These snippets are included with the distribution in the automatic tests as ts-snippets.cpp.

SIMPLE USAGE

cpp
	// simple demonstration

	CSimpleIniA ini;
	ini.SetUnicode();

	SI_Error rc = ini.LoadFile("example.ini");
	if (rc pItem);
	}

MODIFYING DATA

…

DELETING DATA

cpp
	// deleting a key from a section. Optionally the entire
	// section may be deleted if it is now empty.
	bool done, deleteSectionIfEmpty = true;
	done = ini.Delete("section1", "key1", deleteSectionIfEmpty);
	ASSERT_EQ(done, true);
	done = ini.Delete("section1", "key1");
	ASSERT_EQ(done, false);

	// deleting an entire section and all keys in it
	done = ini.Delete("section2", nullptr);
	ASSERT_EQ(done, true);
	done = ini.Delete("section2", nullptr);
	ASSERT_EQ(done, false);

SAVING DATA

cpp
	// save the data to a string
	std::string data;
	rc = ini.Save(data);
	if (rc < 0) { /* handle error */ };
	ASSERT_EQ(rc, SI_OK);

	// save the data back to the file
	rc = ini.SaveFile("example2.ini");
	if (rc < 0) { /* handle error */ };
	ASSERT_EQ(rc, SI_OK);

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言