[cmake] final CPM fixes (#267)

- remove vcpkg references in docs
- move externals around
- fix non-cpm stuff
- remove redundant simpleini call/dir

Signed-off-by: crueter <crueter@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/267
Reviewed-by: Maufeat <sahyno1996@gmail.com>
This commit is contained in:
crueter
2025-08-16 03:19:02 +02:00
parent 1f5f9d34d1
commit d96da5104b
52 changed files with 140 additions and 11781 deletions

View File

@@ -96,7 +96,6 @@ cmake .. -G Ninja \
-DUSE_DISCORD_PRESENCE=ON \
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS" \
-DCMAKE_C_FLAGS="$ARCH_FLAGS" \
-DYUZU_USE_BUNDLED_VCPKG=OFF \
-DYUZU_USE_BUNDLED_QT=OFF \
-DYUZU_USE_BUNDLED_SDL2=OFF \
-DYUZU_USE_EXTERNAL_SDL2=ON \

View File

@@ -128,10 +128,6 @@ Copyright: 2020-2021 Its-Rei <kupfel@gmail.com>
2020-2021 yuzu Emulator Project
License: GPL-2.0-or-later
Files: vcpkg.json
Copyright: 2022 yuzu Emulator Project
License: GPL-3.0-or-later
Files: .github/ISSUE_TEMPLATE/*
Copyright: 2022 yuzu Emulator Project
License: GPL-2.0-or-later

View File

@@ -1,57 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "yuzu",
"builtin-baseline": "ea2a964f9303270322cf3f2d51c265ba146c422d",
"version": "1.0",
"dependencies": [
"boost-algorithm",
"boost-asio",
"boost-bind",
"boost-config",
"boost-container",
"boost-context",
"boost-crc",
"boost-functional",
"boost-heap",
"boost-icl",
"boost-intrusive",
"boost-mpl",
"boost-range",
"boost-spirit",
"boost-process",
"boost-test",
"boost-timer",
"boost-variant",
"fmt",
"lz4",
"nlohmann-json",
"zlib",
"zstd",
"sdl2"
],
"features": {
"yuzu-tests": {
"description": "Compile tests",
"dependencies": [ "catch2" ]
},
"web-service": {
"description": "Enable web services (telemetry, etc.)",
"dependencies": [
{
"name": "openssl"
}
]
}
},
"overrides": [
{
"name": "catch2",
"version": "3.3.1"
},
{
"name": "boost-process",
"version": "1.81.0"
}
]
}

View File

@@ -57,14 +57,7 @@ option(ENABLE_QT_UPDATE_CHECKER "Enable update checker for the Qt frontend" OFF)
CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF)
# TODO(crueter): maybe this should default on everywhere...?
if (MSVC OR ANDROID)
set(CPM_DEFAULT ON)
else()
set(CPM_DEFAULT OFF)
endif()
option(YUZU_USE_CPM "Use CPM for Eden dependencies" "${CPM_DEFAULT}")
option(YUZU_USE_CPM "Use CPM to fetch Eden dependencies if needed" ON)
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
option(ENABLE_WIFI_SCAN "Enable WiFi scanning" OFF)
@@ -101,7 +94,7 @@ set(YUZU_QT_MIRROR "" CACHE STRING "What mirror to use for downloading the bundl
option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF)
CMAKE_DEPENDENT_OPTION(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF "ENABLE_QT" OFF)
option(ENABLE_MICROPROFILE "Enables microprofile capabilities" OFF)
@@ -375,8 +368,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# System imported libraries
# =======================================================================
include(CPMUtil)
if (YUZU_USE_CPM)
include(CPMUtil)
message(STATUS "Fetching needed dependencies with CPM")
set(BUILD_SHARED_LIBS OFF)
@@ -421,6 +415,8 @@ if (YUZU_USE_CPM)
endif()
endif()
# boost
set(BOOST_INCLUDE_LIBRARIES algorithm icl pool container heap asio headers process filesystem crc variant)
AddPackage(
NAME Boost
REPO boostorg/boost
@@ -433,6 +429,8 @@ if (YUZU_USE_CPM)
VERSION 1.57
)
# really annoying thing where boost::headers doesn't work with cpm
# TODO(crueter) investigate
set(BOOST_NO_HEADERS ${Boost_ADDED})
if (Boost_ADDED)
@@ -450,6 +448,7 @@ if (YUZU_USE_CPM)
endif()
endif()
# fmt
AddPackage(
NAME fmt
REPO fmtlib/fmt
@@ -460,6 +459,7 @@ if (YUZU_USE_CPM)
"FMT_INSTALL OFF"
)
# lz4
AddPackage(
NAME lz4
REPO lz4/lz4
@@ -472,6 +472,7 @@ if (YUZU_USE_CPM)
add_library(lz4::lz4 ALIAS lz4_static)
endif()
# nlohmann
AddPackage(
NAME nlohmann_json
REPO nlohmann/json
@@ -480,14 +481,7 @@ if (YUZU_USE_CPM)
VERSION 3.8
)
AddPackage(
NAME SimpleIni
REPO brofield/simpleini
SHA 09c21bda1d
HASH 99779ca9b6e040d36558cadf484f9ffdab5b47bcc8fc72e4d33639d1d60c0ceb4410d335ba445d72a4324e455167fd6769d99b459943aa135bec085dff2d4b7c
EXCLUDE_FROM_ALL ON
)
# zlib
AddPackage(
NAME ZLIB
REPO madler/zlib
@@ -504,7 +498,7 @@ if (YUZU_USE_CPM)
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif()
set(ZSTD_BUILD_SHARED OFF)
# zstd
AddPackage(
NAME zstd
REPO facebook/zstd
@@ -512,9 +506,12 @@ if (YUZU_USE_CPM)
HASH 3037007f990040fe32573b46f9bef8762fd5dbeeb07ffffcbfeba51ec98167edae39bb9c87f9299efcd61c4e467c5e84f7c19f0df7799bc1fc04864a278792ee
VERSION 1.5
SOURCE_SUBDIR build/cmake
OPTIONS
"ZSTD_BUILD_SHARED OFF"
EXCLUDE_FROM_ALL ON
)
# Catch2
if (YUZU_TESTS OR DYNARMIC_TESTS)
AddPackage(
NAME Catch2
@@ -524,6 +521,72 @@ if (YUZU_USE_CPM)
VERSION 3.0.1
)
endif()
# ENet
AddPackage(
NAME enet
REPO lsalzman/enet
SHA 2662c0de09
VERSION 1.3
HASH 3de1beb4fa3d6b1e03eda8dd1e7580694f854af3ed3975dcdabfdcdf76b97f322b9734d35ea7f185855bb490d957842b938b26da4dd2dfded509390f8d2794dd
FIND_PACKAGE_ARGUMENTS "MODULE"
)
if (enet_ADDED)
target_include_directories(enet INTERFACE ${enet_SOURCE_DIR}/include)
endif()
# Opus
AddPackage(
NAME Opus
VERSION 1.3
REPO "xiph/opus"
SHA 5ded705cf4
HASH 0dc89e58ddda1f3bc6a7037963994770c5806c10e66f5cc55c59286fc76d0544fe4eca7626772b888fd719f434bc8a92f792bdb350c807968b2ac14cfc04b203
FIND_PACKAGE_ARGUMENTS "MODULE"
OPTIONS
"OPUS_BUILD_TESTING OFF"
"OPUS_BUILD_PROGRAMS OFF"
"OPUS_INSTALL_PKG_CONFIG_MODULE OFF"
"OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF"
)
if(ENABLE_CUBEB)
AddPackage(
NAME cubeb
REPO "mozilla/cubeb"
SHA fa02160712
HASH 82d808356752e4064de48c8fecbe7856715ade1e76b53937116bf07129fc1cc5b3de5e4b408de3cd000187ba8dc32ca4109661cb7e0355a52e54bd81b9be1c61
FIND_PACKAGE_ARGUMENTS "CONFIG" # not sure this works outside of gentoo
OPTIONS
"USE_SANITIZERS OFF"
"BUILD_TESTS OFF"
"BUILD_TOOLS OFF"
"BUNDLE_SPEEX ON"
)
if (cubeb_ADDED)
if (NOT MSVC)
if (TARGET speex)
target_compile_options(speex PRIVATE -Wno-sign-compare)
endif()
set_target_properties(cubeb PROPERTIES COMPILE_OPTIONS "")
target_compile_options(cubeb INTERFACE
-Wno-implicit-const-int-float-conversion
-Wno-shadow
-Wno-missing-declarations
-Wno-return-type
-Wno-uninitialized
)
else()
target_compile_options(cubeb PRIVATE
/wd4456
/wd4458
)
endif()
endif()
endif()
else()
# Enforce the search mode of non-required packages for better and shorter failure messages
find_package(fmt 8 REQUIRED)
@@ -531,11 +594,16 @@ else()
find_package(nlohmann_json 3.8 REQUIRED)
find_package(lz4 REQUIRED)
find_package(RenderDoc MODULE)
find_package(SimpleIni MODULE)
find_package(stb MODULE)
find_package(enet 1.3 MODULE)
find_package(Opus 1.3 MODULE)
find_package(ZLIB 1.2 REQUIRED)
find_package(zstd 1.5 REQUIRED)
if (ENABLE_CUBEB)
find_package(cubeb CONFIG)
endif()
if (YUZU_TESTS)
find_package(Catch2 3.0.1 REQUIRED)
endif()
@@ -549,6 +617,16 @@ else()
endif()
endif()
if(NOT TARGET Boost::headers)
AddPackage(
NAME boost_headers
REPO "boostorg/headers"
SHA 0456900fad
HASH 50cd75dcdfc5f082225cdace058f47b4fb114a47585f7aee1d22236a910a80b667186254c214fa2fcebac67ae6d37ba4b6e695e1faea8affd6fd42a03cf996e3
BUNDLED_PACKAGE ON
)
endif()
if (ENABLE_LIBUSB)
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
find_package(libusb MODULE)
@@ -557,6 +635,35 @@ if (ENABLE_LIBUSB)
endif()
endif()
# DiscordRPC
if (USE_DISCORD_PRESENCE)
AddPackage(
NAME discord-rpc
REPO "discord/discord-rpc"
SHA 963aa9f3e5
HASH 386e1344e9a666d730f2d335ee3aef1fd05b1039febefd51aa751b705009cc764411397f3ca08dffd46205c72f75b235c870c737b2091a4ed0c3b061f5919bde
OPTIONS
"BUILD_EXAMPLES OFF"
PATCHES
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0001-cmake-version.patch
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0002-no-clang-format.patch
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0003-fix-cpp17.patch
)
target_include_directories(discord-rpc INTERFACE ${discord-rpc_SOURCE_DIR}/include)
add_library(DiscordRPC::discord-rpc ALIAS discord-rpc)
endif()
# SimpleIni
AddPackage(
NAME SimpleIni
REPO brofield/simpleini
SHA 09c21bda1d
HASH 99779ca9b6e040d36558cadf484f9ffdab5b47bcc8fc72e4d33639d1d60c0ceb4410d335ba445d72a4324e455167fd6769d99b459943aa135bec085dff2d4b7c
EXCLUDE_FROM_ALL ON
FIND_PACKAGE_ARGUMENTS "MODULE"
)
# TODO(crueter): Work around this
if (NOT YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS)
find_package(PkgConfig REQUIRED)
@@ -634,7 +741,7 @@ if (ENABLE_WEB_SERVICE OR ENABLE_QT_UPDATE_CHECKER)
endif()
if (NOT YUZU_USE_BUNDLED_SDL2)
find_package(SDL2 REQUIRED)
find_package(SDL2)
endif()
if (ENABLE_QT)

13
docs/build/Linux.md vendored
View File

@@ -10,25 +10,28 @@ The following are handled by Eden's externals:
* [FFmpeg](https://ffmpeg.org/)
* [SDL2](https://www.libsdl.org/download-2.0.php) 2.0.18+
* [opus](https://opus-codec.org/downloads/)
* [opus](https://opus-codec.org/downloads/) 1.3+
All other dependencies will be downloaded by [vcpkg](https://vcpkg.io/) if needed:
All other dependencies will be downloaded and built by [CPM](https://github.com/cpm-cmake/CPM.cmake/) if `YUZU_USE_CPM` is on, but will use system dependencies if available:
* [Boost](https://www.boost.org/users/download/) 1.79.0+
* [Catch2](https://github.com/catchorg/Catch2) 2.13.7 - 2.13.9
* [fmt](https://fmt.dev/) 8.0.1+
* [lz4](http://www.lz4.org) 1.8+
* [nlohmann_json](https://github.com/nlohmann/json) 3.8+
* [OpenSSL](https://www.openssl.org/source/)
* [OpenSSL](https://www.openssl.org/source/) 1.1.1+
* [ZLIB](https://www.zlib.net/) 1.2+
* [zstd](https://facebook.github.io/zstd/) 1.5+
* [enet](http://enet.bespin.org/) 1.3+
* [cubeb](https://github.com/mozilla/cubeb)
* [SimpleIni](https://github.com/brofield/simpleini)
If an ARM64 build is intended, export `VCPKG_FORCE_SYSTEM_BINARIES=1`.
Certain other dependencies (httplib, jwt, sirit, etc.) will be fetched by CPM regardless. System packages *can* be used for these libraries but this is generally not recommended.
Dependencies are listed here as commands that can be copied/pasted. Of course, they should be inspected before being run.
- Arch / Manjaro:
- `sudo pacman -Syu --needed base-devel boost catch2 cmake ffmpeg fmt git glslang libzip lz4 mbedtls ninja nlohmann-json openssl opus qt6-base qt6-multimedia sdl2 zlib zstd zip unzip`
- `sudo pacman -Syu --needed base-devel boost catch2 cmake enet ffmpeg fmt git glslang libzip lz4 mbedtls ninja nlohmann-json openssl opus qt6-base qt6-multimedia sdl2 zlib zstd zip unzip`
- Building with QT Web Engine requires `qt6-webengine` as well.
- Proper wayland support requires `qt6-wayland`
- GCC 11 or later is required.

View File

@@ -10,7 +10,6 @@ On Windows, all library dependencies are automatically included within the `exte
* **[CMake](https://cmake.org/download/)** - Used to generate Visual Studio project files. Does not matter if either 32-bit or 64-bit version is installed.
* **[Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)** - **Make sure to select Latest SDK.**
- A convenience script to install the latest SDK is provided in `.ci\windows\install-vulkan-sdk.ps1`.
* **[OpenSSL](https://slproweb.com/products/Win32OpenSSL.html)** - You are recommended to keep the default install location, otherwise you will have to specify a custom OpenSSL root.
![2](https://i.imgur.com/giDwuTm.png)
@@ -48,8 +47,6 @@ On Windows, all library dependencies are automatically included within the `exte
* *(Note: If you used GitHub's own app to clone, run `git submodule update --init --recursive` to get the remaining dependencies)*
* If you get an error about missing packages, enable `YUZU_USE_BUNDLED_VCPKG`, and then click Configure again.
* *(You may also want to disable `YUZU_TESTS` in this case since Catch2 is not yet supported with this.)*
![13](https://user-images.githubusercontent.com/22451773/180585999-07316d6e-9751-4d11-b957-1cf57cd7cd58.png)
@@ -100,7 +97,7 @@ On Windows, all library dependencies are automatically included within the `exte
```bash
mkdir build && cd build
cmake -G "MSYS Makefiles" -DYUZU_USE_BUNDLED_VCPKG=ON -DYUZU_TESTS=OFF ..
cmake -G "MSYS Makefiles" -DYUZU_TESTS=OFF ..
make -j$(nproc)
# test eden out with
./bin/eden.exe

View File

@@ -59,7 +59,7 @@ if (ARCHITECTURE_arm64 OR DYNARMIC_TESTS)
SHA 94c726ce03
HASH d8d082242fa1881abce3c82f8dafa002c4e561e66a69e7fc038af67faa5eff2630f082d3d19579c88c4c9f9488e54552accc8cb90e7ce743efe043b6230c08ac
)
endif()
endif()
# getopt
if (MSVC)
@@ -70,7 +70,6 @@ endif()
add_subdirectory(glad)
# mbedtls
# TODO(crueter): test local mbedtls
AddPackage(
NAME mbedtls
REPO "Mbed-TLS/mbedtls"
@@ -138,74 +137,6 @@ if (NOT YUZU_USE_BUNDLED_SDL2)
)
endif()
# ENet
AddPackage(
NAME enet
REPO lsalzman/enet
SHA 2662c0de09
VERSION 1.3
HASH 3de1beb4fa3d6b1e03eda8dd1e7580694f854af3ed3975dcdabfdcdf76b97f322b9734d35ea7f185855bb490d957842b938b26da4dd2dfded509390f8d2794dd
FIND_PACKAGE_ARGUMENTS "MODULE"
)
if (enet_ADDED)
target_include_directories(enet INTERFACE ${enet_SOURCE_DIR}/include)
endif()
AddPackage(
NAME cubeb
REPO "mozilla/cubeb"
SHA fa02160712
HASH 82d808356752e4064de48c8fecbe7856715ade1e76b53937116bf07129fc1cc5b3de5e4b408de3cd000187ba8dc32ca4109661cb7e0355a52e54bd81b9be1c61
FIND_PACKAGE_ARGUMENTS "CONFIG" # not sure this works outside of gentoo
OPTIONS
"USE_SANITIZERS OFF"
"BUILD_TESTS OFF"
"BUILD_TOOLS OFF"
"BUNDLE_SPEEX ON"
)
if (cubeb_ADDED)
if (NOT MSVC)
if (TARGET speex)
target_compile_options(speex PRIVATE -Wno-sign-compare)
endif()
set_target_properties(cubeb PROPERTIES COMPILE_OPTIONS "")
target_compile_options(cubeb INTERFACE
-Wno-implicit-const-int-float-conversion
-Wno-shadow
-Wno-missing-declarations
-Wno-return-type
-Wno-uninitialized
)
else()
target_compile_options(cubeb PRIVATE
/wd4456
/wd4458
)
endif()
endif()
# DiscordRPC
if (USE_DISCORD_PRESENCE)
AddPackage(
NAME discord-rpc
REPO "discord/discord-rpc"
SHA 963aa9f3e5
HASH 386e1344e9a666d730f2d335ee3aef1fd05b1039febefd51aa751b705009cc764411397f3ca08dffd46205c72f75b235c870c737b2091a4ed0c3b061f5919bde
OPTIONS
"BUILD_EXAMPLES OFF"
PATCHES
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0001-cmake-version.patch
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0002-no-clang-format.patch
${CMAKE_SOURCE_DIR}/.patch/discord-rpc/0003-fix-cpp17.patch
)
target_include_directories(discord-rpc INTERFACE ${discord-rpc_SOURCE_DIR}/include)
add_library(DiscordRPC::discord-rpc ALIAS discord-rpc)
endif()
# Sirit
# TODO(crueter): spirv-tools doesn't work w/ system
AddPackage(
@@ -225,7 +156,7 @@ AddPackage(
)
# httplib
if ((ENABLE_WEB_SERVICE OR ENABLE_QT_UPDATE_CHECKER))
if (ENABLE_WEB_SERVICE OR ENABLE_QT_UPDATE_CHECKER)
AddPackage(
NAME httplib
REPO "yhirose/cpp-httplib"
@@ -255,21 +186,6 @@ if (ENABLE_WEB_SERVICE)
)
endif()
# Opus
AddPackage(
NAME Opus
VERSION 1.3
REPO "xiph/opus"
SHA 5ded705cf4
HASH 0dc89e58ddda1f3bc6a7037963994770c5806c10e66f5cc55c59286fc76d0544fe4eca7626772b888fd719f434bc8a92f792bdb350c807968b2ac14cfc04b203
FIND_PACKAGE_ARGUMENTS "MODULE"
OPTIONS
"OPUS_BUILD_TESTING OFF"
"OPUS_BUILD_PROGRAMS OFF"
"OPUS_INSTALL_PKG_CONFIG_MODULE OFF"
"OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF"
)
# FFMpeg
if (YUZU_USE_BUNDLED_FFMPEG)
add_subdirectory(ffmpeg)
@@ -292,11 +208,6 @@ AddPackage(
BUNDLED_PACKAGE ${YUZU_USE_EXTERNAL_VULKAN_HEADERS}
)
# CMake's interface generator sucks
# if (VulkanHeaders_ADDED)
# target_include_directories(Vulkan-Headers INTERFACE ${VulkanHeaders_SOURCE_DIR}/include)
# endif()
# Vulkan-Utility-Libraries
AddPackage(
NAME VulkanUtilityLibraries
@@ -318,17 +229,6 @@ if (YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS)
)
endif()
# Boost headers
if (NOT Boost_ADDED AND NOT TARGET Boost::headers)
AddPackage(
NAME boost_headers
REPO "boostorg/headers"
SHA 0456900fad
HASH 50cd75dcdfc5f082225cdace058f47b4fb114a47585f7aee1d22236a910a80b667186254c214fa2fcebac67ae6d37ba4b6e695e1faea8affd6fd42a03cf996e3
BUNDLED_PACKAGE ON
)
endif()
# TZDB (Time Zone Database)
add_subdirectory(nx_tzdb)
@@ -500,11 +400,6 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
endif()
endif()
# SimpleIni
if (NOT TARGET SimpleIni::SimpleIni)
add_subdirectory(simpleini)
endif()
# oboe
if (ANDROID)
AddPackage(
@@ -512,6 +407,7 @@ if (ANDROID)
REPO "google/oboe"
SHA 2bc873e53c
HASH 02329058a7f9cf7d5039afaae5ab170d9f42f60f4c01e21eaf4f46073886922b057a9ae30eeac040b3ac182f51b9c1bfe9fe1050a2c9f6ce567a1a9a0ec2c768
BUNDLED_PACKAGE ON
)
add_library(oboe::oboe ALIAS oboe)

View File

@@ -1,61 +0,0 @@
name: Build and Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
Windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: microsoft/setup-msbuild@v2
- name: Build
run: |
nuget restore vcproj\SimpleIni.sln
msbuild vcproj\SimpleIni.sln /p:Configuration=Release
- name: Run tests
run: |
cd tests
..\vcproj\x64\Release\tests.exe
Ubuntu:
runs-on: ubuntu-latest
steps:
- name: Install requirements
run: sudo apt install libgtest-dev cmake
- uses: actions/checkout@v3
- run: make all && make test
- name: test with CMake (-DSIMPLEINI_USE_SYSTEM_GTEST=OFF)
run: |
cmake . -B build -DSIMPLEINI_USE_SYSTEM_GTEST=OFF
cmake --build build
ctest --verbose --test-dir build
- name: test with CMake (-DSIMPLEINI_USE_SYSTEM_GTEST=ON)
run: |
cmake . -B build-system-gtest -DSIMPLEINI_USE_SYSTEM_GTEST=ON
cmake --build build-system-gtest
ctest --verbose --test-dir build-system-gtest
MacOS:
runs-on: macos-latest
steps:
- name: Install requirements
run: brew install googletest cmake
- uses: actions/checkout@v3
- run: make all && make test
- name: test with CMake (-DSIMPLEINI_USE_SYSTEM_GTEST=OFF)
run: |
cmake . -B build -DSIMPLEINI_USE_SYSTEM_GTEST=OFF
cmake --build build
ctest --verbose --test-dir build
- name: test with CMake (-DSIMPLEINI_USE_SYSTEM_GTEST=ON)
run: |
cmake . -B build-system-gtest -DSIMPLEINI_USE_SYSTEM_GTEST=ON
cmake --build build-system-gtest
ctest --verbose --test-dir build-system-gtest

View File

@@ -1,24 +0,0 @@
name: Build Doxygen Docs
on:
workflow_run:
workflows: ["Build and Test"]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Doxygen
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
- name: Generate Doxygen Documentation
run: doxygen Doxyfile
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html

View File

@@ -1,37 +0,0 @@
name: "CodeQL"
on: workflow_dispatch
#on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -1,365 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
docs
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
build/
build-system-gtest/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -1,66 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(
SimpleIni
VERSION 4.22
DESCRIPTION "Cross-platform C++ library providing a simple API to read and write INI-style configuration files"
LANGUAGES CXX
)
option(SIMPLEINI_USE_SYSTEM_GTEST "Use system GoogleTest dependency" OFF)
# disable in-source builds
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed, use cmake -S . -B build.")
endif()
# Define library paths and include directories
set(EXPORT_NAMESPACE "${PROJECT_NAME}::")
set(HEADERS SimpleIni.h)
add_library(${PROJECT_NAME} INTERFACE)
add_library(${EXPORT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}
)
install(FILES SimpleIni.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}
)
install(EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}
NAMESPACE ${EXPORT_NAMESPACE}
)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# only build tests when top level and testing enabled
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
endif()

View File

@@ -1,578 +0,0 @@
/*
* https://web.archive.org/web/20090529064329/http://www.unicode.org:80/Public/PROGRAMS/CVTUTF/
*
* Copyright 2001-2004 Unicode, Inc.
*
* Disclaimer
*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
* applicability of information provided. If this file has been
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
*
* Limitations on Rights to Redistribute This Code
*
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
* for internal or external distribution as long as this notice
* remains attached.
*/
/* ---------------------------------------------------------------------
Conversions between UTF32, UTF-16, and UTF-8. Source code file.
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
Sept 2001: fixed const & error conditions per
mods suggested by S. Parent & A. Lillich.
June 2002: Tim Dodd added detection and handling of incomplete
source sequences, enhanced error detection, added casts
to eliminate compiler warnings.
July 2003: slight mods to back out aggressive FFFE detection.
Jan 2004: updated switches in from-UTF8 conversions.
Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
See the header file "ConvertUTF.h" for complete documentation.
------------------------------------------------------------------------ */
#include "ConvertUTF.h"
#ifdef CVTUTF_DEBUG
#include <stdio.h>
#endif
static const int halfShift = 10; /* used for shifting by 10 bits */
static const UTF32 halfBase = 0x0010000UL;
static const UTF32 halfMask = 0x3FFUL;
#define UNI_SUR_HIGH_START (UTF32)0xD800
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
#define UNI_SUR_LOW_START (UTF32)0xDC00
#define UNI_SUR_LOW_END (UTF32)0xDFFF
#define false 0
#define true 1
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF32toUTF16(
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF32* source = *sourceStart;
UTF16* target = *targetStart;
while (source < sourceEnd) {
UTF32 ch;
if (target >= targetEnd) {
result = targetExhausted; break;
}
ch = *source++;
if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
/* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
if (flags == strictConversion) {
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
else {
*target++ = UNI_REPLACEMENT_CHAR;
}
}
else {
*target++ = (UTF16)ch; /* normal case */
}
}
else if (ch > UNI_MAX_LEGAL_UTF32) {
if (flags == strictConversion) {
result = sourceIllegal;
}
else {
*target++ = UNI_REPLACEMENT_CHAR;
}
}
else {
/* target is a character in range 0xFFFF - 0x10FFFF. */
if (target + 1 >= targetEnd) {
--source; /* Back up source pointer! */
result = targetExhausted; break;
}
ch -= halfBase;
*target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
*target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
}
}
*sourceStart = source;
*targetStart = target;
return result;
}
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF16toUTF32(
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF16* source = *sourceStart;
UTF32* target = *targetStart;
UTF32 ch, ch2;
while (source < sourceEnd) {
const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
ch = *source++;
/* If we have a surrogate pair, convert to UTF32 first. */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
/* If the 16 bits following the high surrogate are in the source buffer... */
if (source < sourceEnd) {
ch2 = *source;
/* If it's a low surrogate, convert to UTF32. */
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
++source;
}
else if (flags == strictConversion) { /* it's an unpaired high surrogate */
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
}
else { /* We don't have the 16 bits following the high surrogate. */
--source; /* return to the high surrogate */
result = sourceExhausted;
break;
}
}
else if (flags == strictConversion) {
/* UTF-16 surrogate values are illegal in UTF-32 */
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
}
if (target >= targetEnd) {
source = oldSource; /* Back up source pointer! */
result = targetExhausted; break;
}
*target++ = ch;
}
*sourceStart = source;
*targetStart = target;
#ifdef CVTUTF_DEBUG
if (result == sourceIllegal) {
fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2);
fflush(stderr);
}
#endif
return result;
}
/* --------------------------------------------------------------------- */
/*
* Index into the table below with the first byte of a UTF-8 sequence to
* get the number of trailing bytes that are supposed to follow it.
* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
* left as-is for anyone who may want to do such conversion, which was
* allowed in earlier algorithms.
*/
static const char trailingBytesForUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
};
/*
* Magic values subtracted from a buffer value during UTF8 conversion.
* This table contains as many values as there might be trailing bytes
* in a UTF-8 sequence.
*/
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
/*
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
* into the first byte, depending on how many bytes follow. There are
* as many entries in this table as there are UTF-8 sequence types.
* (I.e., one byte sequence, two byte... etc.). Remember that sequencs
* for *legal* UTF-8 will be 4 or fewer bytes total.
*/
static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
/* --------------------------------------------------------------------- */
/* The interface converts a whole buffer to avoid function-call overhead.
* Constants have been gathered. Loops & conditionals have been removed as
* much as possible for efficiency, in favor of drop-through switches.
* (See "Note A" at the bottom of the file for equivalent code.)
* If your compiler supports it, the "isLegalUTF8" call can be turned
* into an inline function.
*/
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF16toUTF8(
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF16* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
UTF32 ch;
unsigned short bytesToWrite = 0;
const UTF32 byteMask = 0xBF;
const UTF32 byteMark = 0x80;
const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
ch = *source++;
/* If we have a surrogate pair, convert to UTF32 first. */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
/* If the 16 bits following the high surrogate are in the source buffer... */
if (source < sourceEnd) {
UTF32 ch2 = *source;
/* If it's a low surrogate, convert to UTF32. */
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
++source;
}
else if (flags == strictConversion) { /* it's an unpaired high surrogate */
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
}
else { /* We don't have the 16 bits following the high surrogate. */
--source; /* return to the high surrogate */
result = sourceExhausted;
break;
}
}
else if (flags == strictConversion) {
/* UTF-16 surrogate values are illegal in UTF-32 */
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
}
/* Figure out how many bytes the result will require */
if (ch < (UTF32)0x80) {
bytesToWrite = 1;
}
else if (ch < (UTF32)0x800) {
bytesToWrite = 2;
}
else if (ch < (UTF32)0x10000) {
bytesToWrite = 3;
}
else if (ch < (UTF32)0x110000) {
bytesToWrite = 4;
}
else {
bytesToWrite = 3;
ch = UNI_REPLACEMENT_CHAR;
}
target += bytesToWrite;
if (target > targetEnd) {
source = oldSource; /* Back up source pointer! */
target -= bytesToWrite; result = targetExhausted; break;
}
switch (bytesToWrite) { /* note: everything falls through. */
case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
}
target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
return result;
}
/* --------------------------------------------------------------------- */
/*
* Utility routine to tell whether a sequence of bytes is legal UTF-8.
* This must be called with the length pre-determined by the first byte.
* If not calling this from ConvertUTF8to*, then the length can be set by:
* length = trailingBytesForUTF8[*source]+1;
* and the sequence is illegal right away if there aren't that many bytes
* available.
* If presented with a length > 4, this returns false. The Unicode
* definition of UTF-8 goes up to 4-byte sequences.
*/
static Boolean isLegalUTF8(const UTF8* source, int length) {
UTF8 a;
const UTF8* srcptr = source + length;
switch (length) {
default: return false;
/* Everything else falls through when "true"... */
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 2: if ((a = (*--srcptr)) > 0xBF) return false;
switch (*source) {
/* no fall-through in this inner switch */
case 0xE0: if (a < 0xA0) return false; break;
case 0xED: if (a > 0x9F) return false; break;
case 0xF0: if (a < 0x90) return false; break;
case 0xF4: if (a > 0x8F) return false; break;
default: if (a < 0x80) return false;
}
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
}
if (*source > 0xF4) return false;
return true;
}
/* --------------------------------------------------------------------- */
/*
* Exported function to return whether a UTF-8 sequence is legal or not.
* This is not used here; it's just exported.
*/
Boolean isLegalUTF8Sequence(const UTF8* source, const UTF8* sourceEnd) {
int length = trailingBytesForUTF8[*source] + 1;
if (source + length > sourceEnd) {
return false;
}
return isLegalUTF8(source, length);
}
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF16(
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF16* target = *targetStart;
while (source < sourceEnd) {
UTF32 ch = 0;
unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
if (source + extraBytesToRead >= sourceEnd) {
result = sourceExhausted; break;
}
/* Do this check whether lenient or strict */
if (!isLegalUTF8(source, extraBytesToRead + 1)) {
result = sourceIllegal;
break;
}
/*
* The cases all fall through. See "Note A" below.
*/
switch (extraBytesToRead) {
case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
case 3: ch += *source++; ch <<= 6;
case 2: ch += *source++; ch <<= 6;
case 1: ch += *source++; ch <<= 6;
case 0: ch += *source++;
}
ch -= offsetsFromUTF8[extraBytesToRead];
if (target >= targetEnd) {
source -= (extraBytesToRead + 1); /* Back up source pointer! */
result = targetExhausted; break;
}
if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
/* UTF-16 surrogate values are illegal in UTF-32 */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
if (flags == strictConversion) {
source -= (extraBytesToRead + 1); /* return to the illegal value itself */
result = sourceIllegal;
break;
}
else {
*target++ = UNI_REPLACEMENT_CHAR;
}
}
else {
*target++ = (UTF16)ch; /* normal case */
}
}
else if (ch > UNI_MAX_UTF16) {
if (flags == strictConversion) {
result = sourceIllegal;
source -= (extraBytesToRead + 1); /* return to the start */
break; /* Bail out; shouldn't continue */
}
else {
*target++ = UNI_REPLACEMENT_CHAR;
}
}
else {
/* target is a character in range 0xFFFF - 0x10FFFF. */
if (target + 1 >= targetEnd) {
source -= (extraBytesToRead + 1); /* Back up source pointer! */
result = targetExhausted; break;
}
ch -= halfBase;
*target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
*target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
}
}
*sourceStart = source;
*targetStart = target;
return result;
}
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF32toUTF8(
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF32* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
UTF32 ch;
unsigned short bytesToWrite = 0;
const UTF32 byteMask = 0xBF;
const UTF32 byteMark = 0x80;
ch = *source++;
if (flags == strictConversion) {
/* UTF-16 surrogate values are illegal in UTF-32 */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
--source; /* return to the illegal value itself */
result = sourceIllegal;
break;
}
}
/*
* Figure out how many bytes the result will require. Turn any
* illegally large UTF32 things (> Plane 17) into replacement chars.
*/
if (ch < (UTF32)0x80) {
bytesToWrite = 1;
}
else if (ch < (UTF32)0x800) {
bytesToWrite = 2;
}
else if (ch < (UTF32)0x10000) {
bytesToWrite = 3;
}
else if (ch <= UNI_MAX_LEGAL_UTF32) {
bytesToWrite = 4;
}
else {
bytesToWrite = 3;
ch = UNI_REPLACEMENT_CHAR;
result = sourceIllegal;
}
target += bytesToWrite;
if (target > targetEnd) {
--source; /* Back up source pointer! */
target -= bytesToWrite; result = targetExhausted; break;
}
switch (bytesToWrite) { /* note: everything falls through. */
case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
}
target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
return result;
}
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF32(
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF32* target = *targetStart;
while (source < sourceEnd) {
UTF32 ch = 0;
unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
if (source + extraBytesToRead >= sourceEnd) {
result = sourceExhausted; break;
}
/* Do this check whether lenient or strict */
if (!isLegalUTF8(source, extraBytesToRead + 1)) {
result = sourceIllegal;
break;
}
/*
* The cases all fall through. See "Note A" below.
*/
switch (extraBytesToRead) {
case 5: ch += *source++; ch <<= 6;
case 4: ch += *source++; ch <<= 6;
case 3: ch += *source++; ch <<= 6;
case 2: ch += *source++; ch <<= 6;
case 1: ch += *source++; ch <<= 6;
case 0: ch += *source++;
}
ch -= offsetsFromUTF8[extraBytesToRead];
if (target >= targetEnd) {
source -= (extraBytesToRead + 1); /* Back up the source pointer! */
result = targetExhausted; break;
}
if (ch <= UNI_MAX_LEGAL_UTF32) {
/*
* UTF-16 surrogate values are illegal in UTF-32, and anything
* over Plane 17 (> 0x10FFFF) is illegal.
*/
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
if (flags == strictConversion) {
source -= (extraBytesToRead + 1); /* return to the illegal value itself */
result = sourceIllegal;
break;
}
else {
*target++ = UNI_REPLACEMENT_CHAR;
}
}
else {
*target++ = ch;
}
}
else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
result = sourceIllegal;
*target++ = UNI_REPLACEMENT_CHAR;
}
}
*sourceStart = source;
*targetStart = target;
return result;
}
/* ---------------------------------------------------------------------
Note A.
The fall-through switches in UTF-8 reading code save a
temp variable, some decrements & conditionals. The switches
are equivalent to the following loop:
{
int tmpBytesToRead = extraBytesToRead+1;
do {
ch += *source++;
--tmpBytesToRead;
if (tmpBytesToRead) ch <<= 6;
} while (tmpBytesToRead > 0);
}
In UTF-8 writing code, the switches on "bytesToWrite" are
similarly unrolled loops.
--------------------------------------------------------------------- */

View File

@@ -1,151 +0,0 @@
/*
* https://web.archive.org/web/20090529064329/http://www.unicode.org:80/Public/PROGRAMS/CVTUTF/
*
* Copyright 2001-2004 Unicode, Inc.
*
* Disclaimer
*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
* applicability of information provided. If this file has been
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
*
* Limitations on Rights to Redistribute This Code
*
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
* for internal or external distribution as long as this notice
* remains attached.
*/
/* ---------------------------------------------------------------------
Conversions between UTF32, UTF-16, and UTF-8. Header file.
Several funtions are included here, forming a complete set of
conversions between the three formats. UTF-7 is not included
here, but is handled in a separate source file.
Each of these routines takes pointers to input buffers and output
buffers. The input buffers are const.
Each routine converts the text between *sourceStart and sourceEnd,
putting the result into the buffer between *targetStart and
targetEnd. Note: the end pointers are *after* the last item: e.g.
*(sourceEnd - 1) is the last item.
The return result indicates whether the conversion was successful,
and if not, whether the problem was in the source or target buffers.
(Only the first encountered problem is indicated.)
After the conversion, *sourceStart and *targetStart are both
updated to point to the end of last text successfully converted in
the respective buffers.
Input parameters:
sourceStart - pointer to a pointer to the source buffer.
The contents of this are modified on return so that
it points at the next thing to be converted.
targetStart - similarly, pointer to pointer to the target buffer.
sourceEnd, targetEnd - respectively pointers to the ends of the
two buffers, for overflow checking only.
These conversion functions take a ConversionFlags argument. When this
flag is set to strict, both irregular sequences and isolated surrogates
will cause an error. When the flag is set to lenient, both irregular
sequences and isolated surrogates are converted.
Whether the flag is strict or lenient, all illegal sequences will cause
an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
must check for illegal sequences.
When the flag is set to lenient, characters over 0x10FFFF are converted
to the replacement character; otherwise (when the flag is set to strict)
they constitute an error.
Output parameters:
The value "sourceIllegal" is returned from some routines if the input
sequence is malformed. When "sourceIllegal" is returned, the source
value will point to the illegal value that caused the problem. E.g.,
in UTF-8 when a sequence is malformed, it points to the start of the
malformed sequence.
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
Fixes & updates, Sept 2001.
------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------
The following 4 definitions are compiler-specific.
The C standard does not guarantee that wchar_t has at least
16 bits, so wchar_t is no less portable than unsigned short!
All should be unsigned values to avoid sign extension during
bit mask & shift operations.
------------------------------------------------------------------------ */
typedef unsigned long UTF32; /* at least 32 bits */
typedef unsigned short UTF16; /* at least 16 bits */
typedef unsigned char UTF8; /* typically 8 bits */
typedef unsigned char Boolean; /* 0 or 1 */
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
#define UNI_MAX_BMP (UTF32)0x0000FFFF
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
typedef enum {
conversionOK, /* conversion successful */
sourceExhausted, /* partial character in source, but hit end */
targetExhausted, /* insuff. room in target for conversion */
sourceIllegal /* source sequence is illegal/malformed */
} ConversionResult;
typedef enum {
strictConversion = 0,
lenientConversion
} ConversionFlags;
/* This is for C++ and does no harm in C */
#ifdef __cplusplus
extern "C" {
#endif
ConversionResult ConvertUTF8toUTF16(
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF8(
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF8toUTF32(
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF8(
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF32(
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF16(
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
Boolean isLegalUTF8Sequence(const UTF8* source, const UTF8* sourceEnd);
#ifdef __cplusplus
}
#endif
/* --------------------------------------------------------------------- */

View File

@@ -1,43 +0,0 @@
https://web.archive.org/web/20090529064329/http://www.unicode.org:80/Public/PROGRAMS/CVTUTF/
The accompanying C source code file "ConvertUTF.c" and the associated header
file "ConvertUTF.h" provide for conversion between various transformation
formats of Unicode characters. The following conversions are supported:
UTF-32 to UTF-16
UTF-32 to UTF-8
UTF-16 to UTF-32
UTF-16 to UTF-8
UTF-8 to UTF-16
UTF-8 to UTF-32
In addition, there is a test harness which runs various tests.
The files "CVTUTF7.C" and "CVTUTF7.H" are for archival and historical purposes
only. They have not been updated to Unicode 3.0 or later and should be
considered obsolescent. "CVTUTF7.C" contains two functions that can convert
between UCS2 (i.e., the BMP characters only) and UTF-7. Surrogates are
not supported, the code has not been tested, and should be considered
unsuitable for general purpose use.
Please submit any bug reports about these programs here:
http://www.unicode.org/unicode/reporting.html
Version 1.0: initial version.
Version 1.1: corrected some minor problems; added stricter checks.
Version 1.2: corrected switch statements associated with "extraBytesToRead"
in 4 & 5 byte cases, in functions for conversion from UTF8.
Note: formally, the 4 & 5 byte cases are illegal in the latest
UTF8, but the table and this code has always catered for those,
cases since at one time they were legal.
Version 1.3: Updated UTF-8 legality check;
updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions
Updated UTF-8 legality tests in harness.c
Last update: October 19, 2004

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2006-2024 Brodie Thiesfield
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,18 +0,0 @@
# This makefile is just to build the automatic test harness
# To use SimpleIni, just include SimpleIni.h header file
PREFIX?= /usr/local
TOPTARGETS := all clean test
SUBDIRS := tests
$(TOPTARGETS): $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
.PHONY: $(TOPTARGETS) $(SUBDIRS)
install:
mkdir -p $(DESTDIR)$(PREFIX)/include/
install -C -m 644 SimpleIni.h $(DESTDIR)$(PREFIX)/include/

View File

@@ -1,199 +0,0 @@
simpleini
=========
![Latest Test Results](https://github.com/brofield/simpleini/actions/workflows/build-and-test.yml/badge.svg)
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](https://brofield.github.io/simpleini/)
# 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](https://brofield.github.io/simpleini/).
# Examples
These snippets are included with the distribution in the automatic tests as ts-snippets.cpp.
### SIMPLE USAGE
```c++
// simple demonstration
CSimpleIniA ini;
ini.SetUnicode();
SI_Error rc = ini.LoadFile("example.ini");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
const char* pv;
pv = ini.GetValue("section", "key", "default");
ASSERT_STREQ(pv, "value");
ini.SetValue("section", "key", "newvalue");
pv = ini.GetValue("section", "key", "default");
ASSERT_STREQ(pv, "newvalue");
```
### LOADING DATA
```c++
// load from a data file
CSimpleIniA ini;
SI_Error rc = ini.LoadFile("example.ini");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
// load from a string
const std::string example = "[section]\nkey = value\n";
CSimpleIniA ini;
SI_Error rc = ini.LoadData(example);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
```
### GETTING SECTIONS AND KEYS
```c++
// get all sections
CSimpleIniA::TNamesDepend sections;
ini.GetAllSections(sections);
// get all keys in a section
CSimpleIniA::TNamesDepend keys;
ini.GetAllKeys("section1", keys);
```
### GETTING VALUES
```c++
// get the value of a key that doesn't exist
const char* pv;
pv = ini.GetValue("section1", "key99");
ASSERT_EQ(pv, nullptr);
// get the value of a key that does exist
pv = ini.GetValue("section1", "key1");
ASSERT_STREQ(pv, "value1");
// get the value of a key which may have multiple
// values. If hasMultiple is true, then there are
// multiple values and just one value has been returned
bool hasMulti;
pv = ini.GetValue("section1", "key1", nullptr, &hasMulti);
ASSERT_STREQ(pv, "value1");
ASSERT_EQ(hasMulti, false);
pv = ini.GetValue("section1", "key2", nullptr, &hasMulti);
ASSERT_STREQ(pv, "value2.1");
ASSERT_EQ(hasMulti, true);
// get all values of a key with multiple values
CSimpleIniA::TNamesDepend values;
ini.GetAllValues("section1", "key2", values);
// sort the values into a known order, in this case we want
// the original load order
values.sort(CSimpleIniA::Entry::LoadOrder());
// output all of the items
CSimpleIniA::TNamesDepend::const_iterator it;
for (it = values.begin(); it != values.end(); ++it) {
printf("value = '%s'\n", it->pItem);
}
```
### MODIFYING DATA
```c++
// add a new section
rc = ini.SetValue("section1", nullptr, nullptr);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_INSERTED);
// not an error to add one that already exists
rc = ini.SetValue("section1", nullptr, nullptr);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_UPDATED);
// get the value of a key that doesn't exist
const char* pv;
pv = ini.GetValue("section2", "key1", "default-value");
ASSERT_STREQ(pv, "default-value");
// adding a key (the section will be added if needed)
rc = ini.SetValue("section2", "key1", "value1");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_INSERTED);
// ensure it is set to expected value
pv = ini.GetValue("section2", "key1", nullptr);
ASSERT_STREQ(pv, "value1");
// change the value of a key
rc = ini.SetValue("section2", "key1", "value2");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_UPDATED);
// ensure it is set to expected value
pv = ini.GetValue("section2", "key1", nullptr);
ASSERT_STREQ(pv, "value2");
```
### DELETING DATA
```c++
// 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
```c++
// 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);
```

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
@PACKAGE_INIT@
# prevent repeatedly including the targets
if(NOT TARGET @PROJECT_NAME@::@PROJECT_NAME@)
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
endif()
message(STATUS "Found @PROJECT_NAME@, version: ${@PROJECT_NAME@_VERSION}")

View File

@@ -1,26 +0,0 @@
set VERSION=4.15
set SEVENZIP="C:\Program Files\7-Zip\7z.exe"
FOR /F "tokens=*" %%G IN ('DIR /AD /B /S Debug*') DO (
DEL /S /Q "%%G"
RD "%%G"
)
FOR /F "tokens=*" %%G IN ('DIR /AD /B /S Release*') DO (
DEL /S /Q "%%G"
RD "%%G"
)
DEL /Q "SimpleIni.ncb"
ATTRIB -H "SimpleIni.suo"
DEL /Q "SimpleIni.suo"
DEL /Q "SimpleIni.opt"
DEL /Q testsi-out*.ini
DEL /Q test1-blah.ini
DEL /Q test1-output.ini
START "Generate documentation" /WAIT "C:\Program Files (x86)\doxygen\bin\doxygen.exe" SimpleIni.doxy
cd ..
del simpleini-%VERSION%.zip
%SEVENZIP% a -tzip -r- -x!simpleini\.svn simpleini-%VERSION%.zip simpleini\*
del simpleini-doc.zip
%SEVENZIP% a -tzip -r simpleini-doc.zip simpleini-doc\*
cd simpleini

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
Making a release:
* update version number in SimpleIni.h
* update version number in CMakeLists.txt
* check-in all files
* make a release "v4.22" etc creating a matching tag

View File

@@ -1,5 +0,0 @@
example2.ini
tests
*.o

View File

@@ -1,30 +0,0 @@
if(SIMPLEINI_USE_SYSTEM_GTEST)
find_package(GTest REQUIRED)
else()
include(FetchContent)
FetchContent_Declare(
googletest
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
URL_HASH SHA1=0ac421f2ec11af38b0fff0f1992184032731a8bc
)
FetchContent_MakeAvailable(googletest)
endif()
add_executable(tests
ts-bugfix.cpp
ts-noconvert.cpp
ts-quotes.cpp
ts-roundtrip.cpp
ts-snippets.cpp
ts-utf8.cpp)
add_test(NAME tests COMMAND tests)
target_link_libraries(tests PRIVATE ${PROJECT_NAME} GTest::gtest_main)
add_custom_command(
TARGET tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/example.ini
${CMAKE_CURRENT_SOURCE_DIR}/tests.ini
${CMAKE_CURRENT_BINARY_DIR})

View File

@@ -1,21 +0,0 @@
CXX?=g++
CXXFLAGS+=-Wall -std=c++14 `pkg-config --cflags gtest_main`
LDFLAGS+=`pkg-config --libs gtest_main`
OBJS=ts-roundtrip.o ts-snippets.o ts-utf8.o ts-bugfix.o ts-quotes.o ts-noconvert.o
BIN=./tests
all: $(BIN)
$(BIN): $(OBJS)
$(CXX) -o $(BIN) $(OBJS) $(LDFLAGS)
clean:
rm -f core $(OBJS) $(BIN)
test: $(BIN)
$(BIN)
$(OBJS): ../SimpleIni.h

View File

@@ -1,2 +0,0 @@
[section]
key = value

View File

@@ -1,24 +0,0 @@
@echo off
Debug\testsi.exe -u -m -l test1-input.ini > test1-blah.ini
fc test1-expected.ini test1-output.ini
if errorlevel 1 goto error
"Debug Unicode\testsi.exe" -u -m -l test1-input.ini > test1-blah.ini
fc test1-expected.ini test1-output.ini
if errorlevel 1 goto error
Release\testsi.exe -u -m -l test1-input.ini > test1-blah.ini
fc test1-expected.ini test1-output.ini
if errorlevel 1 goto error
"Release Unicode\testsi.exe" -u -m -l test1-input.ini > test1-blah.ini
fc test1-expected.ini test1-output.ini
if errorlevel 1 goto error
exit /b 0
:error
echo Failed during test run. Output file doesn't match expected file.
pause
exit /b 1

View File

@@ -1,85 +0,0 @@
; testsi-UTF8-std.ini : standard UTF-8 test file for SimpleIni automated testing
;
; The number after a section or key is the order that it is defined in this file
; to make it easier to see if it has been written out correctly. This file should
; be loaded with Unicode / MultiKey / MultiLine turned on.
; This comment should be joined on to the one below it about the key
; with no section.
; Key with no section
lonely-key = nosection
another = nosection either
; This key has no value
empty =
; This should be joined with the comment below about japanese.
; Another line which will be un-indented.
; This is a section of keys showing the word Japanese in different syllabies.
[ordered-1]
a-1 = blah
; this is in kanji
japanese-2 = 日本語
; this is in hiragana
japanese-3 = にほんご
; this is in katakana
japanese-4 = ニホンゴ
; this is in romaji
japanese-5 = nihongo
; kanji as the key
日本語-6 = japanese
[multi-2]
; value a
test = a
; value b
test = b
; value c
test = c
; value d
test = d
[multiline-3]
; This is obviously a multi-line entry
multiline-1 = <<<END_OF_TEXT
This is a multi-line comment. It
will continue until we have the word MULTI
on a line by itself.
日本語も。
END_OF_TEXT
; This looks like multi-line, but because the newline following the last
; line is discarded, it will be converted into a single line entry.
another-2 = This is not a multiline entry.
; If you wanted a multiline entry with a single line, you need to add
; an extra line to it.
another-3 = <<<END_OF_TEXT
This is a multiline entry.
END_OF_TEXT
[integer]
dec = 42
hex = 0x2a

View File

@@ -1,76 +0,0 @@
; testsi-UTF8-std.ini : standard UTF-8 test file for SimpleIni automated testing
;
; The number after a section or key is the order that it is defined in this file
; to make it easier to see if it has been written out correctly. This file should
; be loaded with Unicode / MultiKey / MultiLine turned on.
; This comment should be joined on to the one below it about the key
; with no section.
; Key with no section
lonely-key = nosection
another = nosection either
; This key has no value
empty =
; This should be joined with the comment below about japanese.
; Another line which will be un-indented.
; This is a section of keys showing the word Japanese in different syllabies.
[ordered-1]
a-1 = blah
; this is in kanji
japanese-2 = 日本語
; this is in hiragana
japanese-3 = にほんご
; this is in katakana
japanese-4 = ニホンゴ
; this is in romaji
japanese-5 = nihongo
; kanji as the key
日本語-6 = japanese
[multi-2]
; value a
test = a
; value b
test = b
; value c
test = c
; value d
test = d
[multiline-3]
; This is obviously a multi-line entry
multiline-1 = <<<MULTI
This is a multi-line comment. It
will continue until we have the word MULTI
on a line by itself.
日本語も。
MULTI
; This looks like multi-line, but because the newline following the last
; line is discarded, it will be converted into a single line entry.
another-2 = <<<MULTI
This is not a multiline entry.
MULTI
; If you wanted a multiline entry with a single line, you need to add
; an extra line to it.
another-3 = <<<MULTI
This is a multiline entry.
MULTI
[integer]
dec = 42
hex = 0x2a

View File

@@ -1,166 +0,0 @@
// File: test1.cpp
// Library: SimpleIni
// Author: Brodie Thiesfield <code@jellycan.com>
// Source: http://code.jellycan.com/simpleini/
//
// Automated testing for SimpleIni streams
#ifdef _WIN32
# pragma warning(disable: 4786)
#endif
#ifdef _WIN32
# include <windows.h>
# define DELETE_FILE DeleteFileA
#else
# include <unistd.h>
# define DELETE_FILE unlink
#endif
#include <fstream>
#define SI_SUPPORT_IOSTREAMS
#include "SimpleIni.h"
class Test
{
std::string m_strTest;
public:
Test(const char * a_pszName)
: m_strTest(a_pszName)
{
printf("%s: test starting\n", m_strTest.c_str());
}
bool Success()
{
printf("%s: test succeeded\n", m_strTest.c_str());
return false;
}
bool Failure(const char * pszReason)
{
printf("%s: test FAILED (%s)\n", m_strTest.c_str(), pszReason);
return false;
}
};
bool FileComparisonTest(const char * a_pszFile1, const char * a_pszFile2) {
// ensure that the two files are the same
try {
std::string strFile1, strFile2;
char szBuf[1024];
FILE * fp = NULL;
#if __STDC_WANT_SECURE_LIB__
fopen_s(&fp, a_pszFile1, "rb");
#else
fp = fopen(a_pszFile1, "rb");
#endif
if (!fp) throw false;
while (!feof(fp)) {
size_t n = fread(szBuf, 1, sizeof(szBuf), fp);
strFile1.append(szBuf, n);
}
fclose(fp);
fp = NULL;
#if __STDC_WANT_SECURE_LIB__
fopen_s(&fp, a_pszFile2, "rb");
#else
fp = fopen(a_pszFile2, "rb");
#endif
if (!fp) throw false;
while (!feof(fp)) {
size_t n = fread(szBuf, 1, sizeof(szBuf), fp);
strFile2.append(szBuf, n);
}
fclose(fp);
if (strFile1 != strFile2) throw false;
}
catch (...) {
return false;
}
return true;
}
bool FileLoadTest(const char * a_pszFile1, const char * a_pszFile2) {
// ensure that the two files load into simpleini the same
CSimpleIniA ini(true, true, true);
bool b;
try {
ini.Reset();
if (ini.LoadFile(a_pszFile1) < 0) throw "Load failed for file 1";
if (ini.SaveFile("test1.ini") < 0) throw "Save failed for file 1";
ini.Reset();
if (ini.LoadFile(a_pszFile2) < 0) throw "Load failed for file 2";
if (ini.SaveFile("test2.ini") < 0) throw "Save failed for file 2";
b = FileComparisonTest("test1.ini", "test2.ini");
DELETE_FILE("test1.ini");
DELETE_FILE("test2.ini");
if (!b) throw "File comparison failed in FileLoadTest";
}
catch (...) {
return false;
}
return true;
}
bool TestStreams()
{
const char * rgszTestFile[3] = {
"test1-input.ini",
"test1-output.ini",
"test1-expected.ini"
};
Test oTest("TestStreams");
CSimpleIniW ini;
ini.SetUnicode(true);
ini.SetMultiKey(true);
ini.SetMultiLine(true);
// load the file
try {
std::ifstream instream;
instream.open(rgszTestFile[0], std::ifstream::in | std::ifstream::binary);
if (ini.LoadData(instream) < 0) throw false;
instream.close();
}
catch (...) {
return oTest.Failure("Failed to load file");
}
// standard contents test
//if (!StandardContentsTest(ini, oTest)) {
// return false;
//}
// save the file
try {
std::ofstream outfile;
outfile.open(rgszTestFile[1], std::ofstream::out | std::ofstream::binary);
if (ini.Save(outfile, true) < 0) throw false;
outfile.close();
}
catch (...) {
return oTest.Failure("Failed to save file");
}
// file comparison test
if (!FileComparisonTest(rgszTestFile[1], rgszTestFile[2])) {
return oTest.Failure("Failed file comparison");
}
if (!FileLoadTest(rgszTestFile[1], rgszTestFile[2])) {
return oTest.Failure("Failed file load comparison");
}
return oTest.Success();
}

View File

@@ -1,52 +0,0 @@
; test file for SimpleIni
nosection=ok
NOSECTION=still ok
whitespace = ok
[standard]
foo=foo1
standard-1=foo
<EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>=ok1
[Standard]
Foo=foo2
standard-2=foo
<EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>=ok2
[ Whitespace ]
a=
[ whitespace in section name ]
whitespace in key name = whitespace in value name
; comments
; more comments
invalid
=invalid
====invalid
[Japanese]
nihongo = <EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD> = <EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>
[<5B><><EFBFBD>ܸ<EFBFBD>]
nihongo = <EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD> = <EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD>
[]
more=no section name
[MultiLine]
single = This is a single line.
multi = <<<MULTI
This is a multi-line value. It continues until the MULTI tag is found
on a line by itself with no whitespace before or after it. This value
will be returned to the user with all newlines and whitespace.
MULTI

View File

@@ -1,51 +0,0 @@
; test file for SimpleIni
nosection=ok
NOSECTION=still ok
whitespace = ok
[standard]
foo=foo1
standard-1=foo
<EFBFBD><EFBFBD><EFBFBD>{<7B><>=ok1
[Standard]
Foo=foo2
standard-2=foo
<EFBFBD><EFBFBD><EFBFBD>{<7B><>=ok2
[ Whitespace ]
a=
[ whitespace in section name ]
whitespace in key name = whitespace in value name
; comments
; more comments
invalid
=invalid
====invalid
[Japanese]
nihongo = <EFBFBD><EFBFBD><EFBFBD>{<7B><>
<EFBFBD><EFBFBD><EFBFBD>{<7B><> = <EFBFBD><EFBFBD><EFBFBD>{<7B><>
[<5B><><EFBFBD>{<7B><>]
nihongo = <EFBFBD><EFBFBD><EFBFBD>{<7B><>
<EFBFBD><EFBFBD><EFBFBD>{<7B><> = <EFBFBD><EFBFBD><EFBFBD>{<7B><>
[]
more=no section name
[MultiLine]
single = This is a single line.
multi = <<<MULTI
This is a multi-line value. It continues until the MULTI tag is found
on a line by itself with no whitespace before or after it. This value
will be returned to the user with all newlines and whitespace.
MULTI

View File

@@ -1,50 +0,0 @@
; test file for SimpleIni
whitespace = ok
nosection=ok
NOSECTION=still ok
[standard]
foo=foo1
standard-1=foo
日本語=ok1
[Standard]
Foo=foo2
standard-2=foo
日本語=ok2
[ Whitespace ]
a=
[ whitespace in section name ]
whitespace in key name = whitespace in value name
; comments
; more comments
invalid
=invalid
====invalid
[Japanese]
nihongo = 日本語
日本語 = 日本語
[日本語]
nihongo = 日本語
日本語 = 日本語
[]
more=no section name
[MultiLine]
single = This is a single line.
multi = <<<MULTI
This is a multi-line value. It continues until the MULTI tag is found
on a line by itself with no whitespace before or after it. This value
will be returned to the user with all newlines and whitespace.
MULTI

View File

@@ -1,315 +0,0 @@
// File: testsi.cpp
// Library: SimpleIni
// Author: Brodie Thiesfield <code@jellycan.com>
// Source: http://code.jellycan.com/simpleini/
//
// Demo of usage
#ifdef _WIN32
# pragma warning(disable: 4786)
#endif
#include <locale.h>
#include <stdio.h>
#include <cassert>
#define SI_SUPPORT_IOSTREAMS
#if defined(SI_SUPPORT_IOSTREAMS) && !defined(_UNICODE)
# include <fstream>
#endif
//#define SI_CONVERT_GENERIC
//#define SI_CONVERT_ICU
//#define SI_CONVERT_WIN32
#include "../SimpleIni.h"
#ifdef SI_CONVERT_ICU
// if converting using ICU then we need the ICU library
# pragma comment(lib, "icuuc.lib")
#endif
#ifdef _WIN32
# include <tchar.h>
#else // !_WIN32
# define TCHAR char
# define _T(x) x
# define _tprintf printf
# define _tmain main
#endif // _WIN32
static void
Test(
CSimpleIni & ini
)
{
const TCHAR *pszSection = 0;
const TCHAR *pItem = 0;
const TCHAR *pszVal = 0;
// get the value of the key "foo" in section "standard"
bool bHasMulti;
pszVal = ini.GetValue(_T("standard"), _T("foo"), 0, &bHasMulti);
_tprintf(_T("\n-- Value of standard::foo is '%s' (hasMulti = %d)\n"),
pszVal ? pszVal : _T("(null)"), bHasMulti);
// set the value of the key "foo" in section "standard"
ini.SetValue(_T("standard"), _T("foo"), _T("wibble"));
pszVal = ini.GetValue(_T("standard"), _T("foo"), 0, &bHasMulti);
_tprintf(_T("\n-- Value of standard::foo is '%s' (hasMulti = %d)\n"),
pszVal ? pszVal : _T("(null)"), bHasMulti);
// get all values of the key "foo" in section "standard"
CSimpleIni::TNamesDepend values;
if (ini.GetAllValues(_T("standard"), _T("foo"), values)) {
_tprintf(_T("\n-- Values of standard::foo are:\n"));
CSimpleIni::TNamesDepend::const_iterator i = values.begin();
for (; i != values.end(); ++i) {
pszVal = i->pItem;
_tprintf(_T(" -> '%s'\n"), pszVal);
}
}
// get the size of the section [standard]
_tprintf(_T("\n-- Number of keys in section [standard] = %d\n"),
ini.GetSectionSize(_T("standard")));
// delete the key "foo" in section "standard", if it has value "bar"
ini.DeleteValue(_T("standard"), _T("foo"), _T("bar"));
pszVal = ini.GetValue(_T("standard"), _T("foo"), 0);
_tprintf(_T("\n-- Value of standard::foo is now '%s'\n"),
pszVal ? pszVal : _T("(null)"));
// delete the key "foo" in section "standard"
ini.Delete(_T("standard"), _T("foo"));
pszVal = ini.GetValue(_T("standard"), _T("foo"), 0);
_tprintf(_T("\n-- Value of standard::foo is now '%s'\n"),
pszVal ? pszVal : _T("(null)"));
// get the size of the section [standard]
_tprintf(_T("\n-- Number of keys in section [standard] = %d\n"),
ini.GetSectionSize(_T("standard")));
// get the list of all key names for the section "standard"
_tprintf(_T("\n-- Dumping keys of section: [standard]\n"));
CSimpleIni::TNamesDepend keys;
ini.GetAllKeys(_T("standard"), keys);
// dump all of the key names
CSimpleIni::TNamesDepend::const_iterator iKey = keys.begin();
for ( ; iKey != keys.end(); ++iKey ) {
pItem = iKey->pItem;
_tprintf(_T("Key: %s\n"), pItem);
}
// add a decimal value
ini.SetLongValue(_T("integer"), _T("dec"), 42, NULL, false);
ini.SetLongValue(_T("integer"), _T("hex"), 42, NULL, true);
// add some bool values
ini.SetBoolValue(_T("bool"), _T("t"), true);
ini.SetBoolValue(_T("bool"), _T("f"), false);
// get the values back
assert(42 == ini.GetLongValue(_T("integer"), _T("dec")));
assert(42 == ini.GetLongValue(_T("integer"), _T("hex")));
assert(true == ini.GetBoolValue(_T("bool"), _T("t")));
assert(false == ini.GetBoolValue(_T("bool"), _T("f")));
// delete the section "standard"
ini.Delete(_T("standard"), NULL);
_tprintf(_T("\n-- Number of keys in section [standard] = %d\n"),
ini.GetSectionSize(_T("standard")));
// iterate through every section in the file
_tprintf(_T("\n-- Dumping all sections\n"));
CSimpleIni::TNamesDepend sections;
ini.GetAllSections(sections);
CSimpleIni::TNamesDepend::const_iterator iSection = sections.begin();
for ( ; iSection != sections.end(); ++iSection ) {
pszSection = iSection->pItem;
// print the section name
printf("\n");
if (*pszSection) {
_tprintf(_T("[%s]\n"), pszSection);
}
// if there are keys and values...
const CSimpleIni::TKeyVal * pSectionData = ini.GetSection(pszSection);
if (pSectionData) {
// iterate over all keys and dump the key name and value
CSimpleIni::TKeyVal::const_iterator iKeyVal = pSectionData->begin();
for ( ;iKeyVal != pSectionData->end(); ++iKeyVal) {
pItem = iKeyVal->first.pItem;
pszVal = iKeyVal->second;
_tprintf(_T("%s=%s\n"), pItem, pszVal);
}
}
}
}
#if defined(SI_SUPPORT_IOSTREAMS) && !defined(_UNICODE)
static bool
TestStreams(
const TCHAR * a_pszFile,
bool a_bIsUtf8,
bool a_bUseMultiKey,
bool a_bUseMultiLine
)
{
// load the file
CSimpleIni ini(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine);
_tprintf(_T("Loading file: %s\n"), a_pszFile);
std::ifstream instream;
instream.open(a_pszFile, std::ifstream::in | std::ifstream::binary);
SI_Error rc = ini.LoadData(instream);
instream.close();
if (rc < 0) {
printf("Failed to open file.\n");
return false;
}
Test(ini);
// save the file (simple)
_tprintf(_T("\n-- Saving file to: testsi-out-streams.ini\n"));
std::ofstream outstream;
outstream.open("testsi-out-streams.ini", std::ofstream::out | std::ofstream::binary);
ini.Save(outstream);
outstream.close();
return true;
}
#endif // SI_SUPPORT_IOSTREAMS
static bool
TestFile(
const TCHAR * a_pszFile,
bool a_bIsUtf8,
bool a_bUseMultiKey,
bool a_bUseMultiLine
)
{
// load the file
CSimpleIni ini(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine);
_tprintf(_T("Loading file: %s\n"), a_pszFile);
SI_Error rc = ini.LoadFile(a_pszFile);
if (rc < 0) {
printf("Failed to open file.\n");
return false;
}
// run the tests
Test(ini);
// save the file (simple)
_tprintf(_T("\n-- Saving file to: testsi-out.ini\n"));
ini.SaveFile("testsi-out.ini");
// save the file (with comments)
// Note: to save the file and add a comment to the beginning, use
// code such as the following.
_tprintf(_T("\n-- Saving file to: testsi-out-comment.ini\n"));
FILE * fp = NULL;
#if __STDC_WANT_SECURE_LIB__
fopen_s(&fp, "testsi-out-comment.ini", "wb");
#else
fp = fopen("testsi-out-comment.ini", "wb");
#endif
if (fp) {
CSimpleIni::FileWriter writer(fp);
if (a_bIsUtf8) {
writer.Write(SI_UTF8_SIGNATURE);
}
// add a string to the file in the correct text format
CSimpleIni::Converter convert = ini.GetConverter();
convert.ConvertToStore(_T("; output from testsi.cpp test program")
SI_NEWLINE SI_NEWLINE);
writer.Write(convert.Data());
ini.Save(writer, false);
fclose(fp);
}
return true;
}
static bool
ParseCommandLine(
int argc,
TCHAR * argv[],
const TCHAR * & a_pszFile,
bool & a_bIsUtf8,
bool & a_bUseMultiKey,
bool & a_bUseMultiLine
)
{
a_pszFile = 0;
a_bIsUtf8 = false;
a_bUseMultiKey = false;
a_bUseMultiLine = false;
for (--argc; argc > 0; --argc) {
if (argv[argc][0] == '-') {
switch (argv[argc][1]) {
case TCHAR('u'):
a_bIsUtf8 = true;
break;
case TCHAR('m'):
a_bUseMultiKey = true;
break;
case TCHAR('l'):
a_bUseMultiLine = true;
break;
}
}
else {
a_pszFile = argv[argc];
}
}
if (!a_pszFile) {
_tprintf(
_T("Usage: testsi [-u] [-m] [-l] iniFile\n")
_T(" -u Load file as UTF-8 (Default is to use system locale)\n")
_T(" -m Enable multiple keys\n")
_T(" -l Enable multiple line values\n")
);
return false;
}
return true;
}
extern bool TestStreams();
int
_tmain(
int argc,
TCHAR * argv[]
)
{
setlocale(LC_ALL, "");
// start of automated testing...
TestStreams();
// parse the command line
const TCHAR * pszFile;
bool bIsUtf8, bUseMultiKey, bUseMultiLine;
if (!ParseCommandLine(argc, argv, pszFile, bIsUtf8, bUseMultiKey, bUseMultiLine)) {
return 1;
}
// run the test
if (!TestFile(pszFile, bIsUtf8, bUseMultiKey, bUseMultiLine)) {
return 1;
}
#if defined(SI_SUPPORT_IOSTREAMS) && !defined(_UNICODE)
if (!TestStreams(pszFile, bIsUtf8, bUseMultiKey, bUseMultiLine)) {
return 1;
}
#endif
return 0;
}

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.1.7" targetFramework="native" />
</packages>

View File

@@ -1,6 +0,0 @@
//
// pch.cpp
// Include the standard header and generate the precompiled header.
//
#include "pch.h"

View File

@@ -1,8 +0,0 @@
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include "gtest/gtest.h"

View File

@@ -1,13 +0,0 @@
[section1]
key1=value1
[section2]
test2=テスト2
テスト=test
テスト2=テスト二
[検査]
key2=value2
test2=テスト2
テスト=test
テスト2=テスト二

View File

@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8f30a5dc-b942-4c9a-ba75-91c906ff85fa}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<ProjectName>tests</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ts-bugfix.cpp" />
<ClCompile Include="ts-noconvert.cpp" />
<ClCompile Include="ts-quotes.cpp" />
<ClCompile Include="ts-roundtrip.cpp" />
<ClCompile Include="ts-snippets.cpp" />
<ClCompile Include="ts-utf8.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ts-wchar.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="example.ini" />
<None Include="Makefile" />
<None Include="packages.config" />
<None Include="tests.ini" />
</ItemGroup>
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\vcproj\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.7\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets" Condition="Exists('..\vcproj\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.7\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" />
</ImportGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\vcproj\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.7\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\vcproj\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.7\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'))" />
</Target>
</Project>

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="ts-bugfix.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-noconvert.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-quotes.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-roundtrip.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-snippets.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-utf8.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="ts-wchar.cpp">
<Filter>Test Cases</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Other Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="example.ini">
<Filter>Other Files</Filter>
</None>
<None Include="tests.ini">
<Filter>Test Cases</Filter>
</None>
<None Include="Makefile">
<Filter>Other Files</Filter>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Filter Include="Test Cases">
<UniqueIdentifier>{8b76c482-decd-405d-abd8-98726f5c0b03}</UniqueIdentifier>
<Extensions>ts-*.cpp</Extensions>
</Filter>
<Filter Include="Other Files">
<UniqueIdentifier>{8f23fd84-666d-4e92-83de-ed431f244af0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Other Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -1,137 +0,0 @@
#include "pch.h"
#include "../SimpleIni.h"
TEST(TestBugFix, TestEmptySection) {
CSimpleIniA ini;
ini.SetValue("foo", "skey", "sval");
ini.SetValue("", "rkey", "rval");
ini.SetValue("bar", "skey", "sval");
std::string output;
ini.Save(output);
std::string expected =
"rkey = rval\n"
"\n"
"\n"
"[foo]\n"
"skey = sval\n"
"\n"
"\n"
"[bar]\n"
"skey = sval\n";
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expected.c_str(), output.c_str());
}
TEST(TestBugFix, TestMultiLineIgnoreTrailSpace0) {
std::string input =
"; multiline values\n"
"key = <<<EOS\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"EOS\n"
"\n"
"[section]\n";
bool multiline = true;
CSimpleIniA ini(true, false, multiline);
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
std::string output;
ini.Save(output);
std::string expected =
"; multiline values\n"
"\n"
"\n"
"key = <<<END_OF_TEXT\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"END_OF_TEXT\n"
"\n"
"\n"
"[section]\n";
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expected.c_str(), output.c_str());
}
TEST(TestBugFix, TestMultiLineIgnoreTrailSpace1) {
std::string input =
"; multiline values\n"
"key = <<<EOS\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"EOS \n"
"\n"
"[section]\n";
bool multiline = true;
CSimpleIniA ini(true, false, multiline);
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
std::string output;
ini.Save(output);
std::string expected =
"; multiline values\n"
"\n"
"\n"
"key = <<<END_OF_TEXT\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"END_OF_TEXT\n"
"\n"
"\n"
"[section]\n";
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expected.c_str(), output.c_str());
}
TEST(TestBugFix, TestMultiLineIgnoreTrailSpace2) {
std::string input =
"; multiline values\n"
"key = <<<EOS\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"EOS \n"
"\n"
"[section]\n";
bool multiline = true;
CSimpleIniA ini(true, false, multiline);
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
std::string output;
ini.Save(output);
std::string expected =
"; multiline values\n"
"\n"
"\n"
"key = <<<END_OF_TEXT\n"
"This is a\n"
"multiline value\n"
"and it ends.\n"
"END_OF_TEXT\n"
"\n"
"\n"
"[section]\n";
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expected.c_str(), output.c_str());
}

View File

@@ -1,69 +0,0 @@
#include "pch.h"
#define SI_NO_CONVERSION
#include "../SimpleIni.h"
class TestNoConvert : public ::testing::Test {
protected:
void SetUp() override;
protected:
CSimpleIniA ini;
};
void TestNoConvert::SetUp() {
ini.SetUnicode();
SI_Error err = ini.LoadFile("tests.ini");
ASSERT_EQ(err, SI_OK);
}
TEST_F(TestNoConvert, TestSectionAKeyAValA) {
const char* result = ini.GetValue("section1", "key1");
ASSERT_STREQ(result, "value1");
}
TEST_F(TestNoConvert, TestSectionAKeyAValU) {
const char tesuto2[] = u8"テスト2";
const char* result = ini.GetValue("section2", "test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestNoConvert, TestSectionAKeyUValA) {
const char tesuto[] = u8"テスト";
const char* result = ini.GetValue("section2", tesuto);
ASSERT_STREQ(result, "test");
}
TEST_F(TestNoConvert, TestSectionAKeyUValU) {
const char tesuto2[] = u8"テスト2";
const char tesutoni[] = u8"テスト二";
const char* result = ini.GetValue("section2", tesuto2);
ASSERT_STREQ(result, tesutoni);
}
TEST_F(TestNoConvert, TestSectionUKeyAValA) {
const char kensa[] = u8"検査";
const char* result = ini.GetValue(kensa, "key2");
ASSERT_STREQ(result, "value2");
}
TEST_F(TestNoConvert, TestSectionUKeyAValU) {
const char kensa[] = u8"検査";
const char tesuto2[] = u8"テスト2";
const char* result = ini.GetValue(kensa, "test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestNoConvert, TestSectionUKeyUValA) {
const char kensa[] = u8"検査";
const char tesuto[] = u8"テスト";
const char* result = ini.GetValue(kensa, tesuto);
ASSERT_STREQ(result, "test");
}
TEST_F(TestNoConvert, TestSectionUKeyUValU) {
const char kensa[] = u8"検査";
const char tesuto2[] = u8"テスト2";
const char tesutoni[] = u8"テスト二";
const char* result = ini.GetValue(kensa, tesuto2);
ASSERT_STREQ(result, tesutoni);
}

View File

@@ -1,202 +0,0 @@
#include "pch.h"
#include <algorithm>
#include "../SimpleIni.h"
class TestQuotes : public ::testing::Test {
protected:
void SetUp() override;
protected:
CSimpleIniA ini;
std::string input;
std::string expect;
std::string output;
};
void TestQuotes::SetUp() {
ini.SetUnicode();
}
TEST_F(TestQuotes, TestEmpty) {
ini.SetQuotes(true);
input =
"[section]\n"
"key1 = \"\"\n"
"key2 = \n"
;
// no need to preserve quotes for empty data
expect =
"[section]\n"
"key1 = \n"
"key2 = \n"
;
const char* result;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
result = ini.GetValue("section", "key1");
ASSERT_STREQ(result, "");
result = ini.GetValue("section", "key2");
ASSERT_STREQ(result, "");
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expect.c_str(), output.c_str());
}
TEST_F(TestQuotes, TestEmptyDisabled) {
ini.SetQuotes(false);
input =
"[section]\n"
"key1 = \"\"\n"
"key2 = \n"
;
const char* result;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
result = ini.GetValue("section", "key1");
ASSERT_STREQ(result, "\"\"");
result = ini.GetValue("section", "key2");
ASSERT_STREQ(result, "");
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(input.c_str(), output.c_str());
}
TEST_F(TestQuotes, TestGeneral) {
ini.SetQuotes(true);
input =
"[section]\n"
"key1 = foo\n"
"key2 = \"foo\"\n"
"key3 = foo \n"
"key4 = \" foo \"\n"
"key5 = \"foo\n"
"key6 = foo\"\n"
"key7 = foo \" foo \n"
"key8 = \" foo \" foo \" \n"
;
expect =
"[section]\n"
"key1 = foo\n"
"key2 = foo\n"
"key3 = foo\n"
"key4 = \" foo \"\n"
"key5 = \"foo\n"
"key6 = foo\"\n"
"key7 = foo \" foo\n"
"key8 = \" foo \" foo \"\n"
;
const char* result;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
result = ini.GetValue("section", "key1");
ASSERT_STREQ(result, "foo");
result = ini.GetValue("section", "key2");
ASSERT_STREQ(result, "foo");
result = ini.GetValue("section", "key3");
ASSERT_STREQ(result, "foo");
result = ini.GetValue("section", "key4");
ASSERT_STREQ(result, " foo ");
result = ini.GetValue("section", "key5");
ASSERT_STREQ(result, "\"foo");
result = ini.GetValue("section", "key6");
ASSERT_STREQ(result, "foo\"");
result = ini.GetValue("section", "key7");
ASSERT_STREQ(result, "foo \" foo");
result = ini.GetValue("section", "key8");
ASSERT_STREQ(result, " foo \" foo ");
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expect.c_str(), output.c_str());
}
TEST_F(TestQuotes, TestGeneralDisabled) {
ini.SetQuotes(false);
input =
"[section]\n"
"key1 = foo\n"
"key2 = \"foo\"\n"
"key3 = foo \n"
"key4 = \" foo \"\n"
"key5 = \"foo\n"
"key6 = foo\"\n"
"key7 = foo \" foo \n"
"key8 = \" foo \" foo \" \n"
;
expect =
"[section]\n"
"key1 = foo\n"
"key2 = \"foo\"\n"
"key3 = foo\n"
"key4 = \" foo \"\n"
"key5 = \"foo\n"
"key6 = foo\"\n"
"key7 = foo \" foo\n"
"key8 = \" foo \" foo \"\n"
;
const char* result;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
result = ini.GetValue("section", "key1");
ASSERT_STREQ(result, "foo");
result = ini.GetValue("section", "key2");
ASSERT_STREQ(result, "\"foo\"");
result = ini.GetValue("section", "key3");
ASSERT_STREQ(result, "foo");
result = ini.GetValue("section", "key4");
ASSERT_STREQ(result, "\" foo \"");
result = ini.GetValue("section", "key5");
ASSERT_STREQ(result, "\"foo");
result = ini.GetValue("section", "key6");
ASSERT_STREQ(result, "foo\"");
result = ini.GetValue("section", "key7");
ASSERT_STREQ(result, "foo \" foo");
result = ini.GetValue("section", "key8");
ASSERT_STREQ(result, "\" foo \" foo \"");
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expect.c_str(), output.c_str());
}

View File

@@ -1,246 +0,0 @@
#include "pch.h"
#include <algorithm>
#include "../SimpleIni.h"
class TestRoundTrip : public ::testing::Test {
protected:
void SetUp() override;
void TestMulti();
void TestBOM(bool useBOM);
protected:
CSimpleIniA ini;
std::string input;
std::string output;
};
void TestRoundTrip::SetUp() {
ini.SetUnicode();
}
TEST_F(TestRoundTrip, TestStandard) {
input =
"; File comment\n"
"\n"
"\n"
"; Section 1 comment\n"
"[section1]\n"
"\n"
"\n"
"; Section 2 comment\n"
"[section2]\n"
"\n"
"; key1 comment\n"
"key1 = string\n"
"\n"
"; key 2 comment\n"
"key2 = true\n"
"key3 = 3.1415\n"
;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
const char* result = ini.GetValue("section2", "key1");
ASSERT_STREQ(result, "string");
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(input.c_str(), output.c_str());
}
void TestRoundTrip::TestMulti() {
input =
"[section]\n"
"key = string1\n"
"key = string2\n"
;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
}
TEST_F(TestRoundTrip, TestMultiGood) {
ini.SetMultiKey(true);
TestMulti();
ASSERT_STREQ(input.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestMultiBad) {
std::string expected =
"[section]\n"
"key = string2\n";
ini.SetMultiKey(false);
TestMulti();
ASSERT_STRNE(input.c_str(), output.c_str());
ASSERT_STREQ(expected.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestSpacesTrue) {
input =
"[section]\n"
"key = string1\n";
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
ini.SetSpaces(true);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(input.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestSpacesFalse) {
input =
"[section]\n"
"key = string1\n";
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
ini.SetSpaces(false);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STRNE(input.c_str(), output.c_str());
std::string expected =
"[section]\n"
"key=string1\n";
ASSERT_STREQ(expected.c_str(), output.c_str());
}
void TestRoundTrip::TestBOM(bool useBOM) {
const char bom[] = "\xEF\xBB\xBF";
const char input8[] =
u8"[テスト1]\n"
u8"テスト2 = テスト3\n";
input = bom;
input += input8;
ini.Reset();
ini.SetUnicode(false);
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
const char tesuto1[] = u8"テスト1";
const char tesuto2[] = u8"テスト2";
const char tesuto3[] = u8"テスト3";
const char* result = ini.GetValue(tesuto1, tesuto2);
ASSERT_STREQ(result, tesuto3);
rc = ini.Save(output, useBOM);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
}
TEST_F(TestRoundTrip, TestWithBOM) {
TestBOM(true);
ASSERT_STREQ(input.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestWithoutBOM) {
TestBOM(false);
ASSERT_STRNE(input.c_str(), output.c_str());
std::string expected(input, 3);
ASSERT_STREQ(expected.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestAllowKeyOnly1) {
ini.SetAllowKeyOnly(false);
input =
"[section1]\n"
"key1 = string\n"
"key2 = \n"
"key3= \n"
"key4=\n"
"key5\n"
"\n"
"Never going to give you up\n"
"Never going to let you down\n"
;
std::string expect =
"[section1]\n"
"key1 = string\n"
"key2 = \n"
"key3 = \n"
"key4 = \n"
;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expect.c_str(), output.c_str());
}
TEST_F(TestRoundTrip, TestAllowKeyOnly2) {
ini.SetAllowKeyOnly(true);
input =
"[section1]\n"
"key1\n"
"key2\n"
"[section2]\n"
"key1 = string\n"
"key2 = \n"
"key3= \n"
"key4=\n"
"\n"
"key5\n"
"\n"
"Never going to give you up\n"
"\n"
"Never going to let you down\n"
;
std::string expect =
"[section1]\n"
"key1\n"
"key2\n"
"\n\n"
"[section2]\n"
"key1 = string\n"
"key2\n"
"key3\n"
"key4\n"
"key5\n"
"Never going to give you up\n"
"Never going to let you down\n"
;
SI_Error rc = ini.LoadData(input);
ASSERT_EQ(rc, SI_OK);
rc = ini.Save(output);
ASSERT_EQ(rc, SI_OK);
output.erase(std::remove(output.begin(), output.end(), '\r'), output.end());
ASSERT_STREQ(expect.c_str(), output.c_str());
}

View File

@@ -1,303 +0,0 @@
#include "pch.h"
#include "../SimpleIni.h"
// ### SIMPLE USAGE
TEST(TestSnippets, TestSimple) {
// simple demonstration
CSimpleIniA ini;
ini.SetUnicode();
SI_Error rc = ini.LoadFile("example.ini");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
const char* pv;
pv = ini.GetValue("section", "key", "default");
ASSERT_STREQ(pv, "value");
ini.SetValue("section", "key", "newvalue");
pv = ini.GetValue("section", "key", "default");
ASSERT_STREQ(pv, "newvalue");
}
// ### LOADING DATA
TEST(TestSnippets, TestLoadFile) {
// load from a data file
CSimpleIniA ini;
SI_Error rc = ini.LoadFile("example.ini");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
}
TEST(TestSnippets, TestLoadString) {
// load from a string
const std::string example = "[section]\nkey = value\n";
CSimpleIniA ini;
SI_Error rc = ini.LoadData(example);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_OK);
}
// ### GETTING SECTIONS AND KEYS
TEST(TestSnippets, TestSectionsAndKeys) {
const std::string example =
"[section1]\n"
"key1 = value1\n"
"key2 = value2\n"
"\n"
"[section2]\n"
"[section3]\n";
CSimpleIniA ini;
SI_Error rc = ini.LoadData(example);
ASSERT_EQ(rc, SI_OK);
// get all sections
CSimpleIniA::TNamesDepend sections;
ini.GetAllSections(sections);
// get all keys in a section
CSimpleIniA::TNamesDepend keys;
ini.GetAllKeys("section1", keys);
const char* expectedSections[] = { "section1", "section2", "section3", nullptr };
const char* expectedKeys[] = { "key1", "key2", nullptr };
CSimpleIniA::TNamesDepend::const_iterator it;
int i;
for (i = 0, it = sections.begin(); it != sections.end(); ++i, ++it) {
ASSERT_NE(expectedSections[i], nullptr);
ASSERT_STREQ(expectedSections[i], it->pItem);
}
ASSERT_EQ(expectedSections[i], nullptr);
for (i = 0, it = keys.begin(); it != keys.end(); ++i, ++it) {
ASSERT_NE(expectedKeys[i], nullptr);
ASSERT_STREQ(expectedKeys[i], it->pItem);
}
ASSERT_EQ(expectedKeys[i], nullptr);
}
// ### GETTING VALUES
TEST(TestSnippets, TestGettingValues) {
const std::string example =
"[section1]\n"
"key1 = value1\n"
"key2 = value2.1\n"
"key2 = value2.2\n"
"\n"
"[section2]\n"
"[section3]\n";
bool utf8 = true;
bool multiKey = true;
CSimpleIniA ini(utf8, multiKey);
SI_Error rc = ini.LoadData(example);
ASSERT_EQ(rc, SI_OK);
// get the value of a key that doesn't exist
const char* pv;
pv = ini.GetValue("section1", "key99");
ASSERT_EQ(pv, nullptr);
// get the value of a key that does exist
pv = ini.GetValue("section1", "key1");
ASSERT_STREQ(pv, "value1");
// get the value of a key which may have multiple
// values. If hasMultiple is true, then there are
// multiple values and just one value has been returned
bool hasMulti;
pv = ini.GetValue("section1", "key1", nullptr, &hasMulti);
ASSERT_STREQ(pv, "value1");
ASSERT_EQ(hasMulti, false);
pv = ini.GetValue("section1", "key2", nullptr, &hasMulti);
ASSERT_STREQ(pv, "value2.1");
ASSERT_EQ(hasMulti, true);
// get all values of a key with multiple values
CSimpleIniA::TNamesDepend values;
ini.GetAllValues("section1", "key2", values);
// sort the values into a known order, in this case we want
// the original load order
values.sort(CSimpleIniA::Entry::LoadOrder());
// output all of the items
CSimpleIniA::TNamesDepend::const_iterator it;
for (it = values.begin(); it != values.end(); ++it) {
//printf("value = '%s'\n", it->pItem);
}
int i;
const char* expectedValues[] = { "value2.1", "value2.2", nullptr };
for (i = 0, it = values.begin(); it != values.end(); ++it, ++i) {
ASSERT_NE(expectedValues[i], nullptr);
ASSERT_STREQ(expectedValues[i], it->pItem);
}
ASSERT_EQ(expectedValues[i], nullptr);
}
// ### VALUE EXISTS
TEST(TestSnippets, TestExists)
{
const std::string example =
"[section1]\n"
"key1 = value1\n"
"key2 = value2.1\n"
"key2 = value2.2\n"
"\n"
"[section2]\n"
"key1\n"
"key2\n"
"[section3]\n";
CSimpleIniA ini;
ini.SetUnicode();
ini.SetMultiKey();
ini.SetAllowKeyOnly();
SI_Error rc = ini.LoadData(example);
ASSERT_EQ(rc, SI_OK);
// check for section doesn't exist
EXPECT_FALSE(ini.SectionExists(""));
EXPECT_FALSE(ini.SectionExists("section4"));
// check for section does exist
EXPECT_TRUE(ini.SectionExists("section1"));
EXPECT_TRUE(ini.SectionExists("section2"));
EXPECT_TRUE(ini.SectionExists("section3"));
// check for key doesn't exist
EXPECT_FALSE(ini.KeyExists("", "key"));
EXPECT_FALSE(ini.KeyExists("section1", "key"));
EXPECT_FALSE(ini.KeyExists("section2", "key"));
// check for key does exist
EXPECT_TRUE(ini.KeyExists("section1", "key1"));
EXPECT_TRUE(ini.KeyExists("section1", "key2"));
EXPECT_TRUE(ini.KeyExists("section2", "key1"));
EXPECT_TRUE(ini.KeyExists("section2", "key2"));
}
// ### MODIFYING DATA
TEST(TestSnippets, TestModifyingData) {
bool utf8 = true;
bool multiKey = false;
CSimpleIniA ini(utf8, multiKey);
SI_Error rc;
// add a new section
rc = ini.SetValue("section1", nullptr, nullptr);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_INSERTED);
// not an error to add one that already exists
rc = ini.SetValue("section1", nullptr, nullptr);
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_UPDATED);
// get the value of a key that doesn't exist
const char* pv;
pv = ini.GetValue("section2", "key1", "default-value");
ASSERT_STREQ(pv, "default-value");
// adding a key (the section will be added if needed)
rc = ini.SetValue("section2", "key1", "value1");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_INSERTED);
// ensure it is set to expected value
pv = ini.GetValue("section2", "key1", nullptr);
ASSERT_STREQ(pv, "value1");
// change the value of a key
rc = ini.SetValue("section2", "key1", "value2");
if (rc < 0) { /* handle error */ };
ASSERT_EQ(rc, SI_UPDATED);
// ensure it is set to expected value
pv = ini.GetValue("section2", "key1", nullptr);
ASSERT_STREQ(pv, "value2");
}
// ### DELETING DATA
TEST(TestSnippets, TestDeletingData) {
const std::string example =
"[section1]\n"
"key1 = value1\n"
"key2 = value2\n"
"\n"
"[section2]\n"
"key1 = value1\n"
"key2 = value2\n"
"\n"
"[section3]\n";
bool utf8 = true;
CSimpleIniA ini(utf8);
SI_Error rc = ini.LoadData(example);
ASSERT_EQ(rc, SI_OK);
// 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
TEST(TestSnippets, TestSavingData) {
bool utf8 = true;
CSimpleIniA ini(utf8);
SI_Error rc;
// 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);
}

View File

@@ -1,67 +0,0 @@
#include "pch.h"
#include "../SimpleIni.h"
class TestUTF8 : public ::testing::Test {
protected:
void SetUp() override;
protected:
CSimpleIniA ini;
};
void TestUTF8::SetUp() {
ini.SetUnicode();
SI_Error err = ini.LoadFile("tests.ini");
ASSERT_EQ(err, SI_OK);
}
TEST_F(TestUTF8, TestSectionAKeyAValA) {
const char* result = ini.GetValue("section1", "key1");
ASSERT_STREQ(result, "value1");
}
TEST_F(TestUTF8, TestSectionAKeyAValU) {
const char tesuto2[] = u8"テスト2";
const char* result = ini.GetValue("section2", "test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestUTF8, TestSectionAKeyUValA) {
const char tesuto[] = u8"テスト";
const char* result = ini.GetValue("section2", tesuto);
ASSERT_STREQ(result, "test");
}
TEST_F(TestUTF8, TestSectionAKeyUValU) {
const char tesuto2[] = u8"テスト2";
const char tesutoni[] = u8"テスト二";
const char* result = ini.GetValue("section2", tesuto2);
ASSERT_STREQ(result, tesutoni);
}
TEST_F(TestUTF8, TestSectionUKeyAValA) {
const char kensa[] = u8"検査";
const char* result = ini.GetValue(kensa, "key2");
ASSERT_STREQ(result, "value2");
}
TEST_F(TestUTF8, TestSectionUKeyAValU) {
const char kensa[] = u8"検査";
const char tesuto2[] = u8"テスト2";
const char* result = ini.GetValue(kensa, "test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestUTF8, TestSectionUKeyUValA) {
const char kensa[] = u8"検査";
const char tesuto[] = u8"テスト";
const char* result = ini.GetValue(kensa, tesuto);
ASSERT_STREQ(result, "test");
}
TEST_F(TestUTF8, TestSectionUKeyUValU) {
const char kensa[] = u8"検査";
const char tesuto2[] = u8"テスト2";
const char tesutoni[] = u8"テスト二";
const char* result = ini.GetValue(kensa, tesuto2);
ASSERT_STREQ(result, tesutoni);
}

View File

@@ -1,67 +0,0 @@
#include "pch.h"
#include "../SimpleIni.h"
class TestWide : public ::testing::Test {
protected:
void TestWide::SetUp() override;
protected:
CSimpleIniW ini;
};
void TestWide::SetUp() {
ini.SetUnicode();
SI_Error err = ini.LoadFile(L"tests.ini");
ASSERT_EQ(err, SI_OK);
}
TEST_F(TestWide, TestSectionAKeyAValA) {
const wchar_t* result = ini.GetValue(L"section1", L"key1");
ASSERT_STREQ(result, L"value1");
}
TEST_F(TestWide, TestSectionAKeyAValU) {
const wchar_t tesuto2[] = L"テスト2";
const wchar_t* result = ini.GetValue(L"section2", L"test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestWide, TestSectionAKeyUValA) {
const wchar_t tesuto[] = L"テスト";
const wchar_t* result = ini.GetValue(L"section2", tesuto);
ASSERT_STREQ(result, L"test");
}
TEST_F(TestWide, TestSectionAKeyUValU) {
const wchar_t tesuto2[] = L"テスト2";
const wchar_t tesutoni[] = L"テスト二";
const wchar_t* result = ini.GetValue(L"section2", tesuto2);
ASSERT_STREQ(result, tesutoni);
}
TEST_F(TestWide, TestSectionUKeyAValA) {
const wchar_t kensa[] = L"検査";
const wchar_t* result = ini.GetValue(kensa, L"key2");
ASSERT_STREQ(result, L"value2");
}
TEST_F(TestWide, TestSectionUKeyAValU) {
const wchar_t kensa[] = L"検査";
const wchar_t tesuto2[] = L"テスト2";
const wchar_t* result = ini.GetValue(kensa, L"test2");
ASSERT_STREQ(result, tesuto2);
}
TEST_F(TestWide, TestSectionUKeyUValA) {
const wchar_t kensa[] = L"検査";
const wchar_t tesuto[] = L"テスト";
const wchar_t* result = ini.GetValue(kensa, tesuto);
ASSERT_STREQ(result, L"test");
}
TEST_F(TestWide, TestSectionUKeyUValU) {
const wchar_t kensa[] = L"検査";
const wchar_t tesuto2[] = L"テスト2";
const wchar_t tesutoni[] = L"テスト二";
const wchar_t* result = ini.GetValue(kensa, tesuto2);
ASSERT_STREQ(result, tesutoni);
}

View File

@@ -1,46 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library Files", "Library Files", "{C1F8A145-78E7-42C6-95D5-23C746C2BC56}"
ProjectSection(SolutionItems) = preProject
..\ConvertUTF.c = ..\ConvertUTF.c
..\ConvertUTF.h = ..\ConvertUTF.h
..\ConvertUTF_readme.txt = ..\ConvertUTF_readme.txt
..\SimpleIni.h = ..\SimpleIni.h
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Information Files", "Information Files", "{E40DD170-6D17-49D2-9BB2-8546658F0A37}"
ProjectSection(SolutionItems) = preProject
..\LICENCE.txt = ..\LICENCE.txt
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Other Files", "Other Files", "{560B512C-6D1C-4E65-83C1-049110E5DEF6}"
ProjectSection(SolutionItems) = preProject
..\Makefile = ..\Makefile
..\other\package.cmd = ..\other\package.cmd
..\other\simpleini.doxy = ..\other\simpleini.doxy
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "..\tests\tests.vcxproj", "{8F30A5DC-B942-4C9A-BA75-91C906FF85FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Debug|x64.ActiveCfg = Debug|x64
{8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Debug|x64.Build.0 = Debug|x64
{8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x64.ActiveCfg = Release|x64
{8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ABD2CECE-EA8B-455B-8AE7-00E499634EC2}
EndGlobalSection
EndGlobal

View File

@@ -1,148 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{9a59fc4f-ad32-4bd3-b6b5-9bb0ddc6138d}</ProjectGuid>
<RootNamespace>SimpleIni</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\tests\snippets.cpp" />
<ClCompile Include="..\tests\testsi.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Tests">
<UniqueIdentifier>{353054bc-f2a3-46d2-a9cb-df767fe52289}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\tests\snippets.cpp">
<Filter>Tests</Filter>
</ClCompile>
<ClCompile Include="..\tests\testsi.cpp">
<Filter>Tests</Filter>
</ClCompile>
</ItemGroup>
</Project>