-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working set.
- Loading branch information
Showing
21 changed files
with
1,884 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// CardFileRdr - Copyright © 2016 John Oliver | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System.IO; | ||
|
||
namespace CardFileRdr { | ||
|
||
/// <summary> | ||
/// A Char Reader for Ascii encodings | ||
/// </summary> | ||
class AsciiReader : CharReader { | ||
|
||
private BinaryReader br; | ||
|
||
public AsciiReader(BinaryReader ibr) { | ||
br = ibr; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Read one char | ||
/// </summary> | ||
/// <returns>The char</returns> | ||
public char ReadChar() { | ||
return br.ReadChar(); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Read some chars | ||
/// </summary> | ||
/// <param name="num">The number of chars to read</param> | ||
/// <returns>The chars</returns> | ||
public char[] ReadChars(int num) { | ||
char[] ca = new char[num]; | ||
ca = br.ReadChars(num); | ||
return ca; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// CardFileRdr - Copyright © 2016 John Oliver | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace CardFileRdr { | ||
|
||
/// <summary> | ||
/// A card from a cardfile | ||
/// </summary> | ||
public class Card { | ||
|
||
private string title = String.Empty; | ||
private string data = String.Empty; | ||
|
||
/// <summary> | ||
/// Card data | ||
/// </summary> | ||
public string Data { | ||
get { | ||
return data; | ||
} | ||
|
||
set { | ||
if (value == null) { | ||
data = string.Empty; | ||
} else { | ||
data = value; | ||
} | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The index title text | ||
/// </summary> | ||
public string Title { | ||
get { | ||
return title; | ||
} | ||
|
||
set { | ||
if (value == null) { | ||
title = string.Empty; | ||
} else { | ||
title = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initialise the data | ||
/// </summary> | ||
public void init() { | ||
title = String.Empty; | ||
data = String.Empty; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// CardFileRdr - Copyright © 2016 John Oliver | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.IO; | ||
|
||
namespace CardFileRdr { | ||
|
||
/// <summary> | ||
/// This class reads a CardFile and exports it using the supplied Writer object. | ||
/// </summary> | ||
public class CardFile { | ||
|
||
private bool doTrace; // logging? | ||
|
||
// Logging is a security risk if the Cardfile contains sensitive information | ||
// so it should only be enabled for debugging with test data. | ||
private static Logger log; // The logger | ||
|
||
/// <summary> | ||
/// Common logger | ||
/// </summary> | ||
public static Logger Log { | ||
get { | ||
return log; | ||
} | ||
} | ||
|
||
|
||
// The writer of the card file data that was read | ||
private Writer wrtr; | ||
|
||
|
||
/// <summary> | ||
/// Construct a Cardfile object | ||
/// </summary> | ||
/// <param name="pDoTrace">Set logging on?</param> | ||
/// <param name="logFileName">Name of log file when logging used (or empty string when not)</param> | ||
/// <param name="wrtr">The object performing the writing of the data read</param> | ||
public CardFile( bool pDoTrace, string logFileName, Writer wrtr ) { | ||
if (logFileName == null) { | ||
throw new ArgumentNullException( "CardFile(): null logFileName received" ); | ||
} | ||
if (wrtr == null) { | ||
throw new ArgumentNullException( "CardFile(): null wrtr received" ); | ||
} | ||
|
||
log = new Logger( String.Empty ); // Always need a valid log object even if not logging | ||
doTrace = pDoTrace; | ||
if (doTrace) { | ||
log = new Logger( logFileName ); | ||
log.open(); | ||
} | ||
this.wrtr = wrtr; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Process the CardFile - read it and write it out | ||
/// </summary> | ||
/// <param name="inStrm">The card file to be read</param> | ||
public void process( Stream inStrm ) { | ||
try { | ||
|
||
FileProcessor fp = new FileProcessor( doTrace, wrtr ); | ||
fp.readBinFile( inStrm ); | ||
|
||
} catch (Exception ex) { | ||
Log.writeLn( ex.ToString() ); | ||
throw; | ||
} finally { | ||
Log.close(); | ||
}//try | ||
|
||
}//process | ||
|
||
}//class | ||
}//namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CardFileRdr</RootNamespace> | ||
<AssemblyName>CardFileRdr</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile> | ||
</TargetFrameworkProfile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleasePlgx|AnyCPU'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\ReleasePlgx\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AssemblyOriginatorKeyFile>snpvtkey.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AsciiReader.cs" /> | ||
<Compile Include="Card.cs" /> | ||
<Compile Include="CardFile.cs" /> | ||
<Compile Include="CharReader.cs" /> | ||
<Compile Include="ExnCardFileRdr.cs" /> | ||
<Compile Include="ExnEndOfStream.cs" /> | ||
<Compile Include="ExnInvalidCardfile.cs" /> | ||
<Compile Include="ExnNoSuchCardFileType.cs" /> | ||
<Compile Include="FileProcessor.cs" /> | ||
<Compile Include="Logger.cs" /> | ||
<Compile Include="OLE.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="UCS2Reader.cs" /> | ||
<Compile Include="Writer.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="snpvtkey.snk" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25420.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardFileRdr", "CardFileRdr\CardFileRdr.csproj", "{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{750B23A0-E5B2-43BD-B7FD-BDC7689F66C9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// CardFileRdr - Copyright © 2016 John Oliver | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace CardFileRdr { | ||
|
||
interface CharReader { | ||
|
||
char ReadChar(); | ||
|
||
char[] ReadChars(int num); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// CardFileRdr - Copyright © 2016 John Oliver | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace CardFileRdr { | ||
|
||
/// <summary> | ||
/// Exception arising from CardFileRdr - Generic base class for this app's exceptions | ||
/// </summary> | ||
[Serializable] | ||
public class ExnCardFileRdr : Exception { | ||
|
||
/// <summary> | ||
/// Exception with default message | ||
/// </summary> | ||
public ExnCardFileRdr() : base() { } | ||
|
||
/// <summary> | ||
/// Exception with parameterised message | ||
/// </summary> | ||
/// <param name="msg">Text</param> | ||
public ExnCardFileRdr( string msg ) : base( msg ) { } | ||
|
||
/// <summary> | ||
/// Chained exception with parameterised message and exception. | ||
/// </summary> | ||
/// <param name="msg">Text</param> | ||
/// <param name="ex">Chained exception</param> | ||
public ExnCardFileRdr( string msg, Exception ex ) : base( msg, ex ) { } | ||
|
||
/// <summary> | ||
/// Make exception serializable | ||
/// </summary> | ||
/// <param name="info"></param> | ||
/// <param name="context"></param> | ||
protected ExnCardFileRdr( SerializationInfo info, StreamingContext context ) : base(info, context) { } | ||
|
||
}//c | ||
|
||
}//n |
Oops, something went wrong.