Skip to content

Commit

Permalink
Merge pull request #5 from anixe/master
Browse files Browse the repository at this point in the history
update fork
  • Loading branch information
lechu445 authored Apr 12, 2021
2 parents ce09d17 + c84ae60 commit 534461c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 28 deletions.
1 change: 1 addition & 0 deletions Anixe.Ion.UnitTests/CurrentLineVerifierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public bool IsSectionHeader_Tests(string currentLine)
[TestCase("|date|", ExpectedResult = false)]
[TestCase("|-", ExpectedResult = false)]
[TestCase("|-1", ExpectedResult = false)]
[TestCase(" abc", ExpectedResult = true)]
[TestCase("abc", ExpectedResult = true)]
[TestCase(";abc", ExpectedResult = true)]
[TestCase("1abc", ExpectedResult = true)]
Expand Down
27 changes: 18 additions & 9 deletions Anixe.Ion.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Anixe.Ion", "Anixe.Ion\Anixe.Ion.csproj", "{679149D4-BF21-46BE-96DE-A162DA69AE02}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Anixe.Ion", "Anixe.Ion\Anixe.Ion.csproj", "{679149D4-BF21-46BE-96DE-A162DA69AE02}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Anixe.Ion.Tester", "Anixe.Ion.Tester\Anixe.Ion.Tester.csproj", "{AB397655-CCF5-4C0E-9882-2501B72F6877}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Anixe.Ion.Tester", "Anixe.Ion.Tester\Anixe.Ion.Tester.csproj", "{AB397655-CCF5-4C0E-9882-2501B72F6877}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Anixe.Ion.UnitTests", "Anixe.Ion.UnitTests\Anixe.Ion.UnitTests.csproj", "{AF76EBA1-9529-435E-A56D-BF6C2E2EE57E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Anixe.Ion.UnitTests", "Anixe.Ion.UnitTests\Anixe.Ion.UnitTests.csproj", "{AF76EBA1-9529-435E-A56D-BF6C2E2EE57E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Anixe.Ion.Benchmark", "Anixe.Ion.Benchmark\Anixe.Ion.Benchmark.csproj", "{736DC7C4-B1DE-46C5-9EB3-A7F15C7B3B7E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Anixe.Ion.Benchmark", "Anixe.Ion.Benchmark\Anixe.Ion.Benchmark.csproj", "{736DC7C4-B1DE-46C5-9EB3-A7F15C7B3B7E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{420DF218-D3B0-4079-8D1B-8A3337F98D15}"
ProjectSection(SolutionItems) = preProject
CHANGELOG.md = CHANGELOG.md
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -20,9 +26,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{679149D4-BF21-46BE-96DE-A162DA69AE02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{679149D4-BF21-46BE-96DE-A162DA69AE02}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand Down Expand Up @@ -73,4 +76,10 @@ Global
{736DC7C4-B1DE-46C5-9EB3-A7F15C7B3B7E}.Release|x86.ActiveCfg = Release|Any CPU
{736DC7C4-B1DE-46C5-9EB3-A7F15C7B3B7E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4EB8F5F-264B-4467-8C89-91846EB6B494}
EndGlobalSection
EndGlobal
41 changes: 23 additions & 18 deletions Anixe.Ion/CurrentLineVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,62 @@ internal sealed class CurrentLineVerifier
{
public bool IsSectionHeader(ArraySegment<char> currentLine)
{
return !IsEmptyLine(currentLine)
return currentLine.Count != 0
&& currentLine[0] == Consts.IonSpecialChars.HeaderOpeningCharacter;
}

public bool IsTableHeaderRow(ArraySegment<char> currentLine, bool passedCurrentTableHeaderRow)
{
return !passedCurrentTableHeaderRow
&& !IsEmptyLine(currentLine)
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter
&& currentLine[1] != Consts.IonSpecialChars.TableHeaderSeparatorCharacter;
&& currentLine.Count > 1
&& currentLine[1] != Consts.IonSpecialChars.TableHeaderSeparatorCharacter
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter;
}

public bool IsTableDataRow(ArraySegment<char> currentLine, bool passedCurrentTableHeaderRow)
{
return passedCurrentTableHeaderRow
&& !IsEmptyLine(currentLine)
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter
&& currentLine[1] != Consts.IonSpecialChars.TableHeaderSeparatorCharacter;
&& currentLine.Count > 1
&& currentLine[1] != Consts.IonSpecialChars.TableHeaderSeparatorCharacter
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter;
}

public bool IsProperty(ArraySegment<char> currentLine)
{
return !IsEmptyLine(currentLine)
&& !IsSectionHeader(currentLine)
&& !IsComment(currentLine)
&& !IsTableRow(currentLine)
&& !IsTableHeaderSeparatorRow(currentLine);
if (currentLine.Count == 0)
{
return false;
}

char firstChar = currentLine[0];
return firstChar != Consts.IonSpecialChars.TableOpeningCharacter
&& firstChar != Consts.IonSpecialChars.HeaderOpeningCharacter
&& firstChar != Consts.IonSpecialChars.CommentCharacter
&& !IsWhiteSpace(currentLine);
}

public bool IsComment(ArraySegment<char> currentLine)
{
return !IsEmptyLine(currentLine)
return currentLine.Count != 0
&& currentLine[0] == Consts.IonSpecialChars.CommentCharacter;
}

public bool IsTableRow(ArraySegment<char> currentLine)
{
return !IsEmptyLine(currentLine)
return currentLine.Count != 0
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter;
}

public bool IsTableHeaderSeparatorRow(ArraySegment<char> currentLine)
{
return !IsEmptyLine(currentLine)
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter
&& currentLine[1] == Consts.IonSpecialChars.TableHeaderSeparatorCharacter;
return currentLine.Count > 1
&& currentLine[1] == Consts.IonSpecialChars.TableHeaderSeparatorCharacter
&& currentLine[0] == Consts.IonSpecialChars.TableOpeningCharacter;
}

public bool IsEmptyLine(ArraySegment<char> currentLine)
{
return currentLine == default(ArraySegment<char>) || currentLine.Count == 0 || IsWhiteSpace(currentLine);
return currentLine.Count == 0 || IsWhiteSpace(currentLine);
}

private static bool IsWhiteSpace(ArraySegment<char> currentLine)
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
## 2.1.0
- added IonProperty ref-struct that represents property row of IIonReader
- added extension method IIonReader.ReadProperty() that returns IonProperty struct

- ION reading performance optimization
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Anixe.Ion library provides static factory which can create an instance for **Ion
* **IsSectionHeader** gets boolean value indicating whether first character of **CurrentLine** is *'['*
* **IsComment** gets boolean value indicating whether first character of **CurrentLine** is *'#'*
* **IsTableRow** gets boolean value indicating whether first character of **CurrentLine** is *'|'*
* **IsTableHeaderRow** gets boolean value indicating whether first character of **CurrentLine** is *'|'* and current table header was not already passed
* **IsTableHeaderSeparatorRow** gets boolean value indicating whether first character of **CurrentLine** is *'|'* and second character is *'-'*
* **IsTableDataRow** gets boolean value indicating whether first character of **CurrentLine** is *'|'* and current table header was already passed
* **IsEmptyLine** returns boolean value indicating whether first character of **CurrentLine** is empty string or line is filled with empty spaces
* **IsProperty** returns boolean value indicating whether other properties are false

Expand Down

0 comments on commit 534461c

Please sign in to comment.