Files
lserp_cs_5.0/插件库/Zhaizj.Framework/Serialization/JsonParser/CharSource.cs
T
2026-07-10 15:25:05 +08:00

68 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace Zhaizj.Framework.Serialization {
internal class CharSource {
public char[] charList;
private int index = -1;
public String strSrc { get; set; }
public CharSource( String src ) {
this.strSrc = clearComment( src );
this.charList = this.strSrc.ToCharArray();
}
private String clearComment( String src ) {
if (src == null) return null;
String[] arr = src.Split( '\n' );
StringBuilder sb = new StringBuilder();
foreach (String line in arr) {
if (line.Trim().StartsWith( "//" )) continue;
sb.Append( line );
sb.AppendLine();
}
return sb.ToString();
}
public char getCurrent() {
return charList[index];
}
public void move() {
if (index >= charList.Length - 1) return;
index++;
}
public void back() {
index--;
}
public void moveToText() {
index++;
char c = this.getCurrent();
if (c == 0 || c > ' ') return;
moveToText();
}
public Boolean isEnd() {
return (index >= charList.Length - 1);
}
public int getIndex() {
return this.index;
}
}
}