Add project files.

This commit is contained in:
moosecrab 2022-05-29 02:29:46 -07:00
parent 3580dafadd
commit 290a5e6b64
4 changed files with 144 additions and 0 deletions

10
mfs/Program.cs Normal file
View File

@ -0,0 +1,10 @@
using System;
namespace mfs
{
internal class Program {
static void Main(string[] args) {
TLGDatabase testdb = new("aero\\Master Files\\Stratolaunch_CA_AllTables_Master_RevL.dat");
}
}
}

99
mfs/TLGDatabase.cs Normal file
View File

@ -0,0 +1,99 @@
namespace mfs {
internal class TLGDatabase {
private enum block_types {
NONE,
REFERENCE_DATA,
BASIC_TABLE,
INCREMENT_TABLE,
DERIVATIVE_TABLE,
} ;
private block_types currentblock = block_types.NONE;
public Dictionary<string, double> reference_values = new Dictionary<string, double>();
public TLGDatabase(string path) {
readfile(path);
}
private void readfile(string path) {
StreamReader fs = File.OpenText(path);
string line = "";
while (!fs.EndOfStream) {
line = fs.ReadLine();
if (line == null) {
line = "";
}
if (string.IsNullOrWhiteSpace(line) || (line[0] == '%')) {
// lines starting with % are comment lines and ignored
// blank or whitespace lines also ignored
} else if (line == "END BLOCK") {
currentblock = block_types.NONE;
} else {
switch (currentblock) {
case block_types.NONE:
// look for data blocks, or an include line
switch (line) {
case "BEGIN REFERENCE DATA BLOCK":
currentblock = block_types.REFERENCE_DATA;
break;
case "BEGIN BASIC TABLE BLOCK":
currentblock = block_types.BASIC_TABLE;
break;
case "BEGIN INCREMENT TABLE BLOCK":
currentblock = block_types.INCREMENT_TABLE;
break;
case "BEGIN DERIVATIVE TABLE BLOCK":
currentblock = block_types.DERIVATIVE_TABLE;
break;
}
if (line.StartsWith("INCLUDE,", StringComparison.InvariantCultureIgnoreCase)) {
string includepath = line.Substring(8).Trim();
if (File.Exists(includepath)) {
readfile(includepath);
} else {
throw new Exception("Could not find included file " + includepath);
}
}
break;
case block_types.REFERENCE_DATA:
string[] splitline = line.Split(',', StringSplitOptions.TrimEntries & StringSplitOptions.RemoveEmptyEntries);
if (splitline.Length != 2) {
throw new Exception("Error parsing reference parameter " + splitline[0]);
} else {
double val = double.NaN;
if (double.TryParse(splitline[1], out val)) {
reference_values.Add(splitline[0], val);
} else {
throw new Exception("Could not parse reference parameter " + splitline[0]);
}
}
break;
case block_types.BASIC_TABLE:
break;
case block_types.INCREMENT_TABLE:
break;
case block_types.DERIVATIVE_TABLE:
break;
default:
break;
}
}
}
if (currentblock != block_types.NONE) {
throw new Exception("End of file encountered inside a block");
}
fs.Close();
}
}
}

10
mfs/mfs.csproj Normal file
View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

25
mfs2022.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32519.379
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mfs", "mfs\mfs.csproj", "{CF0AB839-D840-4F7F-A4F1-87B3A216C764}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF0AB839-D840-4F7F-A4F1-87B3A216C764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF0AB839-D840-4F7F-A4F1-87B3A216C764}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF0AB839-D840-4F7F-A4F1-87B3A216C764}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF0AB839-D840-4F7F-A4F1-87B3A216C764}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {80A68656-006C-412E-931E-D1F282DFA9F4}
EndGlobalSection
EndGlobal