Skip to content

Commit

Permalink
Expose yaml config
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Jan 28, 2024
1 parent e1304a2 commit 8d9a0d9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/BymlLibrary/Byml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public enum BymlNodeType : byte

public sealed class Byml
{
public static class YamlConfig
{
/// <summary>
/// The max amount of children in a container node to trigger a flow style scalar (inline)
/// </summary>
public static int InlineContainerMaxCount { get; set; } = 8;
}

/// <summary>
/// <c>YB</c>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ internal unsafe void EmitYaml(YamlEmitter emitter, in ImmutableByml root)
{
emitter.Builder.Append($"!h32");

if (!emitter.IsIndented && Count < YamlEmitter.FlowContainerStyleMaxChildren && !HasContainerNodes()) {
if (!emitter.IsIndented && Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) {
emitter.Builder.Append(" {");
for (int i = 0; i < Count;) {
var (hash, node) = this[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal unsafe void EmitYaml(YamlEmitter emitter, in ImmutableByml root)
{
emitter.Builder.Append($"!h64");

if (!emitter.IsIndented && Count < YamlEmitter.FlowContainerStyleMaxChildren && !HasContainerNodes()) {
if (!emitter.IsIndented && Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) {
emitter.Builder.Append(" {");
for (int i = 0; i < Count;) {
var (hash, node) = this[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void Reverse(ref RevrsReader reader, int offset, int count, in Has
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void EmitYaml(YamlEmitter emitter, in ImmutableByml root)
{
if (Count < YamlEmitter.FlowContainerStyleMaxChildren && !HasContainerNodes()) {
if (Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) {
emitter.Builder.Append('[');
for (int i = 0; i < Count;) {
emitter.EmitNode(this[i], root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void Reverse(ref RevrsReader reader, int offset, int count, in Has
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void EmitYaml(YamlEmitter emitter, in ImmutableByml root)
{
if (Count < YamlEmitter.FlowContainerStyleMaxChildren && !HasContainerNodes()) {
if (Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) {
emitter.Builder.Append('{');
for (int i = 0; i < Count;) {
var (keyIndex, node) = this[i];
Expand Down
5 changes: 0 additions & 5 deletions src/BymlLibrary/Yaml/YamlEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ namespace BymlLibrary.Yaml;

internal class YamlEmitter
{
/// <summary>
/// The max amount of children in a container node to trigger a flow style scalar (inline)
/// </summary>
public static int FlowContainerStyleMaxChildren { get; set; } = 8;

private const string INDENT = " ";
private const char NEWLINE_CHAR = '\n';
private const byte NEWLINE_CHAR_UTF8 = (byte)'\n';
Expand Down

0 comments on commit 8d9a0d9

Please sign in to comment.