diff options
author | unknown <brofield@users.noreply.github.com> | 2020-06-16 17:18:26 +0300 |
---|---|---|
committer | unknown <brofield@users.noreply.github.com> | 2020-06-16 17:18:26 +0300 |
commit | 3fea945de7264e7a6ae058211203a7f2b1a42b9d (patch) | |
tree | 3dd6c47deab24b62e7446486756c56a928b322a8 | |
parent | fe082fa81f4a55ddceb55056622136be616b3c6f (diff) |
First stage of updating the project to have full test harness and incorporate some of the requested changes
-rw-r--r-- | .gitignore | 360 | ||||
-rw-r--r-- | README.md | 212 | ||||
-rw-r--r-- | SimpleIni.h | 5 | ||||
-rw-r--r-- | SimpleIni.sln | 29 | ||||
-rw-r--r-- | SimpleIni.vcproj | 291 | ||||
-rw-r--r-- | ini.syn | 36 | ||||
-rw-r--r-- | other/.travis.yml (renamed from .travis.yml) | 0 | ||||
-rw-r--r-- | other/Makefile (renamed from Makefile) | 0 | ||||
-rw-r--r-- | other/package.cmd (renamed from package.cmd) | 52 | ||||
-rw-r--r-- | other/simpleini.doxy (renamed from simpleini.doxy) | 0 | ||||
-rw-r--r-- | simpleini.dsp | 178 | ||||
-rw-r--r-- | simpleini.dsw | 29 | ||||
-rw-r--r-- | snippets.cpp | 128 | ||||
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/example.ini | 2 | ||||
-rw-r--r-- | tests/old/test.cmd (renamed from test.cmd) | 0 | ||||
-rw-r--r-- | tests/old/test1-expected.ini (renamed from test1-expected.ini) | 0 | ||||
-rw-r--r-- | tests/old/test1-input.ini (renamed from test1-input.ini) | 0 | ||||
-rw-r--r-- | tests/old/test1.cpp (renamed from test1.cpp) | 0 | ||||
-rw-r--r-- | tests/old/testsi-EUCJP.ini (renamed from testsi-EUCJP.ini) | 0 | ||||
-rw-r--r-- | tests/old/testsi-SJIS.ini (renamed from testsi-SJIS.ini) | 0 | ||||
-rw-r--r-- | tests/old/testsi-UTF8.ini (renamed from testsi-UTF8.ini) | 0 | ||||
-rw-r--r-- | tests/old/testsi.cpp (renamed from testsi.cpp) | 2 | ||||
-rw-r--r-- | tests/packages.config | 4 | ||||
-rw-r--r-- | tests/pch.cpp | 6 | ||||
-rw-r--r-- | tests/pch.h | 8 | ||||
-rw-r--r-- | tests/tests.ini | 13 | ||||
-rw-r--r-- | tests/tests.vcxproj | 129 | ||||
-rw-r--r-- | tests/ts-roundtrip.cpp | 163 | ||||
-rw-r--r-- | tests/ts-snippets.cpp | 259 | ||||
-rw-r--r-- | tests/ts-utf8.cpp | 67 | ||||
-rw-r--r-- | tests/ts-wchar.cpp | 67 | ||||
-rw-r--r-- | vcproj/SimpleIni.sln | 52 | ||||
-rw-r--r-- | vcproj/SimpleIni.vcxproj | 148 | ||||
-rw-r--r-- | vcproj/SimpleIni.vcxproj.filters | 16 |
35 files changed, 1453 insertions, 804 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..83ba081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,360 @@ +## 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 + +# 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/ + +# 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 @@ -8,7 +8,7 @@ A cross-platform library that provides a simple API to read and write INI-style # Feature Summary - MIT Licence allows free use in all software (including GPL and commercial) -- multi-platform (Windows 95/98/ME/NT/2K/XP/2003, Windows CE, Linux, Unix) +- multi-platform (Windows 95 to Windows 10, Windows CE, Linux, Unix) - loading and saving of INI-style configuration files - configuration files can have any newline format on all platforms - liberal acceptance of file format @@ -18,19 +18,14 @@ A cross-platform library that provides a simple API to read and write INI-style - 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. +- 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 - 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 -- compiles cleanly in the following compilers: - * Windows/VC6 (warning level 3) - * Windows/VC.NET 2003 (warning level 4) - * Windows/VC 2005 (warning level 4) - * Linux/gcc (-Wall) - * Windows/MinGW GCC +- should compile with no warnings in most compilers # Documentation @@ -38,115 +33,164 @@ Full documentation of the interface is available in doxygen format. # Examples -These snippets are included with the distribution in the file snippets.cpp. +These snippets are included with the distribution in the automatic tests as ts-snippets.cpp. ### SIMPLE USAGE ```c++ -CSimpleIniA ini; -ini.SetUnicode(); -ini.LoadFile("myfile.ini"); -const char * pVal = ini.GetValue("section", "key", "default"); -ini.SetValue("section", "key", "newvalue"); + // 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(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine); -SI_Error rc = ini.LoadFile(a_pszFile); -if (rc < 0) return false; - -// load from a string -std::string strData; -rc = ini.LoadData(strData.c_str(), strData.size()); -if (rc < 0) return false; + // 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 sections + CSimpleIniA::TNamesDepend sections; + ini.GetAllSections(sections); -// get all keys in a section -CSimpleIniA::TNamesDepend keys; -ini.GetAllKeys("section-name", keys); + // get all keys in a section + CSimpleIniA::TNamesDepend keys; + ini.GetAllKeys("section1", keys); ``` ### GETTING VALUES ```c++ -// get the value of a key -const char * pszValue = ini.GetValue("section-name", - "key-name", NULL /*default*/); - -// get the value of a key which may have multiple -// values. If bHasMultipleValues is true, then just -// one value has been returned -bool bHasMultipleValues; -pszValue = ini.GetValue("section-name", "key-name", - NULL /*default*/, &bHasMultipleValues); - -// get all values of a key with multiple values -CSimpleIniA::TNamesDepend values; -ini.GetAllValues("section-name", "key-name", values); - -// sort the values into the original load order -values.sort(CSimpleIniA::Entry::LoadOrder()); - -// output all of the items -CSimpleIniA::TNamesDepend::const_iterator i; -for (i = values.begin(); i != values.end(); ++i) { - printf("key-name = '%s'\n", i->pItem); -} + // 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++ -// adding a new section -rc = ini.SetValue("new-section", NULL, NULL); -if (rc < 0) return false; -printf("section: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); - -// adding a new key ("new-section" will be added -// automatically if it doesn't already exist) -rc = ini.SetValue("new-section", "new-key", "value"); -if (rc < 0) return false; -printf("key: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); - -// changing the value of a key -rc = ini.SetValue("section", "key", "updated-value"); -if (rc < 0) return false; -printf("key: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); + // 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. -ini.Delete("section-name", "key-name", - true /*delete the section if empty*/); - -// deleting an entire section and all keys in it -ini.Delete("section-name", NULL); + // 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 -rc = ini.Save(strData); -if (rc < 0) return false; - -// save the data back to the file -rc = ini.SaveFile(a_pszFile); -if (rc < 0) return false; + // 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); ``` diff --git a/SimpleIni.h b/SimpleIni.h index 047c809..8d8f0f6 100644 --- a/SimpleIni.h +++ b/SimpleIni.h @@ -3,7 +3,7 @@ <table> <tr><th>Library <td>SimpleIni <tr><th>File <td>SimpleIni.h - <tr><th>Author <td>Brodie Thiesfield [code at jellycan dot com] + <tr><th>Author <td>Brodie Thiesfield [brofield at gmail dot com] <tr><th>Source <td>https://github.com/brofield/simpleini <tr><th>Version <td>4.17 </table> @@ -1929,6 +1929,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::AddEntry( // check for existence of the key TKeyVal & keyval = iSection->second; typename TKeyVal::iterator iKey = keyval.find(a_pKey); + bInserted = iKey == keyval.end(); // remove all existing entries but save the load order and // comment of the first entry @@ -1975,8 +1976,8 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::AddEntry( } typename TKeyVal::value_type oEntry(oKey, static_cast<const SI_CHAR *>(NULL)); iKey = keyval.insert(oEntry); - bInserted = true; } + iKey->second = a_pValue; return bInserted ? SI_INSERTED : SI_UPDATED; } diff --git a/SimpleIni.sln b/SimpleIni.sln deleted file mode 100644 index 6fd8a73..0000000 --- a/SimpleIni.sln +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleIni", "SimpleIni.vcproj", "{C23240A6-AA9D-4827-AF06-C98E97CA6DFB}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Debug Unicode = Debug Unicode
- Release = Release
- Release Unicode = Release Unicode
- EndGlobalSection
- GlobalSection(ProjectDependencies) = postSolution
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Debug.ActiveCfg = Debug|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Debug.Build.0 = Debug|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Debug Unicode.ActiveCfg = Debug Unicode|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Debug Unicode.Build.0 = Debug Unicode|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Release.ActiveCfg = Release|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Release.Build.0 = Release|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Release Unicode.ActiveCfg = Release Unicode|Win32
- {C23240A6-AA9D-4827-AF06-C98E97CA6DFB}.Release Unicode.Build.0 = Release Unicode|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
diff --git a/SimpleIni.vcproj b/SimpleIni.vcproj deleted file mode 100644 index e5ee0db..0000000 --- a/SimpleIni.vcproj +++ /dev/null @@ -1,291 +0,0 @@ -<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="SimpleIni"
- ProjectGUID="{C23240A6-AA9D-4827-AF06-C98E97CA6DFB}"
- RootNamespace="SimpleIni"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testsi.exe"
- LinkIncremental="2"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/SimpleIni.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="4"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testsi.exe"
- LinkIncremental="1"
- GenerateDebugInformation="TRUE"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Debug Unicode|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="1">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testsi.exe"
- LinkIncremental="2"
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/SimpleIni.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release Unicode|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="1">
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="4"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/testsi.exe"
- LinkIncremental="1"
- GenerateDebugInformation="TRUE"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
- <File
- RelativePath=".\snippets.cpp">
- </File>
- <File
- RelativePath=".\test1.cpp">
- </File>
- <File
- RelativePath=".\testsi.cpp">
- </File>
- </Filter>
- <Filter
- Name="Library Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
- <File
- RelativePath=".\SimpleIni.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- <File
- RelativePath=".\Makefile">
- </File>
- <File
- RelativePath=".\testsi-EUCJP.ini">
- </File>
- <File
- RelativePath=".\testsi-SJIS.ini">
- </File>
- <File
- RelativePath=".\testsi-UTF8.ini">
- </File>
- </Filter>
- <Filter
- Name="Conversion Files"
- Filter="">
- <File
- RelativePath=".\ConvertUTF.c">
- </File>
- <File
- RelativePath=".\ConvertUTF.h">
- </File>
- </Filter>
- <Filter
- Name="Documentation"
- Filter="">
- <File
- RelativePath=".\simpleini.doxy">
- <FileConfiguration
- Name="Debug|Win32">
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="if not exist "C:\Program Files\doxygen\bin\doxygen.exe" goto done
-
-echo Generating documentation...
-"C:\Program Files\doxygen\bin\doxygen.exe" $(InputDir)simpleini.doxy
-
-:done
-"
- Outputs="d:\src\simpleini-doc\html\index.html"/>
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Tests"
- Filter="">
- <File
- RelativePath=".\test1-expected.ini">
- </File>
- <File
- RelativePath=".\test1-input.ini">
- </File>
- <File
- RelativePath=".\test1-output.ini">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/ini.syn b/ini.syn deleted file mode 100644 index b9c9d01..0000000 --- a/ini.syn +++ /dev/null @@ -1,36 +0,0 @@ -; Syntax file for ini files - contributed by Brodie Thiesfield -; -; Suggested Colors: -; Comments (;#) Comments, Comments 2 Green -; Sections Characters Red -; Values Strings Blue - -C=1 - -[Syntax] -Namespace1 = 6 -IgnoreCase = Yes -KeyWordLength = 1 -BracketChars = -OperatorChars = -PreprocStart = -SyntaxStart = -SyntaxEnd = -HexPrefix = -CommentStart = -CommentEnd = -CommentStartAlt = -CommentEndAlt = -SingleComment = # -SingleCommentCol = -SingleCommentAlt = ; -SingleCommentColAlt = -SingleCommentEsc = -StringsSpanLines = No -StringStart = -StringEnd = -StringAlt = = -StringEsc = -CharStart = [ -CharEnd = ] -CharEsc = diff --git a/.travis.yml b/other/.travis.yml index c1f1852..c1f1852 100644 --- a/.travis.yml +++ b/other/.travis.yml diff --git a/Makefile b/other/Makefile index a04b5e3..a04b5e3 100644 --- a/Makefile +++ b/other/Makefile diff --git a/package.cmd b/other/package.cmd index 2ae29db..51b8b15 100644 --- a/package.cmd +++ b/other/package.cmd @@ -1,26 +1,26 @@ -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
+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 diff --git a/simpleini.doxy b/other/simpleini.doxy index b9291e7..b9291e7 100644 --- a/simpleini.doxy +++ b/other/simpleini.doxy diff --git a/simpleini.dsp b/simpleini.dsp deleted file mode 100644 index 97c386a..0000000 --- a/simpleini.dsp +++ /dev/null @@ -1,178 +0,0 @@ -# Microsoft Developer Studio Project File - Name="simpleini" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=simpleini - Win32 Debug Unicode
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "simpleini.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "simpleini.mak" CFG="simpleini - Win32 Debug Unicode"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "simpleini - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "simpleini - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "simpleini - Win32 Debug Unicode" (based on "Win32 (x86) Console Application")
-!MESSAGE "simpleini - Win32 Release Unicode" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "simpleini - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0xc09 /d "NDEBUG"
-# ADD RSC /l 0xc09 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"Release/testsi.exe"
-
-!ELSEIF "$(CFG)" == "simpleini - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "simpleini___Win32_Debug"
-# PROP BASE Intermediate_Dir "simpleini___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0xc09 /d "_DEBUG"
-# ADD RSC /l 0xc09 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/testsi.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "simpleini - Win32 Debug Unicode"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug Unicode"
-# PROP BASE Intermediate_Dir "Debug Unicode"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug Unicode"
-# PROP Intermediate_Dir "Debug Unicode"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "SI_USE_GENERIC_CONVERSION" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0xc09 /d "_DEBUG"
-# ADD RSC /l 0xc09 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug Unicode/testsi.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "simpleini - Win32 Release Unicode"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release Unicode"
-# PROP BASE Intermediate_Dir "Release Unicode"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release Unicode"
-# PROP Intermediate_Dir "Release Unicode"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "SI_USE_GENERIC_CONVERSION" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0xc09 /d "NDEBUG"
-# ADD RSC /l 0xc09 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"Release Unicode/testsi.exe"
-
-!ENDIF
-
-# Begin Target
-
-# Name "simpleini - Win32 Release"
-# Name "simpleini - Win32 Debug"
-# Name "simpleini - Win32 Debug Unicode"
-# Name "simpleini - Win32 Release Unicode"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\snippets.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\test1.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\testsi.cpp
-# End Source File
-# End Group
-# Begin Group "Library Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\SimpleIni.h
-# End Source File
-# End Group
-# Begin Group "Generic Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ConvertUTF.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ConvertUTF.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/simpleini.dsw b/simpleini.dsw deleted file mode 100644 index 2d593ed..0000000 --- a/simpleini.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "simpleini"=.\simpleini.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/snippets.cpp b/snippets.cpp deleted file mode 100644 index 8a69aa6..0000000 --- a/snippets.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// File: snippets.cpp -// Library: SimpleIni -// Author: Brodie Thiesfield <code@jellycan.com> -// Source: http://code.jellycan.com/simpleini/ -// -// Snippets that are used on the website - -#ifdef _WIN32 -# pragma warning(disable: 4786) -#endif - -#ifndef _WIN32 -# include <unistd.h> -#endif -#include <fstream> - -#define SI_SUPPORT_IOSTREAMS -#include "SimpleIni.h" - -bool -snippets( - const char * a_pszFile, - bool a_bIsUtf8, - bool a_bUseMultiKey, - bool a_bUseMultiLine - ) -{ - // LOADING DATA - - // load from a data file - CSimpleIniA ini(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine); - SI_Error rc = ini.LoadFile(a_pszFile); - if (rc < 0) return false; - - // load from a string - std::string strData; - rc = ini.LoadData(strData.c_str(), strData.size()); - if (rc < 0) return false; - - // GETTING SECTIONS AND KEYS - - // get all sections - CSimpleIniA::TNamesDepend sections; - ini.GetAllSections(sections); - - // get all keys in a section - CSimpleIniA::TNamesDepend keys; - ini.GetAllKeys("section-name", keys); - - // GETTING VALUES - - // get the value of a key - const char * pszValue = ini.GetValue("section-name", - "key-name", NULL /*default*/); - - // get the value of a key which may have multiple - // values. If bHasMultipleValues is true, then just - // one value has been returned - bool bHasMultipleValues; - pszValue = ini.GetValue("section-name", "key-name", - NULL /*default*/, &bHasMultipleValues); - - // get all values of a key with multiple values - CSimpleIniA::TNamesDepend values; - ini.GetAllValues("section-name", "key-name", values); - - // sort the values into the original load order -#if defined(_MSC_VER) && _MSC_VER <= 1200 - /** STL of VC6 doesn't allow me to specify my own comparator for list::sort() */ - values.sort(); -#else - values.sort(CSimpleIniA::Entry::LoadOrder()); -#endif - - // output all of the items - CSimpleIniA::TNamesDepend::const_iterator i; - for (i = values.begin(); i != values.end(); ++i) { - printf("key-name = '%s'\n", i->pItem); - } - - // MODIFYING DATA - - // adding a new section - rc = ini.SetValue("new-section", NULL, NULL); - if (rc < 0) return false; - printf("section: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); - - // adding a new key ("new-section" will be added - // automatically if it doesn't already exist. - rc = ini.SetValue("new-section", "new-key", "value"); - if (rc < 0) return false; - printf("key: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); - - // changing the value of a key - rc = ini.SetValue("section", "key", "updated-value"); - if (rc < 0) return false; - printf("key: %s\n", rc == SI_INSERTED ? - "inserted" : "updated"); - - // DELETING DATA - - // deleting a key with a value from a section. - // Optionally the entire section may be deleted if - // it is now empty. - ini.DeleteValue("section-name", "key-name", "value", - true /*delete the section if empty*/); - - // deleting a key with any value from a section. - ini.Delete("section-name", "key-name", - true /*delete the section if empty*/); - - // deleting an entire section and all keys in it - ini.Delete("section-name", NULL); - - // SAVING DATA - - // save the data to a string - rc = ini.Save(strData); - if (rc < 0) return false; - - // save the data back to the file - rc = ini.SaveFile(a_pszFile); - if (rc < 0) return false; - - return true; -} diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..51ade18 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +example2.ini diff --git a/tests/example.ini b/tests/example.ini new file mode 100644 index 0000000..43b252c --- /dev/null +++ b/tests/example.ini @@ -0,0 +1,2 @@ +[section] +key = value diff --git a/test.cmd b/tests/old/test.cmd index 2d319d5..2d319d5 100644 --- a/test.cmd +++ b/tests/old/test.cmd diff --git a/test1-expected.ini b/tests/old/test1-expected.ini index dde335d..dde335d 100644 --- a/test1-expected.ini +++ b/tests/old/test1-expected.ini diff --git a/test1-input.ini b/tests/old/test1-input.ini index 6d27681..6d27681 100644 --- a/test1-input.ini +++ b/tests/old/test1-input.ini diff --git a/test1.cpp b/tests/old/test1.cpp index 3dd7800..3dd7800 100644 --- a/test1.cpp +++ b/tests/old/test1.cpp diff --git a/testsi-EUCJP.ini b/tests/old/testsi-EUCJP.ini index 16d1d06..16d1d06 100644 --- a/testsi-EUCJP.ini +++ b/tests/old/testsi-EUCJP.ini diff --git a/testsi-SJIS.ini b/tests/old/testsi-SJIS.ini index 585af09..585af09 100644 --- a/testsi-SJIS.ini +++ b/tests/old/testsi-SJIS.ini diff --git a/testsi-UTF8.ini b/tests/old/testsi-UTF8.ini index ead2c40..ead2c40 100644 --- a/testsi-UTF8.ini +++ b/tests/old/testsi-UTF8.ini diff --git a/testsi.cpp b/tests/old/testsi.cpp index 4f7963e..0c5d7d7 100644 --- a/testsi.cpp +++ b/tests/old/testsi.cpp @@ -21,7 +21,7 @@ //#define SI_CONVERT_GENERIC //#define SI_CONVERT_ICU //#define SI_CONVERT_WIN32 -#include "SimpleIni.h" +#include "../SimpleIni.h" #ifdef SI_CONVERT_ICU // if converting using ICU then we need the ICU library diff --git a/tests/packages.config b/tests/packages.config new file mode 100644 index 0000000..6c6422e --- /dev/null +++ b/tests/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.1.3" targetFramework="native" /> +</packages>
\ No newline at end of file diff --git a/tests/pch.cpp b/tests/pch.cpp new file mode 100644 index 0000000..97b544e --- /dev/null +++ b/tests/pch.cpp @@ -0,0 +1,6 @@ +// +// pch.cpp +// Include the standard header and generate the precompiled header. +// + +#include "pch.h" diff --git a/tests/pch.h b/tests/pch.h new file mode 100644 index 0000000..29c81ff --- /dev/null +++ b/tests/pch.h @@ -0,0 +1,8 @@ +// +// pch.h +// Header for standard system include files. +// + +#pragma once + +#include "gtest/gtest.h" diff --git a/tests/tests.ini b/tests/tests.ini new file mode 100644 index 0000000..ea66f7a --- /dev/null +++ b/tests/tests.ini @@ -0,0 +1,13 @@ +[section1] +key1=value1 + +[section2] +test2=テスト2 +テスト=test +テスト2=テスト二 + +[検査] +key2=value2 +test2=テスト2 +テスト=test +テスト2=テスト二 diff --git a/tests/tests.vcxproj b/tests/tests.vcxproj new file mode 100644 index 0000000..5fe1d76 --- /dev/null +++ b/tests/tests.vcxproj @@ -0,0 +1,129 @@ +<?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|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"> + <ProjectGuid>{8f30a5dc-b942-4c9a-ba75-91c906ff85fa}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion> + <ConfigurationType>Application</ConfigurationType> + <PlatformToolset>v142</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-roundtrip.cpp" /> + <ClCompile Include="ts-snippets.cpp" /> + <ClCompile Include="ts-utf8.cpp" /> + <ClCompile Include="pch.cpp"> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> + <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="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.3\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.3\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" /> + </ImportGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <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>Level3</WarningLevel> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> + <PreprocessorDefinitions>WIN32;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> + <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.3\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.3\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'))" /> + </Target> +</Project>
\ No newline at end of file diff --git a/tests/ts-roundtrip.cpp b/tests/ts-roundtrip.cpp new file mode 100644 index 0000000..3808a08 --- /dev/null +++ b/tests/ts-roundtrip.cpp @@ -0,0 +1,163 @@ +#include "pch.h" +#include <algorithm> +#include "../SimpleIni.h" + +class TestRoundTrip : public ::testing::Test { +protected: + void TestRoundTrip::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" + "key1 = string\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()); +} diff --git a/tests/ts-snippets.cpp b/tests/ts-snippets.cpp new file mode 100644 index 0000000..d18150e --- /dev/null +++ b/tests/ts-snippets.cpp @@ -0,0 +1,259 @@ +#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); +} + + +// ### 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); +} + diff --git a/tests/ts-utf8.cpp b/tests/ts-utf8.cpp new file mode 100644 index 0000000..9208648 --- /dev/null +++ b/tests/ts-utf8.cpp @@ -0,0 +1,67 @@ +#include "pch.h" +#include "../SimpleIni.h" + +class TestUTF8 : public ::testing::Test { +protected: + void TestUTF8::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); +} diff --git a/tests/ts-wchar.cpp b/tests/ts-wchar.cpp new file mode 100644 index 0000000..8041272 --- /dev/null +++ b/tests/ts-wchar.cpp @@ -0,0 +1,67 @@ +#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); +} diff --git a/vcproj/SimpleIni.sln b/vcproj/SimpleIni.sln new file mode 100644 index 0000000..be0dd1a --- /dev/null +++ b/vcproj/SimpleIni.sln @@ -0,0 +1,52 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 +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 + ..\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 + ..\other\.travis.yml = ..\other\.travis.yml + ..\other\Makefile = ..\other\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 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + 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}.Debug|x86.ActiveCfg = Debug|Win32 + {8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Debug|x86.Build.0 = Debug|Win32 + {8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x64.ActiveCfg = Release|x64 + {8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x64.Build.0 = Release|x64 + {8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x86.ActiveCfg = Release|Win32 + {8F30A5DC-B942-4C9A-BA75-91C906FF85FA}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ABD2CECE-EA8B-455B-8AE7-00E499634EC2} + EndGlobalSection +EndGlobal diff --git a/vcproj/SimpleIni.vcxproj b/vcproj/SimpleIni.vcxproj new file mode 100644 index 0000000..e0ca636 --- /dev/null +++ b/vcproj/SimpleIni.vcxproj @@ -0,0 +1,148 @@ +<?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>
\ No newline at end of file diff --git a/vcproj/SimpleIni.vcxproj.filters b/vcproj/SimpleIni.vcxproj.filters new file mode 100644 index 0000000..742ba65 --- /dev/null +++ b/vcproj/SimpleIni.vcxproj.filters @@ -0,0 +1,16 @@ +<?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>
\ No newline at end of file |