Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioZ committed Jan 17, 2015
1 parent c8b75dc commit 5d4cfff
Show file tree
Hide file tree
Showing 57 changed files with 3,686 additions and 2 deletions.
Binary file added MadMilkman.Ini.Documentation.chm
Binary file not shown.
40 changes: 40 additions & 0 deletions MadMilkman.Ini.Samples/MadMilkman.Ini.Samples.CPP/AssemblyInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "stdafx.h"

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;

//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("MadMilkmanIniSamplesCPP")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("MadMilkmanIniSamplesCPP")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2015")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];

//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("1.0.*")];

[assembly:ComVisible(false)];

[assembly:CLSCompliantAttribute(true)];

[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
191 changes: 191 additions & 0 deletions MadMilkman.Ini.Samples/MadMilkman.Ini.Samples.CPP/IniSamples.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#include "stdafx.h"
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace MadMilkman::Ini;


void HelloWorld()
{
// Create new file.
IniFile ^file = gcnew IniFile();

// Add new section.
IniSection ^section = file->Sections->Add("Section Name");

// Add new key and its value.
IniKey ^key = section->Keys->Add("Key Name", "Hello World");

// Read file's specific value.
Console::WriteLine(file->Sections["Section Name"]->Keys["Key Name"]->Value);
}

void Create()
{
// Create new file with default formatting.
IniFile ^file = gcnew IniFile(gcnew IniOptions());

// Add new content.
IniSection ^section = gcnew IniSection(file, IniSection::GlobalSectionName);
IniKey ^key = gcnew IniKey(file, "Key 1", "Value 1");
file->Sections->Add(section);
section->Keys->Add(key);

// Add new content.
file->Sections->Add("Section 2")->Keys->Add("Key 2", "Value 2");

// Add new content.
file->Sections->Add(
gcnew IniSection(file, "Section 3",
gcnew IniKey(file, "Key 3", "Value 3")));
}

void Load()
{
IniOptions ^options = gcnew IniOptions();
IniFile ^iniFile = gcnew IniFile(options);

// Load file from path.
iniFile->Load("..\\MadMilkman.Ini.Samples.Files\\Load Example.ini");

// Load file from stream.
Stream ^fileStream = File::OpenRead("..\\MadMilkman.Ini.Samples.Files\\Load Example.ini");
try { iniFile->Load(fileStream); }
finally { delete fileStream; }

// Load file's content from string.
String ^iniContent = "[Section 1]" + Environment::NewLine +
"Key 1.1 = Value 1.1" + Environment::NewLine +
"Key 1.2 = Value 1.2" + Environment::NewLine +
"Key 1.3 = Value 1.3" + Environment::NewLine +
"Key 1.4 = Value 1.4";
Stream ^contentStream = gcnew MemoryStream(options->Encoding->GetBytes(iniContent));
try { iniFile->Load(contentStream); }
finally { delete contentStream; }

// Read file's content.
for each (IniSection ^section in iniFile->Sections)
{
Console::WriteLine("SECTION: {0}", section->Name);
for each (IniKey ^key in section->Keys)
{
Console::WriteLine("KEY: {0}, VALUE: {1}", key->Name, key->Value);
}
}
}

void Style()
{
IniFile ^file = gcnew IniFile();
file->Sections->Add("Section 1")->Keys->Add("Key 1", "Value 1");
file->Sections->Add("Section 2")->Keys->Add("Key 2", "Value 2");
file->Sections->Add("Section 3")->Keys->Add("Key 3", "Value 3");

// Add leading comments.
file->Sections[0]->LeadingComment->Text = "Section 1 leading comment.";
file->Sections[0]->Keys[0]->LeadingComment->Text = "Key 1 leading comment.";

// Add trailing comments.
file->Sections[1]->TrailingComment->Text = "Section 2 trailing comment->";
file->Sections[1]->Keys[0]->TrailingComment->Text = "Key 2 trailing comment->";

// Add left space, indentation.
file->Sections[1]->LeftIndentation = 4;
file->Sections[1]->TrailingComment->LeftIndentation = 4;
file->Sections[1]->Keys[0]->LeftIndentation = 4;
file->Sections[1]->Keys[0]->TrailingComment->LeftIndentation = 4;

// Add above space, empty lines.
file->Sections[2]->TrailingComment->EmptyLinesBefore = 2;
}

void Save()
{
IniOptions ^options = gcnew IniOptions();
IniFile ^iniFile = gcnew IniFile(options);
iniFile->Sections->Add(
gcnew IniSection(iniFile, "Section 1",
gcnew IniKey(iniFile, "Key 1.1", "Value 1.1"),
gcnew IniKey(iniFile, "Key 1.2", "Value 1.2"),
gcnew IniKey(iniFile, "Key 1.3", "Value 1.3"),
gcnew IniKey(iniFile, "Key 1.4", "Value 1.4")));

// Save file to path.
iniFile->Save("..\\MadMilkman.Ini.Samples.Files\\Save Example.ini");

// Save file to stream.
Stream ^fileStream = File::Create("..\\MadMilkman.Ini.Samples.Files\\Save Example.ini");
try { iniFile->Save(fileStream); }
finally { delete fileStream; }

// Save file's content to string.
String ^iniContent;
Stream ^contentStream = gcnew MemoryStream();
try
{
iniFile->Save(contentStream);
iniContent = (gcnew StreamReader(contentStream, options->Encoding))->ReadToEnd();
}
finally { delete contentStream; }

Console::WriteLine(iniContent);
}

void Custom()
{
IniOptions ^options = gcnew IniOptions();
options->CommentStarter = IniCommentStarter::Hash;
options->KeyDelimiter = IniKeyDelimiter::Colon;
options->KeySpaceAroundDelimiter = true;
options->SectionWrapper = IniSectionWrapper::CurlyBrackets;
options->Encoding = Encoding::UTF8;
IniFile ^file = gcnew IniFile(options);

// Load file.
file->Load("..\\MadMilkman.Ini.Samples.Files\\Custom Example Input.ini");

// Change first section's fourth key's value.
file->Sections[0]->Keys[3]->Value = "NEW VALUE";

// Save file.
file->Save("..\\MadMilkman.Ini.Samples.Files\\Custom Example Output.ini");
}

void Copy()
{
// Create new file.
IniFile ^file = gcnew IniFile();

// Add new content.
IniSection ^section = file->Sections->Add("Section");
IniKey ^key = section->Keys->Add("Key");

// Add duplicate section.
file->Sections->Add(section->Copy());

// Add duplicate key.
section->Keys->Add(key->Copy());

// Create new file.
IniFile ^newFile = gcnew IniFile(gcnew IniOptions());

// Import first file's section to second file.
newFile->Sections->Add(section->Copy(newFile));
}

void main()
{
HelloWorld();

Create();

Load();

Style();

Save();

Custom();

Copy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.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>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{097C11FE-8D4B-48D8-884E-0747454E43DB}</ProjectGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>MadMilkmanIniSamplesCPP</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</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>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies />
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies />
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="IniSamples.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MadMilkman.Ini\MadMilkman.Ini.csproj">
<Project>{bef9735d-c3cc-41e6-aac6-18c5985d3107}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="IniSamples.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
7 changes: 7 additions & 0 deletions MadMilkman.Ini.Samples/MadMilkman.Ini.Samples.CPP/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// stdafx.cpp : source file that includes just the standard includes
// MadMilkman.Ini.Samples.CPP.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"


8 changes: 8 additions & 0 deletions MadMilkman.Ini.Samples/MadMilkman.Ini.Samples.CPP/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

// TODO: reference additional headers your program requires here
Loading

0 comments on commit 5d4cfff

Please sign in to comment.